@krapht/ork 1.0.0-alpha.2 → 1.0.0-alpha.21

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.
Files changed (75) hide show
  1. package/README.md +12 -7
  2. package/dist/__build_info__-0wqQ-rtf.mjs +180 -0
  3. package/dist/apply-Mb0fNpCX.mjs +17 -0
  4. package/dist/argument-error-CihH46Le.mjs +27 -0
  5. package/dist/attach-C0-YyNoY.mjs +92 -0
  6. package/dist/attach-CAKNqnUK.mjs +1259 -0
  7. package/dist/bin.mjs +1885 -1609
  8. package/dist/brief-C2hew8cS.mjs +116 -0
  9. package/dist/{decide-CGyx9rv7.mjs → builtin-files-YYAnbZGD.mjs} +3 -51
  10. package/dist/chips-CP_pgKlj.mjs +48 -0
  11. package/dist/command-tree-CEkzWNy6.mjs +63 -0
  12. package/dist/{completion-CSU5vkEt.mjs → completion-K4rAVsrf.mjs} +200 -30
  13. package/dist/context-B-fjPJky.mjs +106 -0
  14. package/dist/context-DMK0U1w0.mjs +160 -0
  15. package/dist/detached-q0AYG0Bs.mjs +39 -0
  16. package/dist/extra-arguments-BxQMXARO.mjs +13 -0
  17. package/dist/{find-D6Gj1sxg.mjs → find-Ct5CNl1J.mjs} +2 -2
  18. package/dist/flags-C90N4J1i.mjs +145 -0
  19. package/dist/follow-ups-D3HPyNYM.mjs +568 -0
  20. package/dist/format-CiPhQqbX.mjs +260 -0
  21. package/dist/{help-groups-BwYoAWsh.mjs → help-groups-BQvcKQ9H.mjs} +49 -78
  22. package/dist/in-a-run-D_wg4iJi.mjs +27 -0
  23. package/dist/install-Hji6LIei.mjs +259 -0
  24. package/dist/{limits-B1-DYc3d.mjs → limits-BD6RZRCS.mjs} +2 -2
  25. package/dist/{mcp-DE_EmyVm.mjs → mcp-CpbDmBLG.mjs} +6 -6
  26. package/dist/once-J8Qn5fTG.mjs +112 -0
  27. package/dist/orphan-guard-BFKg8VSd.mjs +58 -0
  28. package/dist/output-DXZbnFt_.mjs +458 -0
  29. package/dist/outputs-text-CNTJ7Qq_.mjs +19 -0
  30. package/dist/{pause-CL6N_Xrj.mjs → pause-Cl4ZYA35.mjs} +7 -4
  31. package/dist/print-DzugGZQB.mjs +19 -0
  32. package/dist/project-records-CtkmlsHN.mjs +233 -0
  33. package/dist/refusals-DQQX3AIb.mjs +116 -0
  34. package/dist/{relay-0SD0erwf.mjs → relay-CiP77vga.mjs} +2 -2
  35. package/dist/run-CtuNY3mE.mjs +234 -0
  36. package/dist/send-DRYGks8K.mjs +104 -0
  37. package/dist/short-flags-DkJLWVqh.mjs +1 -0
  38. package/dist/short-flags-Qf21as0E.mjs +83 -0
  39. package/dist/src-BMFQKHz4.mjs +3122 -0
  40. package/dist/{src-BbyEoMn4.mjs → src-BrFfDKux.mjs} +800 -235
  41. package/dist/{src-Dujmvv4s.mjs → src-BuF9Lbow.mjs} +12580 -5505
  42. package/dist/{src-DOcK8Jfp.mjs → src-k0A_QpST.mjs} +1024 -590
  43. package/dist/store-rTgRu8xy.mjs +25 -0
  44. package/dist/ui/THIRD_PARTY_LICENSES.txt +612 -0
  45. package/dist/ui/assets/app-BYxpKJRh.css +1 -0
  46. package/dist/ui/assets/app-SEFEJLkF.js +112 -0
  47. package/dist/ui/assets/{index-9dFha9Qn.js → index-Cb6Voq_W.js} +3 -3
  48. package/dist/ui/assets/theme-CdXvqTQ6.js +1 -0
  49. package/dist/ui/index.html +2 -2
  50. package/dist/{ui-CTmO2Xzu.mjs → ui-C2f37TSb.mjs} +57 -25
  51. package/dist/usage-BuvGcQSk.mjs +256 -0
  52. package/dist/validate-ObP5lt29.mjs +1 -0
  53. package/dist/validate-_HjACtk9.mjs +632 -0
  54. package/dist/verdict-B592j1W3.mjs +84 -0
  55. package/dist/{watch-CtbgDAcz.mjs → watch-DV3ixCYj.mjs} +45 -17
  56. package/dist/{workflows-D1_WVukk.mjs → workflows-QLjBhGNS.mjs} +30 -5
  57. package/dist/worktrees-D3ubG_Qw.mjs +302 -0
  58. package/dist/yolo-BSH1E_kE.mjs +33 -0
  59. package/package.json +10 -8
  60. package/dist/__build_info__-fy6L1Mrd.mjs +0 -615
  61. package/dist/clean-DaHjs__2.mjs +0 -88
  62. package/dist/context-DT8MfEIR.mjs +0 -274
  63. package/dist/format-Dnfv8zMT.mjs +0 -427
  64. package/dist/in-a-run-pLAZeNys.mjs +0 -22
  65. package/dist/list-BrH8KRSJ.mjs +0 -110
  66. package/dist/output-BLQWD6MJ.mjs +0 -950
  67. package/dist/remove-BeGdqroy.mjs +0 -194
  68. package/dist/report-DK4LGqwF.mjs +0 -129
  69. package/dist/send-C8tunWhv.mjs +0 -163
  70. package/dist/src-CCUKRX51.mjs +0 -1204
  71. package/dist/ui/assets/app-BNT0SuIz.css +0 -1
  72. package/dist/ui/assets/app-T7wVAhgx.js +0 -67
  73. package/dist/ui/assets/theme-3xH5jxKs.js +0 -1
  74. package/dist/usage-DYUmP0i4.mjs +0 -419
  75. package/dist/worktrees-DdMYoNOC.mjs +0 -212
@@ -0,0 +1,112 @@
1
+ import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as T,Z as E,_ as D,a as O,at as k,b as A,c as j,ct as M,d as N,et as P,f as F,g as I,h as L,i as R,j as ee,k as te,l as ne,lt as re,m as ie,n as ae,nt as oe,o as se,ot as ce,p as le,q as ue,r as de,rt as fe,s as pe,st as me,t as he,tt as ge,u as _e,v as ve,w as ye,x as be,y as xe,z}from"./theme-CdXvqTQ6.js";function Se(){let e=this._zod;return e.message??=JSON.stringify(e.def,l,2),e.message}function Ce(e){this._zod.message=e}var we={get:Se,set:Ce,enumerable:!0,configurable:!0},Te={value:void 0,enumerable:!1},Ee=new WeakSet([Object.prototype,Error.prototype]),De=O(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Te.value=t,Object.defineProperty(e,"issues",Te),Te.value=void 0,Object.defineProperty(e,"message",we);let n=Object.getPrototypeOf(e);Ee.has(n)||(Ee.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Oe(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ke(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Oe(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ae(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function je(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Me=e=>{let t=(n,r,i,o)=>{let s=i?{...i,async:!1}:{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new de;if(c.issues.length){let n=new((o?.Err)??e)(c.issues.map(e=>a(e,s,se())));throw L(n,o?.callee??t),n}return c.value};return t},Ne=e=>{let t=async(n,r,i,o)=>{let s=i?{...i,async:!0}:{async:!0},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise&&(c=await c),c.issues.length){let n=new((o?.Err)??e)(c.issues.map(e=>a(e,s,se())));throw L(n,o?.callee??t),n}return c.value};return t},Pe=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new de;return a.issues.length?Fe(e,a.issues,i):{success:!0,data:a.value}};function Fe(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>a(e,n,se()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Ie=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Fe(e,a.issues,i):{success:!0,data:a.value}},Le=Symbol.for(`zod.compile.invalid`),Re=Symbol.for(`zod.compile.fallback`),ze=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Le)return!0;if(r.definite===!0&&n===void 0)return!1}return Be(e,t,n)});function Be(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Re]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new de;return a.issues.length===0}var Ve=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},He=e=>{let t=Me(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,je(n,a))};return n},Ue=e=>{let t=Me(e),n=(e,r,i,a)=>t(e,r,i,je(n,a));return n},We=e=>{let t=Ne(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,je(n,a))};return n},Ge=e=>{let t=Ne(e),n=async(e,r,i,a)=>await t(e,r,i,je(n,a));return n},Ke=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Pe(e)(t,n,i)},qe=e=>(t,n,r)=>Pe(e)(t,n,r),Je=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ie(e)(t,n,i)},Ye=e=>async(t,n,r)=>Ie(e)(t,n,r),Xe=/^[cC][0-9a-z]{6,}$/,Ze=/^[0-9a-z]+$/,Qe=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,$e=/^[0-9a-vA-V]{20}$/,et=/^[A-Za-z0-9]{27}$/,tt=/^[a-zA-Z0-9_-]{21}$/;function nt(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var rt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,it=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,at=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ot=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,st=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function ct(){return new RegExp(st,`u`)}var lt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ut=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,dt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ft=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mt=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ht=/^https?$/,gt=/^\+[1-9]\d{6,14}$/,_t=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function vt(e){return RegExp(`^${e}$`)}var yt=vt(_t);function bt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xt(e){return RegExp(`^${bt(e)}$`)}function St(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${bt({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${bt({precision:e.precision})}`:n;return RegExp(`^${_t}T(?:${r})$`)}var Ct=/^[\s\S]{0,}$/,wt=/^-?\d+$/,Tt=/^-?\d+(?:\.\d+)?$/,Et=/^(?:true|false)$/i,Dt=/^[^A-Z]*$/,Ot=/^[^a-z]*$/,kt=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),At=e=>{let t=e.value;return!n(t)&&t.length!==void 0},jt={number:`number`,bigint:`bigint`,object:`date`},Mt=O(`$ZodCheckLessThan`,(e,t)=>{kt.init(e,t);let n=jt[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:jt[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Nt=O(`$ZodCheckGreaterThan`,(e,t)=>{kt.init(e,t);let n=jt[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:jt[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pt=O(`$ZodCheckMultipleOf`,(e,t)=>{kt.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):i(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ft=O(`$ZodCheckNumberFormat`,(e,t)=>{kt.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ne[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),It=O(`$ZodCheckMaxLength`,(e,t)=>{var n;kt.init(e,t),(n=e._zod.def).when??(n.when=At),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?ve(r):i)<=t.maximum)return;let a=te(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Lt=O(`$ZodCheckMinLength`,(e,t)=>{var n;kt.init(e,t),(n=e._zod.def).when??(n.when=At),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?ve(r):i)>=t.minimum)return;let a=te(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Rt=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;kt.init(e,t),(n=e._zod.def).when??(n.when=At),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?ve(r):i;if(a===t.length)return;let o=te(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),zt=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;kt.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Bt=O(`$ZodCheckRegex`,(e,t)=>{zt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Vt=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Dt,zt.init(e,t)}),Ht=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ot,zt.init(e,t)}),Ut=O(`$ZodCheckIncludes`,(e,t)=>{kt.init(e,t);let n=r(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Wt=O(`$ZodCheckStartsWith`,(e,t)=>{kt.init(e,t);let n=RegExp(`^${r(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Gt=O(`$ZodCheckEndsWith`,(e,t)=>{kt.init(e,t);let n=RegExp(`.*${r(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Kt=O(`$ZodCheckOverwrite`,(e,t)=>{kt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),qt=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
3
+ `)}\n};`)(...Object.values(this.closed))}},Jt={major:4,minor:6,patch:7},Yt=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jt;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=_e(t),a;for(let o of n){if(o._zod.def.when){if(ye(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new de;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(le(t.issues,n,e),i||=_e(t,n))});else{if(t.issues.length===n)continue;le(t.issues,n,e),i||=_e(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(_e(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new de;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new de;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return t(this,`~standard`,Qt(this))},set"~standard"(e){x(this,`~standard`,e)}}),Xt=(e,t)=>e.issues.length?{issues:e.issues.map(e=>a(e,t,se()))}:{value:e.value};async function Zt(e,t){let n={async:!0};return Xt(await e._zod.run({value:t,issues:[]},n),n)}function Qt(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Xt(r,n)}catch{}return Zt(e,t)},vendor:`zod`,version:1}}var $t=O(`$ZodString`,(e,t)=>{Yt.init(e,t),e._zod.pattern=t.pattern??Ct,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),en=O(`$ZodStringFormat`,(e,t)=>{zt.init(e,t),$t.init(e,t)}),tn=O(`$ZodGUID`,(e,t)=>{t.pattern??=it,en.init(e,t)}),nn=O(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=at(e)}else t.pattern??=at();en.init(e,t)}),rn=O(`$ZodEmail`,(e,t)=>{t.pattern??=ot,en.init(e,t)});function an(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function on(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?an(e)||2:sn(e,t)}function sn(e,t){if(!t.normalize&&t.protocol?.source===ht.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var cn=/[\t\n\r]/g;function ln(e){return e.replace(cn,``)}function un(e,t){return t.lastIndex=0,t.test(e.hostname)}function dn(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var fn=O(`$ZodURL`,(e,t)=>{en.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=on(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=ln(r);return}t.hostname&&!un(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!dn(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:ln(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),pn=O(`$ZodEmoji`,(e,t)=>{t.pattern??=ct(),en.init(e,t)}),mn=O(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?tt:nt(t.length),en.init(e,t)}),hn=O(`$ZodCUID`,(e,t)=>{t.pattern??=Xe,en.init(e,t)}),gn=O(`$ZodCUID2`,(e,t)=>{t.pattern??=Ze,en.init(e,t)}),_n=O(`$ZodULID`,(e,t)=>{t.pattern??=Qe,en.init(e,t)}),vn=O(`$ZodXID`,(e,t)=>{t.pattern??=$e,en.init(e,t)}),yn=O(`$ZodKSUID`,(e,t)=>{t.pattern??=et,en.init(e,t)}),bn=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=St(t),en.init(e,t)}),xn=O(`$ZodISODate`,(e,t)=>{t.pattern??=yt,en.init(e,t)}),Sn=O(`$ZodISOTime`,(e,t)=>{t.pattern??=xt(t),en.init(e,t)}),Cn=O(`$ZodISODuration`,(e,t)=>{t.pattern??=rt,en.init(e,t)}),wn=O(`$ZodIPv4`,(e,t)=>{t.pattern??=lt,en.init(e,t)}),Tn=/^[0-9a-fA-F:.]+$/;function En(e){return Tn.test(e)?an(`http://[${e}]`):!1}var Dn=O(`$ZodIPv6`,(e,t)=>{t.pattern??=ut,en.init(e,t),e._zod.check=n=>{En(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),On=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=dt,en.init(e,t)});function kn(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:En(n)}var An=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ft,en.init(e,t),e._zod.check=n=>{kn(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function jn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Mn=/^[0-9a-zA-Z+/]*={0,2}$/,Nn=O(`$ZodBase64`,(e,t)=>{t.pattern??=Mn,en.init(e,t),e._zod.check=n=>{jn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Pn=/^[A-Za-z0-9_-]*$/;function Fn(e){if(!Pn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return jn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var In=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Pn,en.init(e,t),e._zod.check=n=>{Fn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ln=O(`$ZodE164`,(e,t)=>{t.pattern??=gt,en.init(e,t)});function Rn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var zn=O(`$ZodJWT`,(e,t)=>{en.init(e,t),e._zod.check=n=>{Rn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Bn=O(`$ZodNumber`,(e,t)=>{Yt.init(e,t),e._zod.pattern=Tt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Vn=O(`$ZodNumberFormat`,(e,t)=>{Ft.init(e,t),Bn.init(e,t)}),Hn=O(`$ZodBoolean`,(e,t)=>{Yt.init(e,t),e._zod.pattern=Et,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Un=O(`$ZodUnknown`,(e,t)=>{Yt.init(e,t),e._zod.parse=e=>e}),Wn=O(`$ZodNever`,(e,t)=>{Yt.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Gn(t,n){let r=e(t._zod.def.checks);if(!r.length)return;let i=Math.min(...r.map(e=>e[0])),a=t._zod.parse;t._zod.parse=(r,o)=>{let s=n(r.value);if(s>i&&!o?.skipChecks&&o?.direction!==`backward`){for(let[n,i]of e(t._zod.def.checks))if(s>n&&i._zod.def.when(r)){let e=r.issues.length;return i._zod.check(r),r.issues[e].continue=!1,le(r.issues,e,t),r}}return a(r,o)}}var Kn=e=>Array.isArray(e)?e.length:-1;function qn(e,t,n){e.issues.length&&t.issues.push(...ue(n,e.issues)),t.value[n]=e.value}var Jn=O(`$ZodArray`,(e,t)=>{Yt.init(e,t);let n=pe.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>qn(t,r,e)));else if(qn(c,r,e),s&&c.issues.length!==0&&_e(c))break}return o.length?Promise.all(o).then(()=>r):r},Gn(e,Kn)});function Yn(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...ue(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Xn=[];function Zn(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Xn,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=c(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Qn(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(_e(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Yn(e,n,i,t,d,f))):Yn(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var $n=O(`$ZodObject`,(e,t)=>{Yt.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=ie(()=>Zn(t));A(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||F(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=p,o=t.catchall,s,c=pe.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(_e(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Yn(n,t,e,r,a,o))):Yn(s,t,e,r,a,o)}return o?Qn(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),er=O(`$ZodObjectJIT`,(e,t)=>{$n.init(e,t);let n=e._zod.parse,r=ie(()=>Zn(t)),i=pe.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new qt([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
4
+ let ${e}_ab = false;
5
+ for (let i = 0; i < ${e}.issues.length; i++) {
6
+ const iss = ${e}.issues[i];
7
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
8
+ payload.issues.push(iss);
9
+ if (iss.continue !== true) ${e}_ab = true;
10
+ }
11
+ if (${e}_ab && ctx && ctx.abortEarly) {
12
+ payload.value = newResult;
13
+ return payload;
14
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:y(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
15
+ const ${n}_present = ${i};
16
+ if (!${n}.issues.length || ${n}_present) {
17
+ if (${n}.issues.length) {${c(n,r)}
18
+ }
19
+
20
+ if (${e}) {
21
+ newResult[${r}] = ${n}.value;
22
+ }
23
+ }
24
+
25
+ `)}else f?(o.write(`
26
+ if (${n}.issues.length) {${c(n,r)}
27
+ }
28
+ `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
29
+ if (${n}.value !== undefined || ${i}) {
30
+ newResult[${r}] = ${n}.value;
31
+ }
32
+ `)):o.write(`
33
+ const ${n}_present = ${i};
34
+ if (${n}.issues.length) {${c(n,r)}
35
+ }
36
+ if (!${n}_present && !${n}.issues.length) {
37
+ payload.issues.push({
38
+ code: "invalid_type",
39
+ expected: "nonoptional",
40
+ input: undefined,
41
+ path: [${r}]
42
+ });
43
+ if (ctx && ctx.abortEarly) {
44
+ payload.value = newResult;
45
+ return payload;
46
+ }
47
+ }
48
+
49
+ if (${n}_present) {
50
+ newResult[${r}] = ${n}.value;
51
+ }
52
+
53
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=p,c=!pe.jitless,l=c&&N.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Qn([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function tr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!_e(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>a(e,r,se())))}),t)}var nr=O(`$ZodUnion`,(e,t)=>{Yt.init(e,t),A(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),A(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),A(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>I(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>tr(t,r,e,i)):tr(o,r,e,i)}});function rr(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var ir=O(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,nr.init(e,t);let n=e._zod.parse;A(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||F(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=T(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=ie(()=>rr(t));e._zod.parse=(i,a)=>{let o=i.value;if(!p(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),ar=O(`$ZodIntersection`,(e,t)=>{Yt.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>sr(e,t,n)):sr(e,i,a)}});function or(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(m(e)&&m(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=or(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=or(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function sr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=or(t.value,n.value);if(!c.valid){if(_e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var cr=O(`$ZodTuple`,(e,t)=>{Yt.init(e,t);let n=t.items,r=pe.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=lr(n,`optin`),l=lr(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=_e(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(_e(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>ur(t,i,e))):ur(r,i,e)}}return s.length?Promise.all(s).then(()=>dr(u,i,n,o,l)):dr(u,i,n,o,l)}});function lr(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function ur(e,t,n){e.issues.length&&t.issues.push(...ue(n,e.issues)),t.value[n]=e.value}function dr(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...ue(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var fr=O(`$ZodRecord`,(e,t)=>{Yt.init(e,t);let n=pe.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let o=r.value;if(!m(o))return r.issues.push({expected:`record`,code:`invalid_type`,input:o,inst:e}),r;let s=[],c=t.keyType._zod.values;if(c&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let l=new Set;for(let n of c)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(l.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let c=t.keyType._zod.run({value:n,issues:[]},i);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(c.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>a(e,i,se())),input:n,path:[n],inst:e});continue}let u=c.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:o[n],issues:[]},i);d instanceof Promise?s.push(d.then(e=>{e.issues.length&&r.issues.push(...ue(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ue(n,d.issues)),r.value[u]=d.value)}let u;for(let e in o)if(!l.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=o[e]}else u??=[],u.push(e)}u&&u.length>0&&r.issues.push({code:`unrecognized_keys`,input:o,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let l;for(let n of Reflect.ownKeys(o)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(o,n))continue;let u=t.keyType._zod.run({value:n,issues:[]},i);if(u instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Tt.test(n)&&u.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(u=e)}if(u.issues.length){t.mode===`loose`?r.value[n]=o[n]:c?(l??=[],l.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:u.issues.map(e=>a(e,i,se())),input:n,path:[n],inst:e});continue}let d=u.value;if(d===`__proto__`)continue;let f=t.valueType._zod.run({value:o[n],issues:[]},i);f instanceof Promise?s.push(f.then(e=>{e.issues.length&&r.issues.push(...ue(n,e.issues)),r.value[d]=e.value})):(f.issues.length&&r.issues.push(...ue(n,f.issues)),r.value[d]=f.value)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:o,inst:e,keys:l,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),pr=O(`$ZodEnum`,(e,t)=>{Yt.init(e,t);let n=h(t.entries),i=new Set(n);e._zod.values=i,A(e,`pattern`,e=>{let t=h(e.def.entries).filter(e=>u.has(typeof e));return RegExp(t.length?`^(${t.map(e=>r(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,r)=>{let a=t.value;return i.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),mr=O(`$ZodLiteral`,(e,t)=>{Yt.init(e,t);let n=new Set(t.values);e._zod.values=n,A(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?r(e):e?r(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),hr=O(`$ZodTransform`,(e,t)=>{Yt.init(e,t),e._zod.optin=`optional`,pe.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new R(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new de;return n.value=i,n}});function gr(e,t){return e.value=t.issues.length?void 0:t.value,e}var _r=O(`$ZodOptional`,(e,t)=>{Yt.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,A(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),A(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${I(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>gr(e,t)):gr(e,r)}return t.innerType._zod.run(e,n)}}),vr=O(`$ZodExactOptional`,(e,t)=>{_r.init(e,t),A(e,`values`,e=>e.def.innerType._zod.values),A(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),yr=O(`$ZodNullable`,(e,t)=>{Yt.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin),A(e,`optout`,e=>e.def.innerType._zod.optout),A(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${I(t.source)}|null)$`):void 0}),A(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),br=O(`$ZodDefault`,(e,t)=>{Yt.init(e,t),e._zod.optin=`defaulted`,A(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>xr(e,t)):xr(r,t)}});function xr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Sr=O(`$ZodPrefault`,(e,t)=>{Yt.init(e,t),e._zod.optin=`defaulted`,A(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Cr=O(`$ZodNonOptional`,(e,t)=>{Yt.init(e,t),A(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>wr(t,e)):wr(i,e)}});function wr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Tr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>a(e,r,se()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Er=O(`$ZodCatch`,(e,t)=>{Yt.init(e,t),A(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),A(e,`optout`,e=>e.def.innerType._zod.optout),A(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Tr(e,r,t,n)):Tr(e,r,t,n)}}),Dr=O(`$ZodPipe`,(e,t)=>{Yt.init(e,t),A(e,`values`,e=>e.def.in._zod.values),A(e,`optin`,e=>e.def.in._zod.optin),A(e,`optout`,e=>e.def.out._zod.optout),A(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Or(e,t.in,n)):Or(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Or(e,t.out,n)):Or(r,t.out,n)}});function Or(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var kr=O(`$ZodReadonly`,(e,t)=>{Yt.init(e,t),A(e,`propValues`,e=>e.def.innerType._zod.propValues),A(e,`values`,e=>e.def.innerType._zod.values),A(e,`optin`,e=>e.def.innerType?._zod?.optin),A(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ar):Ar(r)}});function Ar(e){return e.memo||(e.value=Object.freeze(e.value)),e}var jr=O(`$ZodCustom`,(e,t)=>{kt.init(e,t),Yt.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Mr(t,n,r,e));Mr(i,n,r,e)}});function Mr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(g(e))}}var Nr=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Pr=`~memo`,Fr=[];function Ir(e){return typeof e==`object`&&!!e}function Lr(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Rr=new WeakMap,zr=0,Br=1,Vr=2;function Hr(e,t,n){let r=Rr.get(e);if(r!==void 0)return r?Vr:zr;if(t.has(e))return Vr;t.add(e);let i=zr,a=e=>{if(i!==Vr&&e?._zod){let r=Hr(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=zr;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Br:o.value?._zod?Hr(o.value,t,n):zr;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=T(c);s(e?o(e,!0):Br),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Hr(r,t,!1):Br);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Ur(e,i)}function Ur(e,t){return t!==Br&&Rr.set(e,t===Vr),t}function Wr(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Gr,Kr=[],qr={alloc(e,t,n){let r=Gr;if(!r)return n;Gr=void 0;let i={value:n,issues:null};return r.set(t.value,i),Kr.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Yr(n,e.value))throw new Nr;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Hr(e,new Set,!1);if(i===zr)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Vr||r?n=!0:r=!0}let l=s.value;if(!Ir(l))return t(s,c);let u=c[Pr];u||(u={buckets:new WeakMap,backEdges:void 0},c[Pr]=u);let d;i===c?d=a:(d=Wr(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Lr(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Gr=d;let p=Kr.length,m=t(s,c);Gr=void 0;let h=Kr.length>p?Kr.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Lr(e.issues):Fr),e)):(h&&(h.issues=m.issues.length?Lr(m.issues):Fr),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Jr(){return qr}function Yr(e,t){let n=e[Pr]?.backEdges;return n!==void 0&&Ir(t)&&n.has(t)}var Xr=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(C(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ge(e.values[0])}`:`Invalid option: expected one of ${o(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${o(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Zr(){return{localeError:Xr()}}var Qr,$r=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ei(){return new $r}(Qr=globalThis).__zod_globalRegistry??(Qr.__zod_globalRegistry=ei());var ti=globalThis.__zod_globalRegistry;function ni(e){return e.checks&&=[...e.checks],e}function ri(e,t){return new e(ni({type:`string`,...z(t)}))}function ii(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...z(t)})}function ai(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...z(t)})}function oi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...z(t)})}function si(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...z(t)})}function ci(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...z(t)})}function li(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...z(t)})}function ui(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...z(t)})}function di(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...z(t)})}function fi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...z(t)})}function pi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...z(t)})}function mi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...z(t)})}function hi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...z(t)})}function gi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...z(t)})}function _i(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...z(t)})}function vi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...z(t)})}function yi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...z(t)})}function bi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...z(t)})}function xi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...z(t)})}function Si(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...z(t)})}function Ci(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...z(t)})}function wi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...z(t)})}function Ti(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...z(t)})}function Ei(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...z(t)})}function Di(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...z(t)})}function Oi(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...z(t)})}function ki(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...z(t)})}function Ai(e,t){return new e(ni({type:`number`,checks:[],...z(t)}))}function ji(e,t){return new e(ni({type:`number`,coerce:!0,checks:[],...z(t)}))}function Mi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...z(t)})}function Ni(e,t){return new e({type:`boolean`,...z(t)})}function Pi(e){return new e({type:`unknown`})}function Fi(e,t){return new e({type:`never`,...z(t)})}function Ii(e,t){return new Mt({check:`less_than`,...z(t),value:e,inclusive:!1})}function Li(e,t){return new Mt({check:`less_than`,...z(t),value:e,inclusive:!0})}function Ri(e,t){return new Nt({check:`greater_than`,...z(t),value:e,inclusive:!1})}function zi(e,t){return new Nt({check:`greater_than`,...z(t),value:e,inclusive:!0})}function Bi(e,t){return new Pt({check:`multiple_of`,...z(t),value:e})}function Vi(e,t){return new It({check:`max_length`,...z(t),maximum:e})}function Hi(e,t){return new Lt({check:`min_length`,...z(t),minimum:e})}function Ui(e,t){return new Rt({check:`length_equals`,...z(t),length:e})}function Wi(e,t){return new Bt({check:`string_format`,format:`regex`,...z(t),pattern:e})}function Gi(e){return new Vt({check:`string_format`,format:`lowercase`,...z(e)})}function Ki(e){return new Ht({check:`string_format`,format:`uppercase`,...z(e)})}function qi(e,t){return new Ut({check:`string_format`,format:`includes`,...z(t),includes:e})}function Ji(e,t){return new Wt({check:`string_format`,format:`starts_with`,...z(t),prefix:e})}function Yi(e,t){return new Gt({check:`string_format`,format:`ends_with`,...z(t),suffix:e})}function Xi(e){return new Kt({check:`overwrite`,tx:e})}function Zi(e){return Xi(t=>t.normalize(e))}function Qi(){return Xi(e=>e.trim())}function $i(){return Xi(e=>e.toLowerCase())}function ea(){return Xi(e=>e.toUpperCase())}function ta(){return Xi(e=>P(e))}function na(e,t,n){return new e({type:`array`,element:t,...z(n)})}function ra(e,t,n){let r=z(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ia(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...z(n)})}function aa(e,t){let n=oa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(g(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(g(r))}},e(t.value,t)),t);return n}function oa(e,t){let n=new kt({check:`custom`,...z(t)});return n._zod.check=e,n}function sa(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&F(e,t,n[t]);return e}function ca(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ti,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function la(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function ua(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,ua(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&sa(o.schema,c),t.io===`input`&&ba(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function da(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function fa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${da(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+da(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
54
+
55
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function pa(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;pa(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var ma=new Set([`type`,`properties`,`required`,`additionalProperties`]),ha=[`oneOf`,`anyOf`];function ga(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function _a(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!ma.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ga(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}let i=e.length===1?e[0]:_a(e)??{allOf:e};F(n,r,i)}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=ga(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function va(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of ma)if(t in e)return;let n=t.filter(e=>ha.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=_a(t);else{let e=n[0],i=ha.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>_a([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,sa(e,r))}function ya(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):sa(i,s),sa(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())pa(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])va(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}sa(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,F(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Sa(t,`input`,e.processors),output:Sa(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ba(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return ba(r.element,n);if(r.type===`set`)return ba(r.valueType,n);if(r.type===`lazy`)return ba(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return ba(r.innerType,n);if(r.type===`intersection`)return ba(r.left,n)||ba(r.right,n);if(r.type===`record`||r.type===`map`)return ba(r.keyType,n)||ba(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ba(r.in,n)||ba(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ba(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ba(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ba(e,n))return!0;return!!(r.rest&&ba(r.rest,n))}return!1}var xa=(e,t={})=>n=>{let r=ca({...n,processors:t});return ua(e,r),fa(r,e),ya(r,e)},Sa=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ca({...i??{},target:a,io:t,processors:n});return ua(e,o),fa(o,e),ya(o,e)},Ca=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},wa=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ta=(e,t)=>{Ca(e,`minimum`,t),wa(e,`maximum`,t)},Ea=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Da=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Oa=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},ka=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Aa=(e,t)=>Ca(e,`minimum`,t.minimum),ja=(e,t)=>wa(e,`maximum`,t.maximum),Ma=e=>(t,n)=>{ka(t,n.format);let[r,i]=e[n.format];Ca(t,`minimum`,r),wa(t,`maximum`,i)},Na={greater_than:(e,t)=>Ca(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>wa(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ea(e,t.value),number_format:Ma(ne),bigint_format:Ma(j),min_length:Aa,max_length:ja,length_equals:(e,t)=>Ta(e,t.length),min_size:Aa,max_size:ja,size_equals:(e,t)=>Ta(e,t.size),string_format:(e,t)=>{ka(e,t.format),t.pattern&&Da(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Oa(e,t.mime)};function Pa(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Na[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ca(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ca(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&wa(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&wa(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ea(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Oa(t,i.mime);for(let e of i.patterns??[])Da(t,e);return t}var Fa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ia=new Map([[Mn,pt],[Pn,mt]]),La=e=>Ia.get(e)??e,Ra=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Pa(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Fa[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(La);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},za=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Pa(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):la(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Ba=(e,t,n,r)=>{n.type=`boolean`},Va=(e,t,n,r)=>{n.not={}},Ha=(e,t,n,r)=>{let i=e._zod.def,a=h(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Ua=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(la(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(la(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Wa=(e,t,n,r)=>{la(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Ga=(e,t,n,r)=>{la(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Ka=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Pa(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ua(a.element,t,{...r,path:[...r.path,`items`]})};function qa(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?qa(t.out):t.type===`catch`?qa(t.innerType):e._zod.optin}var Ja=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&la(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)F(i.properties,e,ua(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?qa(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ua(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ya=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ua(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Xa=(e,t,n,r)=>{let i=e._zod.def,a=ua(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ua(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Za=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>ua(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?ua(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?qa(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Pa(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function Qa(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Qa(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Qa(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Tt:wt).source)),p}var $a=new WeakMap;function eo(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of $a.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Qa(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var to=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Pa(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ua(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)F(i.patternProperties,La(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=ua(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=$a.get(t);n||(n=[],$a.set(t,n),t.deferred.push(()=>eo(t))),n.push(e)}i.additionalProperties=ua(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&qa(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},no=(e,t,n,r)=>{let i=e._zod.def,a=ua(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ro=(e,t,n,r)=>{let i=e._zod.def;ua(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},io=Symbol();function ao(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(la(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),io):JSON.parse(o)}var oo=(e,t,n,r)=>{let i=e._zod.def;ua(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=ao(i.defaultValue,e,t,n,r);o!==io&&(n.default=o)},so=(e,t,n,r)=>{let i=e._zod.def;ua(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=ao(i.defaultValue,e,t,n,r);o!==io&&(n._prefault=o)},co=(e,t,n,r)=>{let i=e._zod.def;ua(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{la(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},lo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ua(o,t,r);let s=t.seen.get(e);s.ref=o},uo=(e,t,n,r)=>{let i=e._zod.def;ua(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fo=(e,t,n,r)=>{let i=e._zod.def;ua(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},po=new WeakSet([Object.prototype,Error.prototype]);function mo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var ho=O(`ZodError`,(e,t)=>{De.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);po.has(n)||(po.add(n),mo(n,`format`,e=>t=>Ae(e,t)),mo(n,`flatten`,e=>t=>ke(e,t)),mo(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,l,2)}),mo(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,l,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),go=Me(ho),_o=Ne(ho),vo=Pe(ho),yo=Ie(ho),bo=He(ho),xo=Ue(ho),So=We(ho),Co=Ge(ho),wo=Ke(ho),To=qe(ho),Eo=Je(ho),Do=Ye(ho);function Oo(){pe.localeError||se(Zr())}function ko(){pe.memoizer||se({memoizer:Jr()})}var Ao=O(`ZodType`,(e,t)=>(Oo(),Yt.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(v(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return D(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ec(e,t))},superRefine(e,t){return this.check(tc(e,t))},overwrite(e){return this.check(Xi(e))},optional(){return Fs(this)},exactOptional(){return Ls(this)},nullable(){return zs(this)},nullish(){return Fs(zs(this))},nonoptional(e){return Gs(this,e)},array(){return ms(this)},or(e){return ys([this,e])},and(e){return Cs(this,e)},transform(e){return Ys(this,Ns(e))},default(e){return Vs(this,e)},prefault(e){return Us(this,e)},catch(e){return qs(this,e)},pipe(e){return Ys(this,e)},readonly(){return Zs(this)},describe(e){let t=this.clone();return ti.add(t,{description:e}),t},meta(...e){if(e.length===0)return ti.get(this);let t=this.clone();return ti.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return t(this,`~standard`,{...Qt(this),jsonSchema:{input:Sa(this,`input`),output:Sa(this,`output`)}})},set"~standard"(e){x(this,`~standard`,e)},parse:function e(t,n){return go(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await _o(this,t,n,{callee:e})},safeParse(e,t){return vo(this,e,t)},async safeParseAsync(e,t){return yo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){x(this,`spa`,e)},validate(e,t){return ze(this,e,t)},validateAsync(e,t){return Ve(this,e,t)},encode:function e(t,n){return bo(this,t,n,{callee:e})},decode:function e(t,n){return xo(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await So(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Co(this,t,n,{callee:e})},safeEncode(e,t){return wo(this,e,t)},safeDecode(e,t){return To(this,e,t)},async safeEncodeAsync(e,t){return Eo(this,e,t)},async safeDecodeAsync(e,t){return Do(this,e,t)},toJSONSchema(e){return xa(this,{})(e)},get description(){return ti.get(this)?.description},get _def(){return this._zod.def}}),jo=O(`_ZodString`,(e,t)=>{$t.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r)},be({format:e=>Pa(e).format??null,minLength:e=>Pa(e).minimum??null,maxLength:e=>Pa(e).maximum??null},{regex(...e){return this.check(Wi(...e))},includes(...e){return this.check(qi(...e))},startsWith(...e){return this.check(Ji(...e))},endsWith(...e){return this.check(Yi(...e))},min(...e){return this.check(Hi(...e))},max(...e){return this.check(Vi(...e))},length(...e){return this.check(Ui(...e))},nonempty(...e){return this.check(Hi(1,...e))},lowercase(e){return this.check(Gi(e))},uppercase(e){return this.check(Ki(e))},trim(){return this.check(Qi())},normalize(...e){return this.check(Zi(...e))},toLowerCase(){return this.check($i())},toUpperCase(){return this.check(ea())},slugify(){return this.check(ta())}})),Mo=O(`ZodString`,(e,t)=>{$t.init(e,t),jo.init(e,t)},{email(e){return this.check(ii(Ro,e))},url(e){return this.check(ui(Vo,e))},jwt(e){return this.check(Ti(ns,e))},emoji(e){return this.check(di(Ho,e))},guid(e){return this.check(ai(zo,e))},uuid(e){return this.check(oi(Bo,e))},uuidv4(e){return this.check(si(Bo,e))},uuidv6(e){return this.check(ci(Bo,e))},uuidv7(e){return this.check(li(Bo,e))},nanoid(e){return this.check(fi(Uo,e))},cuid(e){return this.check(pi(Wo,e))},cuid2(e){return this.check(mi(Go,e))},ulid(e){return this.check(hi(Ko,e))},base64(e){return this.check(Si($o,e))},base64url(e){return this.check(Ci(es,e))},xid(e){return this.check(gi(qo,e))},ksuid(e){return this.check(_i(Jo,e))},ipv4(e){return this.check(vi(Yo,e))},ipv6(e){return this.check(yi(Xo,e))},cidrv4(e){return this.check(bi(Zo,e))},cidrv6(e){return this.check(xi(Qo,e))},e164(e){return this.check(wi(ts,e))},datetime(e){return this.check(Ei(Po,e))},date(e){return this.check(Di(Fo,e))},time(e){return this.check(Oi(Io,e))},duration(e){return this.check(ki(Lo,e))}});function B(e){return ri(Mo,e)}var No=O(`ZodStringFormat`,(e,t)=>{en.init(e,t),jo.init(e,t)}),Po=O(`ZodISODateTime`,(e,t)=>{bn.init(e,t),No.init(e,t)}),Fo=O(`ZodISODate`,(e,t)=>{xn.init(e,t),No.init(e,t)}),Io=O(`ZodISOTime`,(e,t)=>{Sn.init(e,t),No.init(e,t)}),Lo=O(`ZodISODuration`,(e,t)=>{Cn.init(e,t),No.init(e,t)}),Ro=O(`ZodEmail`,(e,t)=>{rn.init(e,t),No.init(e,t)}),zo=O(`ZodGUID`,(e,t)=>{tn.init(e,t),No.init(e,t)}),Bo=O(`ZodUUID`,(e,t)=>{nn.init(e,t),No.init(e,t)}),Vo=O(`ZodURL`,(e,t)=>{fn.init(e,t),No.init(e,t)}),Ho=O(`ZodEmoji`,(e,t)=>{pn.init(e,t),No.init(e,t)}),Uo=O(`ZodNanoID`,(e,t)=>{mn.init(e,t),No.init(e,t)}),Wo=O(`ZodCUID`,(e,t)=>{hn.init(e,t),No.init(e,t)}),Go=O(`ZodCUID2`,(e,t)=>{gn.init(e,t),No.init(e,t)}),Ko=O(`ZodULID`,(e,t)=>{_n.init(e,t),No.init(e,t)}),qo=O(`ZodXID`,(e,t)=>{vn.init(e,t),No.init(e,t)}),Jo=O(`ZodKSUID`,(e,t)=>{yn.init(e,t),No.init(e,t)}),Yo=O(`ZodIPv4`,(e,t)=>{wn.init(e,t),No.init(e,t)}),Xo=O(`ZodIPv6`,(e,t)=>{Dn.init(e,t),No.init(e,t)}),Zo=O(`ZodCIDRv4`,(e,t)=>{On.init(e,t),No.init(e,t)}),Qo=O(`ZodCIDRv6`,(e,t)=>{An.init(e,t),No.init(e,t)}),$o=O(`ZodBase64`,(e,t)=>{Nn.init(e,t),No.init(e,t)}),es=O(`ZodBase64URL`,(e,t)=>{In.init(e,t),No.init(e,t)}),ts=O(`ZodE164`,(e,t)=>{Ln.init(e,t),No.init(e,t)}),ns=O(`ZodJWT`,(e,t)=>{zn.init(e,t),No.init(e,t)}),rs=O(`ZodNumber`,(e,t)=>{Bn.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(e,t,n,r),e.isFinite=!0},be({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Pa(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Pa(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Pa(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Pa(e).format??null},{gt(e,t){return this.check(Ri(e,t))},gte(e,t){return this.check(zi(e,t))},min(e,t){return this.check(zi(e,t))},lt(e,t){return this.check(Ii(e,t))},lte(e,t){return this.check(Li(e,t))},max(e,t){return this.check(Li(e,t))},int(e){return this.check(os(e))},safe(e){return this.check(os(e))},positive(e){return this.check(Ri(0,e))},nonnegative(e){return this.check(zi(0,e))},negative(e){return this.check(Ii(0,e))},nonpositive(e){return this.check(Li(0,e))},multipleOf(e,t){return this.check(Bi(e,t))},step(e,t){return this.check(Bi(e,t))},finite(){return this}}));function is(e){return Ai(rs,e)}var as=O(`ZodNumberFormat`,(e,t)=>{Vn.init(e,t),rs.init(e,t)});function os(e){return Mi(as,e)}var ss=O(`ZodBoolean`,(e,t)=>{Hn.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r)});function cs(e){return Ni(ss,e)}var ls=O(`ZodUnknown`,(e,t)=>{Un.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function us(){return Pi(ls)}var ds=O(`ZodNever`,(e,t)=>{Wn.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r)});function fs(e){return Fi(ds,e)}var ps=O(`ZodArray`,(e,t)=>{ko(),Jn.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Hi(e,t))},nonempty(e){return this.check(Hi(1,e))},max(e,t){return this.check(Vi(e,t))},length(e,t){return this.check(Ui(e,t))},unwrap(){return this.element}});function ms(e,t){return na(ps,e,t)}var hs=O(`ZodObject`,(e,t)=>{ko(),er.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r),ee(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return ks(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(v(this._zod.def,{catchall:e}))},passthrough(){return this.clone(v(this._zod.def,{catchall:us()}))},loose(){return this.clone(v(this._zod.def,{catchall:us()}))},strict(){return this.clone(v(this._zod.def,{catchall:fs()}))},strip(){return this.clone(v(this._zod.def,{catchall:void 0}))},extend(e){return b(this,e)},safeExtend(e){return E(this,e)},merge(e){return f(this,e)},pick(e){return d(this,e)},omit(e){return S(this,e)},partial(...e){return s(Ps,this,e[0])},exactPartial(...e){return s(Is,this,e[0],`exactPartial`)},required(...e){return w(Ws,this,e[0])}});function gs(e,t){return new hs({type:`object`,shape:e??{},...z(t)})}function V(e,t){return new hs({type:`object`,shape:e,catchall:fs(),...z(t)})}function _s(e,t){return new hs({type:`object`,shape:e,catchall:us(),...z(t)})}var vs=O(`ZodUnion`,(e,t)=>{nr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.options=t.options});function ys(e,t){return new vs({type:`union`,options:e,...z(t)})}var bs=O(`ZodDiscriminatedUnion`,(e,t)=>{vs.init(e,t),ir.init(e,t)});function xs(e,t,n){return new bs({type:`union`,options:t,discriminator:e,...z(n)})}var Ss=O(`ZodIntersection`,(e,t)=>{ar.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r)});function Cs(e,t){return new Ss({type:`intersection`,left:e,right:t})}var ws=O(`ZodTuple`,(e,t)=>{ko(),cr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new Ps({type:`optional`,innerType:e}))})}});function Ts(e,t,n){let r=t instanceof Yt;return new ws({type:`tuple`,items:e,rest:r?t:null,...z(r?n:t)})}var Es=O(`ZodRecord`,(e,t)=>{ko(),fr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ds(e,t,n){return!t||!t._zod?new Es({type:`record`,keyType:B(),valueType:e,...z(t)}):new Es({type:`record`,keyType:e,valueType:t,...z(n)})}var Os=O(`ZodEnum`,(e,t)=>{pr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Os({...t,checks:[],...z(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Os({...t,checks:[],...z(r),entries:i})}});function ks(e,t){return new Os({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...z(t)})}var As=O(`ZodLiteral`,(e,t)=>{mr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function js(e,t){return new As({type:`literal`,values:Array.isArray(e)?e:[e],...z(t)})}var Ms=O(`ZodTransform`,(e,t)=>{ko(),hr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new R(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(g(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(g(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ns(e){return new Ms({type:`transform`,transform:e})}var Ps=O(`ZodOptional`,(e,t)=>{_r.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fs(e){return new Ps({type:`optional`,innerType:e})}var Is=O(`ZodExactOptional`,(e,t)=>{vr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ls(e){return new Is({type:`optional`,innerType:e})}var Rs=O(`ZodNullable`,(e,t)=>{yr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zs(e){return new Rs({type:`nullable`,innerType:e})}var Bs=O(`ZodDefault`,(e,t)=>{br.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Vs(e,t){return new Bs({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():_(t)}})}var Hs=O(`ZodPrefault`,(e,t)=>{Sr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Us(e,t){return new Hs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():_(t)}})}var Ws=O(`ZodNonOptional`,(e,t)=>{Cr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gs(e,t){return new Ws({type:`nonoptional`,innerType:e,...z(t)})}var Ks=O(`ZodCatch`,(e,t)=>{Er.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function qs(e,t){return new Ks({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:xe(t)})}var Js=O(`ZodPipe`,(e,t)=>{Dr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r),e.in=t.in,e.out=t.out});function Ys(e,t){return new Js({type:`pipe`,in:e,out:t})}var Xs=O(`ZodReadonly`,(e,t)=>{kr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e){return new Xs({type:`readonly`,innerType:e})}var Qs=O(`ZodCustom`,(e,t)=>{jr.init(e,t),Ao.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r)});function $s(e,t){return ra(Qs,e??(()=>!0),t)}function ec(e,t={}){return ia(Qs,e,t)}function tc(e,t){return aa(e,t)}function nc(e){return ji(rs,e)}var H=re(ce(),1),rc={};function ic(e,t){let n=H.useRef(rc);return n.current===rc&&(n.current=e(t)),n}var ac=[],oc=void 0;function sc(){return oc}function cc(e){ac.push(e)}function lc(e){let t=(t,n)=>{let r=ic(dc).current,i;try{oc=r;for(let e of ac)e.before(r);i=e(t,n);for(let e of ac)e.after(r);r.didInitialize=!0}finally{oc=void 0}return i};return t.displayName=e.displayName||e.name,t}function uc(e){return H.forwardRef(lc(e))}function dc(){return{didInitialize:!1}}function fc(){}var pc=Object.freeze([]),mc=Object.freeze({}),U=typeof document<`u`?H.useLayoutEffect:()=>{};function hc(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var gc=hc(`https://base-ui.com/production-error`,`Base UI`),_c=H.createContext(void 0);function vc(e){let t=H.useContext(_c);if(t===void 0&&!e)throw Error(gc(72));return t}function yc(e){H.useEffect(e,pc)}var bc=0,xc=class e{static create(){return new e}currentId=bc;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=bc,t()},e)}isStarted(){return this.currentId!==bc}clear=()=>{this.currentId!==bc&&(clearTimeout(this.currentId),this.currentId=bc)};disposeEffect=()=>this.clear};function Sc(){let e=ic(xc.create).current;return yc(e.disposeEffect),e}function Cc(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:wc,platform:Tc,maxTouchPoints:Ec}=Cc(),Dc=wc.toLowerCase(),Oc=Tc.toLowerCase(),kc=/^i(os$|p)/.test(Oc)||Oc===`macintel`&&Ec>1,Ac=`android`,jc=Oc===Ac||Dc.includes(Ac),Mc=!kc&&Oc.startsWith(`mac`);Oc.startsWith(`win`),!jc&&/^(linux|chrome os)/.test(Oc);var Nc=Mc||kc,Pc=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),Fc=!Pc&&Dc.includes(`firefox`);!Pc&&Dc.includes(`chrom`);var Ic=Nc,Lc=/jsdom|happydom/.test(Dc);function Rc(e){e.preventDefault(),e.stopPropagation()}function zc(e){return`nativeEvent`in e}function Bc(e){return e.pointerType===``&&e.isTrusted?!0:jc&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Vc(e){return Lc?!1:!jc&&e.width===0&&e.height===0||e.type===`pointerdown`&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`&&(jc||e.buttons===0)||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Hc(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Uc(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function Wc(){return typeof window<`u`}function Gc(e){return Jc(e)?(e.nodeName||``).toLowerCase():`#document`}function Kc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qc(e){return((Jc(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Jc(e){return Wc()?e instanceof Node||e instanceof Kc(e).Node:!1}function Yc(e){return Wc()?e instanceof Element||e instanceof Kc(e).Element:!1}function Xc(e){return Wc()?e instanceof HTMLElement||e instanceof Kc(e).HTMLElement:!1}function Zc(e){return!Wc()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Kc(e).ShadowRoot}function Qc(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ll(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function $c(e){return/^(table|td|th)$/.test(Gc(e))}function el(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var tl=/transform|translate|scale|rotate|perspective|filter/,nl=/paint|layout|strict|content/,rl=e=>!!e&&e!==`none`,il;function al(e){let t=Yc(e)?ll(e):e;return rl(t.transform)||rl(t.translate)||rl(t.scale)||rl(t.rotate)||rl(t.perspective)||!sl()&&(rl(t.backdropFilter)||rl(t.filter))||tl.test(t.willChange||``)||nl.test(t.contain||``)}function ol(e){let t=dl(e);for(;Xc(t)&&!cl(t);){if(al(t))return t;if(el(t))return null;t=dl(t)}return null}function sl(){return il??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),il}function cl(e){return/^(html|body|#document)$/.test(Gc(e))}function ll(e){return Kc(e).getComputedStyle(e)}function ul(e){return Yc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function dl(e){if(Gc(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Zc(e)&&e.host||qc(e);return Zc(t)?t.host:t}function fl(e){let t=dl(e);return cl(t)?(e.ownerDocument||e).body:Xc(t)&&Qc(t)?t:fl(t)}function pl(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=fl(e),i=r===e.ownerDocument?.body,a=Kc(r);if(i){let e=ml(a);return t.concat(a,a.visualViewport||[],Qc(r)?r:[],e&&n?pl(e):[])}return t.concat(r,pl(r,[],n))}function ml(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function W(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Zc(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function gl(e,t){let n=e;for(;n;){if(Yc(n)&&n.matches(t))return n;n=n.assignedSlot??n.parentNode??(Zc(n)?n.host:null)}return null}function _l(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var vl=`data-base-ui-focusable`,yl=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,bl=`ArrowLeft`,xl=`ArrowRight`,Sl=`ArrowUp`,Cl=`ArrowDown`,wl=`data-starting-style`,Tl=`data-ending-style`,El={[wl]:``},Dl={[Tl]:``},Ol={transitionStatus(e){return e===`starting`?El:e===`ending`?Dl:null}},kl=`data-open`,Al=`data-closed`,jl=`data-anchor-hidden`,Ml=`data-popup-open`,Nl=`data-pressed`,Pl={[Ml]:``},Fl={[Ml]:``,[Nl]:``},Il={[kl]:``},Ll={[Al]:``},Rl={[jl]:``},zl={open(e){return e?Pl:null}},Bl={open(e){return e?Fl:null}},Vl={open(e){return e?Il:Ll},anchorHidden(e){return e?Rl:null}},Hl={...Vl,...Ol},Ul=`data-trigger-disabled`;function Wl(e,t){if(!Yc(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(Ul);for(let[,e]of t.entries())if(W(e,n))return!e.hasAttribute(Ul);return!1}function Gl(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function Kl(e){return e.matches(`html,body`)}function ql(e){return Xc(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function Jl(e){return gl(e,`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${yl}`)!=null}function Yl(e){return e?e.getAttribute(`role`)===`combobox`&&ql(e):!1}function Xl(e){if(!e||Lc)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function Zl(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function Ql(e,t){return t!=null&&!Hc(t)?0:typeof e==`function`?e():e}function $l(e,t,n){let r=Ql(e,n);return typeof r==`number`?r:r?.[t]}function eu(e){return typeof e==`function`?e():e}function tu(e,t){return t||e===`click`||e===`mousedown`}function nu(e){return e?.includes(`mouse`)&&e!==`mousedown`}function G(e,t,n,r){let i=!1,a=!1,o=r??mc;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function ru(e,t,n){let r=n??mc;return{reason:e,event:t??new Event(`base-ui`),...r}}var iu=`none`,au=`trigger-press`,ou=`trigger-hover`,su=`trigger-focus`,cu=`outside-press`,lu=`item-press`,uu=`close-press`,du=`input-change`,fu=`input-clear`,pu=`input-press`,mu=`focus-out`,hu=`escape-key`,gu=`list-navigation`,_u=`keyboard`,vu=`pointer`,yu=`cancel-open`,bu=`sibling-open`,xu=`disabled`,Su=`imperative-action`,Cu=`window-resize`,K=fe(),wu=H.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new xc,currentIdRef:{current:null},currentContextRef:{current:null}});function Tu(e,t){e.current=t.current}function Eu(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=H.useRef(n),a=H.useRef(n),o=H.useRef(null),s=H.useRef(null),c=Sc();return U(()=>{a.current=n,o.current?i.current={open:$l(i.current,`open`),close:$l(n,`close`)}:i.current=n},[n,o,i,a]),(0,K.jsx)(wu.Provider,{value:H.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function Du(e,t={open:!1}){let{open:n}=t,r=e.useState(`floatingId`),{currentIdRef:i,delayRef:a,timeoutMs:o,initialDelayRef:s,currentContextRef:c,hasProvider:l,timeout:u}=H.useContext(wu),[d,f]=H.useState(!1),p=H.useRef(n);return U(()=>{p.current=n},[n]),U(()=>{function t(){c.current?.setIsInstantPhase(!1),i.current=null,c.current=null,a.current=s.current,u.clear()}if(i.current&&!n&&i.current===r){if(f(!1),o){let n=r;return u.start(o,()=>{e.select(`open`)||i.current&&i.current!==n||t()}),()=>{(p.current||i.current!==n)&&u.clear()}}t()}},[n,r,i,a,o,s,c,u,e]),U(()=>{if(!n)return;let t=c.current,o=i.current;u.clear(),c.current={onOpenChange:e.setOpen,setIsInstantPhase:f},i.current=r,a.current={open:0,close:$l(s.current,`close`)},o!==null&&o!==r?(f(!0),t?.setIsInstantPhase(!0),t?.onOpenChange(!1,G(iu))):(f(!1),t?.setIsInstantPhase(!1))},[n,r,e,i,a,s,c,u]),U(()=>()=>{if(i.current===r){if(c.current=null,!p.current)return;i.current=null,Tu(a,s),u.clear()}},[c,i,a,r,s,u]),H.useMemo(()=>({activeIdRef:i,hasProvider:l,delayRef:a,isInstantPhase:d}),[i,l,a,d])}function Ou(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function ku(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Au(e,t,n,r){let i=ic(Mu).current;return Nu(i,e,t,n,r)&&Fu(i,[e,t,n,r]),i.callback}function ju(e){let t=ic(Mu).current;return Pu(t,e)&&Fu(t,e),t.callback}function Mu(){return{callback:null,cleanup:null,refs:[]}}function Nu(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Pu(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Fu(e,t){e.refs=t,e.callback=t.every(e=>e==null)?null:n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Iu(e){let t=ic(Lu,e).current;return t.next=e,U(t.effect),t}function Lu(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Ru={...H},zu=Ru.useInsertionEffect,Bu=zu&&zu!==Ru.useLayoutEffect?zu:e=>e();function q(e){let t=ic(Vu).current;return t.next=e,Bu(t.effect),t.trampoline}function Vu(){let e={next:void 0,callback:Hu,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Hu(){}var Uu=null;globalThis.requestAnimationFrame;var Wu=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},Gu=class e{static create(){return new e}static request(e){return Wu.request(e)}static cancel(e){return Wu.cancel(e)}currentId=Uu;request(e){this.cancel(),this.currentId=Wu.request(()=>{this.currentId=Uu,e()})}cancel=()=>{this.currentId!==Uu&&(Wu.cancel(this.currentId),this.currentId=Uu)};disposeEffect=()=>this.cancel};function Ku(){let e=ic(Gu.create).current;return yc(e.disposeEffect),e}function qu(e){return e?.ownerDocument||document}var Ju={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Yu={...Ju,position:`fixed`,margin:0,top:0,left:0},Xu={...Ju,position:`absolute`},Zu=H.forwardRef(function(e,t){let[n,r]=H.useState();U(()=>{Ic&&Pc&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,K.jsx)(`span`,{...e,ref:t,style:Yu,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Qu=Math.min,$u=Math.max,ed=Math.round,td=Math.floor,nd=e=>({x:e,y:e}),rd={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function id(e,t,n){return $u(e,Qu(t,n))}function ad(e,t){return typeof e==`function`?e(t):e}function od(e){return e.split(`-`)[0]}function sd(e){return e.split(`-`)[1]}function cd(e){return e===`x`?`y`:`x`}function ld(e){return e===`y`?`height`:`width`}function ud(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function dd(e){return cd(ud(e))}function fd(e,t,n){n===void 0&&(n=!1);let r=sd(e),i=dd(e),a=ld(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=xd(o)),[o,xd(o)]}function pd(e){let t=xd(e);return[md(e),t,md(t)]}function md(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var hd=[`left`,`right`],gd=[`right`,`left`],_d=[`top`,`bottom`],vd=[`bottom`,`top`];function yd(e,t,n){switch(e){case`top`:case`bottom`:return n?t?gd:hd:t?hd:gd;case`left`:case`right`:return t?_d:vd;default:return[]}}function bd(e,t,n,r){let i=sd(e),a=yd(od(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(md)))),a}function xd(e){let t=od(e);return rd[t]+e.slice(t.length)}function Sd(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Cd(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Sd(e)}function wd(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Td(e,t,n){return Math.floor(e/t)!==n}function Ed(e,t){return t<0||t>=e.length}function Dd(e,t){return Ad(e.current,{disabledIndices:t})}function Od(e,t){return Ad(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function kd(e,t,n){let{decrement:r,loopFocus:i,allowEscape:a,disabledIndices:o,minIndex:s,maxIndex:c}=n,l=()=>Ad(e,{startingIndex:t,decrement:r,disabledIndices:o}),u,d=!1;if(!i)u=r?Math.max(s,l()):Math.min(c,l());else if(r?t<=s:t>=c){let n=r?-1:e.length;a&&t!==n?u=-1:(u=r?c:s,d=!0)}else u=l();return{index:Ed(e,u)?-1:u,wrapped:d}}function Ad(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Md(e,a,r));return a}function jd(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=gl(e,`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!Md(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=td(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!Md(e,r,s))return r}};d&&Rc(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=Ad(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=Ad(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}Ed(e,f)&&(f=u)}if(n===`both`){let n=td(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&Rc(t),u%o===o-1?r&&(f=Ad(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Ad(e,{startingIndex:u,disabledIndices:s}),r&&Td(f,o,n)&&(f=Ad(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),Td(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&Rc(t),u%o===0?r&&(f=Ad(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Ad(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&Td(f,o,n)&&(f=Ad(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),Td(f,o,n)&&(f=u));let c=td(l/o)===n;Ed(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:Ad(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function Md(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Pd(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function Nd(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Pd(e,t=e?ll(e):null){return!e||!e.isConnected||!t||Nd(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Fd=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Id(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return Zc(n)?n.host:null}function Ld(e){for(let t of Array.from(e.children))if(Gc(t)===`summary`)return t;return null}function Rd(e,t){let n=Ld(t);return!!n&&(e===n||W(n,e))}function zd(e){let t=e?Gc(e):``;return e!=null&&e.matches(Fd)&&(t!==`summary`||e.parentElement!=null&&Gc(e.parentElement)===`details`&&Ld(e.parentElement)===e)&&(t!==`details`||Ld(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Bd(e){if(!zd(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Id(t)){let n=t!==e,r=Gc(t)===`slot`;if(t.hasAttribute(`inert`)||n&&Gc(t)===`details`&&!t.open&&!Rd(e,t)||t.hasAttribute(`hidden`)||!r&&!Vd(t,n))return!1}return!0}function Vd(e,t){let n=ll(e);return t?n.display!==`none`:Pd(e,n)}function Hd(e){let t=e.tabIndex;if(t<0){let t=Gc(e);if(t===`details`||t===`audio`||t===`video`||Xc(e)&&e.isContentEditable)return 0}return t}function Ud(e){if(Gc(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Wd(e,t){let n=Ud(e);if(!n)return!0;let r=t.find(e=>{let t=Ud(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Ud(e);return t?.name===n.name&&t.form===n.form})===n}function Gd(e){if(Xc(e)&&Gc(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return Xc(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Kd(e,t){Gd(e).forEach(e=>{zd(e)&&t.push(e),Kd(e,t)})}function qd(e,t,n){Gd(e).forEach(e=>{Xc(e)&&e.matches(t)&&n.push(e),qd(e,t,n)})}function Jd(e){return Bd(e)&&Hd(e)>=0}function Yd(e){let t=[];return Kd(e,t),t.filter(Bd)}function Xd(e){let t=Yd(e);return t.filter(e=>Hd(e)>=0&&Wd(e,t))}function Zd(e,t){let n=Xd(e),r=n.length;if(r===0)return;let i=hl(qu(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Qd(e){return Zd(qu(e).body,1)||e}function $d(e){return Zd(qu(e).body,-1)||e}function ef(e,t,n){if(!e)return null;let r=[];Kd(qu(e).body,r);let i=r.indexOf(e);if(i===-1)return null;let a=r.filter(Bd);for(let e=1;e<r.length;e+=1){let o=r[(i+t*e+r.length)%r.length];if(!W(n,o)&&Jd(o)&&Wd(o,a))return o}return r[i]}function tf(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!W(n,r)}function nf(e){Xd(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function rf(e){let t=[];qd(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function af(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...af(e,t.id,n)])}function of(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function sf(e){return`data-base-ui-${e}`}var cf=0;function lf(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(cf);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),fc;let o=requestAnimationFrame(a);return cf=o,()=>{cf===o&&(cancelAnimationFrame(o),cf=0)}}var uf=`data-base-ui-inert`,df=new WeakMap,ff=new WeakSet,pf=new WeakMap,mf=0;function hf(e){return e?Zc(e)?e.host:hf(e.parentNode):null}var gf=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=hf(t);return e.contains(n)?n:null}).filter(e=>e!=null),_f=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},vf=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Gc(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function yf(e,t,n,{mark:r=!0}){let i=gf(t,e),a=r?vf(t,_f(i),new Set(i)):[],o=[],s=[];if(n){let e=gf(t,Array.from(t.querySelectorAll(`[aria-live]`))),n=i.concat(e);vf(t,_f(n),new Set(n)).forEach(e=>{let t=e.getAttribute(`aria-hidden`),n=t!==null&&t!==`false`,r=(df.get(e)||0)+1;df.set(e,r),o.push(e),r===1&&n&&ff.add(e),n||e.setAttribute(`aria-hidden`,`true`)})}return r&&a.forEach(e=>{let t=(pf.get(e)||0)+1;pf.set(e,t),s.push(e),t===1&&e.setAttribute(uf,``)}),mf+=1,()=>{o.forEach(e=>{let t=(df.get(e)||0)-1;df.set(e,t),t||(ff.has(e)||e.removeAttribute(`aria-hidden`),ff.delete(e))}),r&&s.forEach(e=>{let t=(pf.get(e)||0)-1;pf.set(e,t),t||e.removeAttribute(uf)}),--mf,mf||(df=new WeakMap,ff=new WeakSet,pf=new WeakMap)}}function bf(e,t={}){let{ariaHidden:n=!1,mark:r=!0}=t,i=qu(e[0]).body;return yf(e,i,n,{mark:r})}function xf(){let[,e]=H.useState({});return H.useCallback(()=>{e({})},[])}var Sf=0;function Cf(e,t=`mui`){let n=H.useRef(void 0),r=xf(),i=e??n.current;return H.useEffect(()=>{n.current??(Sf+=1,n.current=`${t}-${Sf}`,e??r())},[e,t,r]),i}var wf=Ru.useId;function Tf(e,t){if(wf!==void 0){let n=wf();return e??(t?`${t}-${n}`:n)}return Cf(e,t)}var Ef=19;function Df(e){return Ef>=e}function Of(e){if(!H.isValidElement(e))return null;let t=e,n=t.props;return(Df(19)?n?.ref:t.ref)??null}function kf(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Af(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e)}else i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function jf(e,t){return typeof e==`function`?e(t):e}function Mf(e,t){return typeof e==`function`?e(t):e}var Nf={};function Pf(e,t,n,r,i){if(!n&&!r&&!i&&!e)return If(t);let a=If(e);return t&&(a=Lf(a,t)),n&&(a=Lf(a,n)),r&&(a=Lf(a,r)),i&&(a=Lf(a,i)),a}function Ff(e){if(e.length===0)return Nf;if(e.length===1)return If(e[0]);let t=If(e[0]);for(let n=1;n<e.length;n+=1)t=Lf(t,e[n]);return t}function If(e){return Vf(e)?{...e(Nf)}:Rf(e)}function Lf(e,t){return Vf(t)?t(e):zf(e,t)}function Rf(e){let t={...e};for(let e in t){let n=t[e];Bf(e,n)&&(t[e]=Uf(n))}return t}function zf(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=kf(e.style,r);break;case`className`:e[n]=Gf(e.className,r);break;default:e[n]=Bf(n,r)?Hf(e[n],r):r}}return e}function Bf(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Vf(e){return typeof e==`function`}function Hf(e,t){return t?e?(...n)=>{let r=n[0];if(Kf(r)){let i=r;Wf(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Uf(t):e}function Uf(e){return e&&((...t)=>{let n=t[0];return Kf(n)&&Wf(n),e(...t)})}function Wf(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Gf(e,t){return t?e?t+` `+e:t:e}function Kf(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function qf(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Zf(r));let i=Jf(t,n,r);if(n.enabled===!1)return null;let a=n.state??mc;return Qf(e,r,i,a)}function Jf(e,t,n){let{className:r,style:i}=e,{state:a=mc,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?jf(r,a):void 0,d=l?Mf(i,a):void 0,f=l?Af(a,c):mc,p=l&&s?Yf(s):void 0,m=l?kf(f,p)??{}:mc;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?ju([m.ref,Of(n),...o]):Au(m.ref,Of(n),o):Au(null,null)),l?(u!==void 0&&(m.className=Gf(m.className,u)),d!==void 0&&(m.style=kf(m.style,d)),m):mc}function Yf(e){return Array.isArray(e)?Ff(e):Pf(void 0,e)}var Xf=Symbol.for(`react.lazy`);function Zf(e){if(e?.$$typeof!==Xf)return e;let t=H.Children.toArray(e)[0];return H.isValidElement(t)?t:e}function Qf(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Pf(n,t.props);return e.ref=n.ref,H.cloneElement(t,e)}return $f(e,n)}function $f(e,t){return e===`button`?(0,H.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,H.createElement)(`img`,{alt:``,...t,key:t.key}):H.createElement(e,t)}var ep={style:{transition:`none`}},tp=`data-base-ui-click-trigger`,np=`data-base-ui-swipe-ignore`,rp=`data-swipe-ignore`,ip=`[${np}]`,ap=`[${rp}]`,op={fallbackAxisSide:`none`},sp={fallbackAxisSide:`end`},cp={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},lp=re(oe(),1),up=H.createContext(null),dp=()=>H.useContext(up),fp=sf(`portal`);function pp(e={}){let{ref:t,container:n,componentProps:r=mc,elementProps:i}=e,a=Tf(),o=dp()?.portalNode,[s,c]=H.useState(null),[l,u]=H.useState(null),d=q(e=>{e!==null&&u(e)}),f=H.useRef(null);U(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(Jc(n)?n:n.current))??o??document.body;e==null?f.current&&(f.current=null,u(null),c(null)):f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=qf(`div`,r,{ref:[t,d],props:[{id:a,[fp]:``},i]}),m=s&&p?lp.createPortal(p,s):null;return{node:l,nodeId:H.isValidElement(p)?p.props.id:void 0,subtree:m}}var mp=H.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=pp({container:o,ref:t,componentProps:e,elementProps:c}),f=H.useRef(null),p=H.useRef(null),m=H.useRef(null),h=H.useRef(null),[g,_]=H.useState(null),v=H.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;H.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&tf(e)&&(e.type===`focusin`?v.current&&=(rf(l),!1):(nf(l),v.current=!0))}return ku(Ou(l,`focusin`,e,!0),Ou(l,`focusout`,e,!0))},[l,y]),U(()=>{l&&b===!0&&v.current&&(rf(l),v.current=!1)},[b,l]);let S=H.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,K.jsxs)(H.Fragment,{children:[d,(0,K.jsxs)(up.Provider,{value:S,children:[x&&l&&(0,K.jsx)(Zu,{"data-type":`outside`,ref:f,onFocus:e=>{tf(e,l)?m.current?.focus():$d(g?g.domReference:null)?.focus()}}),x&&l&&(0,K.jsx)(`span`,{role:s,"aria-owns":u,style:cp}),l&&lp.createPortal(a,l),x&&l&&(0,K.jsx)(Zu,{"data-type":`outside`,ref:p,onFocus:e=>{tf(e,l)?h.current?.focus():(Qd(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,G(`focus-out`,e.nativeEvent)))}})]})]})});function hp(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var gp=class{nodesRef={current:[]};events=hp();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},_p=H.createContext(null),vp=H.createContext(null),yp=()=>H.useContext(_p)?.id||null,bp=e=>{let t=H.useContext(vp);return e??t};function xp(e){let t=Tf(),n=bp(e),r=yp();return U(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Sp(e){let{children:t,id:n}=e,r=yp();return(0,K.jsx)(_p.Provider,{value:H.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Cp(e){let{children:t,externalTree:n}=e,r=ic(()=>n??new gp).current;return(0,K.jsx)(vp.Provider,{value:r,children:t})}function wp(e){return e==null?e:`current`in e?e.current:e}function Tp(e,t){let n=Kc(_l(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||(Bc(e)?`keyboard`:t||`mouse`):`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var Ep=20,Dp=[];function Op(){Dp=Dp.filter(e=>e.deref()?.isConnected)}function kp(e){Op(),e&&Gc(e)!==`body`&&(Dp.push(new WeakRef(e)),Dp.length>Ep&&(Dp=Dp.slice(-20)))}function Ap(){return Op(),Dp[Dp.length-1]?.deref()}function jp(e){return e?Jd(e)?e:Xd(e)[0]||e:null}function Mp(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Yd(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Jd(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function Np(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,explicitReturnFocus:o,restoreFocus:s=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=t.useState(`open`),_=t.useState(`domReferenceElement`),v=t.useState(`floatingElement`),{events:y,dataRef:b}=t.context,x=q(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Yl(_)&&S,w=Iu(i),T=Iu(a),E=Iu(o),D=Iu(u),O=Iu(g),k=bp(m),A=dp(),j=H.useRef(!1),M=H.useRef(!1),N=H.useRef(!1),P=H.useRef(null),F=H.useRef(``),I=H.useRef(``),L=H.useRef(null),R=H.useRef(null),ee=Au(L,p,A?.beforeInsideRef),te=Au(R,A?.afterInsideRef),ne=Sc(),re=Sc(),ie=Ku(),ae=A!=null,oe=Zl(v),se=q((e=oe)=>e?Xd(e):[]),ce=q(()=>h?.().filter(e=>e!=null)??[]);H.useEffect(()=>{if(r||!c)return;function e(e){e.key===`Tab`&&W(oe,hl(qu(oe)))&&se().length===0&&!C&&Rc(e)}return Ou(qu(oe),`keydown`,e)},[r,oe,c,C,se]),H.useEffect(()=>{if(r||!g)return;let e=qu(oe);function t(){N.current=!1}function n(e){let t=_l(e),n=ce(),r=W(v,t)||W(_,t)||W(A?.portalNode,t)||n.some(e=>e===t||W(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,gl(t,`[data-base-ui-click-trigger]`)&&(M.current=!0,re.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return ku(Ou(e,`pointerdown`,n,!0),Ou(e,`pointerup`,t,!0),Ou(e,`pointercancel`,t,!0),Ou(e,`keydown`,i,!0),t)},[r,v,_,oe,g,A,re,ce]),H.useEffect(()=>{if(r||!l)return;let e=qu(oe);function n(){M.current=!0,re.start(0,()=>{M.current=!1})}function i(e){let t=_l(e);Jd(t)&&(P.current=t)}function a(n){let r=n.relatedTarget,i=n.currentTarget,a=_l(n);c&&r==null&&a!=null&&W(v,a)&&kp(a),queueMicrotask(()=>{let o=x(),l=t.context.triggerElements,u=ce(),p=r?.hasAttribute(sf(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,wp(f),wp(d)].includes(r),m=!(W(_,r)||W(v,r)||W(r,v)||W(A?.portalNode,r)||u.some(e=>e===r||W(e,r))||l.hasMatchingElement(e=>W(e,r))||p||k&&(af(k.nodesRef.current,o).find(e=>W(e.context?.elements.floating,r)||W(e.context?.elements.domReference,r))||of(k.nodesRef.current,o).find(e=>[e.context?.elements.floating,Zl(e.context?.elements.floating)].includes(r)||e.context?.elements.domReference===r)));if(i===_&&oe&&Mp(oe),s&&i!==_&&!Pd(a)&&hl(e)===e.body){if(Xc(oe)&&(oe.focus(),s===`popup`)){ie.request(()=>{oe.focus()});return}let e=se(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||oe;Xc(n)&&n.focus()}b.current.insideReactTree?b.current.insideReactTree=!1:(C||!c)&&r&&m&&!M.current&&(C||r!==Ap())&&(j.current=!0,t.setOpen(!1,G(mu,n)))})}function o(){N.current||(b.current.insideReactTree=!0,ne.start(0,()=>{b.current.insideReactTree=!1}))}let u=Xc(_)?_:null;if(v||u)return ku(u&&Ou(u,`focusout`,a),u&&Ou(u,`pointerdown`,n),v&&Ou(v,`focusin`,i),v&&Ou(v,`focusout`,a),v&&A&&Ou(v,`focusout`,o,!0))},[r,_,v,oe,c,k,A,t,l,s,se,C,x,b,ne,re,ie,d,f,ce]),H.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${sf(`portal`)}]`)||[]),t=(k?of(k.nodesRef.current,x()):[]).find(e=>Yl(e.context?.elements.domReference||null))?.context?.elements.domReference,n=bf([v,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ce(),t,wp(f),wp(d),C?_:null].filter(e=>e!=null),{ariaHidden:c||C,mark:!1}),i=bf([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,c,A,C,k,x,d,f,ce]),U(()=>{if(!g||r||!Xc(oe))return;F.current=``,I.current=``;let e=qu(oe),t=hl(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||W(oe,t))return;let i=null,a=()=>(i??=se(oe),i[0]||oe),o;o=r===!0||r===null?a():wp(r),o||=a();let s=W(oe,hl(e)),c=b.current.openEvent,l=c?.type===`mousedown`&&Bc(c);lf(o,{sync:l,preventScroll:o===oe,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=hl(e);return!(t!==o&&W(oe,t))}})})},[r,g,oe,se,w,D,O,b]);let le=H.useRef(null);U(()=>{if(r||!oe){le.current=null;return}le.current&&=(le.current.cancelled=!0,null);let e=qu(oe),t=hl(e),n=D.current==null;kp(t);function i(e){if(e.open||(F.current=Tp(e.nativeEvent,I.current)),(e.reason===`focus-out`&&e.triggerElement?.hasAttribute(sf(`focus-guard`))||e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`)&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(Bc(e.nativeEvent)||Vc(e.nativeEvent))j.current=!1;else{let e=!1;qu(oe).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&Gc(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Ap()||null,typeof i==`boolean`?s:wp(i)||s||null}return()=>{y.off(`openchange`,i);let t=hl(e),n=ce(),r=W(v,t)||n.some(e=>e===t||W(e,t))||k&&af(k.nodesRef.current,x(),!1).some(e=>W(e.context?.elements.floating,t)),o=T.current,s=F.current,c=a(s),l={cancelled:!1};le.current=l,queueMicrotask(()=>{le.current===l&&(le.current=null);let n=jp(c),i=E.current??typeof o!=`boolean`;if(!l.cancelled&&o&&!j.current&&Xc(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,v,oe,T,E,D,y,k,_,x,ce]),U(()=>{if(!Pc||g||!v)return;let e=hl(qu(v));Xc(e)&&ql(e)&&W(v,e)&&e.blur()},[g,v]),U(()=>{if(!r&&A)return A.setFocusManagerState({modal:c,closeOnFocusOut:l,open:g,onOpenChange:t.setOpen,domReference:_}),()=>{A.setFocusManagerState(null)}},[r,A,c,g,t,l,_]),U(()=>{if(!r&&oe)return Mp(oe),()=>{queueMicrotask(Op)}},[r,oe]);let ue=!r&&(!c||!C)&&(ae||c);return(0,K.jsxs)(H.Fragment,{children:[ue&&(0,K.jsx)(Zu,{"data-type":`inside`,ref:ee,onFocus:e=>{if(c){let e=se();lf(e[e.length-1])}else A?.portalNode&&(j.current=!1,tf(e,A.portalNode)?Qd(_)?.focus():wp(f??A.beforeOutsideRef)?.focus())}}),n,ue&&(0,K.jsx)(Zu,{"data-type":`inside`,ref:te,onFocus:e=>{c?lf(se()[0]):A?.portalNode&&(l&&(j.current=!0),tf(e,A.portalNode)?$d(_)?.focus():wp(d??A.afterOutsideRef)?.focus())}})]})}function Pp(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=au}=t,l=e.context.dataRef,u=H.useRef(void 0),d=Ku(),f=Sc(),p=H.useMemo(()=>{function t(t,n,r,i){let a=G(c,n,r);t&&i===`touch`&&s>0?f.start(s,()=>{e.setOpen(!0,a)}):e.setOpen(t,a)}function n(t,n,r){let a=l.current.openEvent,s=e.select(`domReferenceElement`)!==n;return t&&s||!t||!i?!0:a&&(typeof o==`function`?o():o)?!r(a.type):!1}return{onPointerDown(e){u.current=Hc(e.pointerType,!0)&&Vc(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(i){let o=u.current,s=i.nativeEvent,c=e.select(`open`);if(i.button!==0||r===`click`||Hc(o,!0)&&a)return;let l=n(c,i.currentTarget,e=>e===`click`||e===`mousedown`),f=_l(s),p=ql(f);if(p||o===`virtual`){t(l,s,p?f:i.currentTarget,o);return}let m=i.currentTarget;d.request(()=>{t(l,s,m,o)})},onClick(i){if(r===`mousedown-only`)return;let o=u.current;r===`mousedown`&&o?u.current=void 0:Hc(o,!0)&&a||t(n(e.select(`open`),i.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),i.nativeEvent,i.currentTarget,o)},onKeyDown(){u.current=void 0}}},[l,r,a,c,e,o,i,d,f,s]);return H.useMemo(()=>n?{reference:p}:mc,[n,p])}function Fp(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,(!i||c)&&(d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function Ip(e){return e!=null&&e.clientX!=null}function Lp(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=e.useState(`open`),a=e.useState(`floatingElement`),o=e.useState(`domReferenceElement`),s=e.context.dataRef,c=H.useRef(!1),l=H.useRef(null),[u,d]=H.useState(),[f,p]=H.useState([]),m=q(t=>{e.set(`positionReference`,t)}),h=q((t,n,i)=>{c.current||(!s.current.openEvent||Ip(s.current.openEvent))&&e.set(`positionReference`,Fp(i??o,{x:t,y:n,axis:r,dataRef:s,pointerType:u}))}),g=q(e=>{i?l.current||(h(e.clientX,e.clientY,e.currentTarget),p([])):h(e.clientX,e.clientY,e.currentTarget)}),_=Hc(u)?a:i;H.useEffect(()=>{if(!n){m(o);return}if(!_)return;function e(){l.current?.(),l.current=null}let t=Kc(a);function r(t){let n=_l(t);W(a,n)?e():h(t.clientX,t.clientY)}return!s.current.openEvent||Ip(s.current.openEvent)?l.current=Ou(t,`mousemove`,r):m(o),e},[_,n,a,s,o,e,h,m,f]),H.useEffect(()=>()=>{e.set(`positionReference`,null)},[e]),H.useEffect(()=>{n&&!a&&(c.current=!1)},[n,a]),H.useEffect(()=>{!n&&i&&(c.current=!0)},[n,i]);let v=H.useMemo(()=>{function e(e){d(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:g,onMouseEnter:g}},[g]);return H.useMemo(()=>n?{reference:v,trigger:v}:{},[n,v])}function Rp(){return!1}function zp(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Bp(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Rp,bubbles:s,externalTree:c}=t,l=e.useState(`open`),u=e.useState(`floatingElement`),{dataRef:d,events:f}=e.context,p=bp(c),m=q(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=q(()=>a),{escapeKey:v,outsidePress:y}=zp(s),b=H.useRef(!1),x=H.useRef(!1),S=H.useRef(!1),C=H.useRef(!1),w=H.useRef(!1),T=H.useRef(``),E=H.useRef(null),D=Sc(),O=Sc(),k=Sc(),A=q(()=>{O.clear(),d.current.insideReactTree=!1}),j=q(e=>{let t=d.current.floatingContext?.nodeId;return(p?af(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=q(t=>Gl(t,e.select(`floatingElement`))||Gl(t,e.select(`domReferenceElement`))),N=q(t=>{o()&&e.setOpen(!1,G(au,t.nativeEvent))}),P=q(t=>{if(!l||!n||!r||t.key!==`Escape`)return;let i=zc(t)?t.nativeEvent:t;if(w.current||i.isComposing||!v&&j(`__escapeKeyBubbles`))return;let a=G(hu,i);e.setOpen(!1,a),a.isCanceled||t.preventDefault(),!v&&!a.isPropagationAllowed&&t.stopPropagation()}),F=q(()=>{d.current.insideReactTree=!0,O.start(0,A)}),I=q(t=>{if(!l||!n||t.button!==0)return;let r=_l(t.nativeEvent);W(e.select(`floatingElement`),r)&&(b.current||(b.current=!0,x.current=!1))}),L=q(e=>{l&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});H.useEffect(()=>{function e(e){e.open||(C.current=!1)}return f.on(`openchange`,e),()=>{f.off(`openchange`,e)}},[f]),H.useEffect(()=>A,[A]),H.useEffect(()=>{if(!l||!n)return l||(C.current=!1,w.current=!1,T.current=``,E.current=null),A;d.current.__escapeKeyBubbles=v,d.current.__outsidePressBubbles=y;let t=new xc,i=qu(u);function a(){k.clear(),w.current=!0}function o(){w.current=!0,k.start(Pc?5:0,()=>{w.current=!1})}function s(){S.current=!0,t.start(0,()=>{S.current=!1})}function c(){b.current=!1,x.current=!1}function f(){let e=T.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=f();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function O(e){let t=d.current.floatingContext?.nodeId,n=p&&af(p.nodesRef.current,t).some(t=>Gl(e,t.context?.elements.floating));return M(e)||n}function N(n){if(m(n)){n.type!==`click`&&!M(n)&&(t.clear(),S.current=!1),A();return}if(d.current.insideReactTree){A();return}let r=_l(n),i=`[${sf(`inert`)}]`,a=Yc(r)?r.getRootNode():null,o=Array.from((Zc(a)?a:qu(e.select(`floatingElement`))).querySelectorAll(i)),s=e.context.triggerElements;if(r&&(s.hasElement(r)||s.hasMatchingElement(e=>W(e,r))))return;let c=Yc(r)?r:null;for(;c&&!cl(c);){let e=dl(c);if(cl(e)||!Yc(e))break;c=e}if(!(o.length&&Yc(r)&&!Kl(r)&&!W(r,e.select(`floatingElement`))&&o.every(e=>!W(c,e)))){if(Xc(r)&&!(`touches`in n)){let e=cl(r),t=ll(r),i=/auto|scroll/,a=e||i.test(t.overflowX),o=e||i.test(t.overflowY),s=a&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,c=o&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,l=t.direction===`rtl`,u=c&&(l?n.offsetX<=r.offsetWidth-r.clientWidth:n.offsetX>r.clientWidth),d=s&&n.offsetY>r.clientHeight;if(u||d)return}if(!O(n)){if(f()===`intentional`){if(n.detail!==0&&!Bc(n)&&!C.current)return;if(S.current){t.clear(),S.current=!1;return}}typeof h==`function`&&!h(n)||j(`__outsidePressBubbles`)||(e.setOpen(!1,G(cu,n)),A())}}}function F(t){f()===`sloppy`&&t.pointerType!==`touch`&&e.select(`open`)&&n&&!M(t)&&N(t)}function I(t){if(f()!==`sloppy`||!e.select(`open`)||!n||M(t))return;let r=t.touches[0];r&&(E.current={startTime:Date.now(),startX:r.clientX,startY:r.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},D.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=_l(e);if(!n)return;let r=Ou(n,e.type,()=>{t(e),r()})}function R(e){T.current=`touch`,L(e,I)}function ee(e){D.clear(),e.type===`pointerdown`&&(e.button===0&&(C.current=!0),T.current=e.pointerType),(e.type!==`mousedown`||!E.current||E.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function te(e){if(e.type===`pointercancel`&&(C.current=!1),!b.current)return;let n=x.current;c(),f()===`intentional`&&(e.type===`pointercancel`?n&&s():O(e)||(n?s():(typeof h!=`function`||h(e))&&(t.clear(),S.current=!0,A())))}function ne(e){if(f()!==`sloppy`||!E.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(E.current.dismissOnTouchEnd=!0),i>10&&(N(e),D.clear(),E.current=null)}function re(e){L(e,ne)}function ie(e){f()===`sloppy`&&E.current&&!M(e)&&(E.current.dismissOnTouchEnd&&N(e),D.clear(),E.current=null)}function ae(e){L(e,ie)}let oe=ku(r&&ku(Ou(i,`keydown`,P),Ou(i,`compositionstart`,a),Ou(i,`compositionend`,o)),g&&ku(Ou(i,`click`,ee,!0),Ou(i,`pointerdown`,ee,!0),Ou(i,`pointerup`,te,!0),Ou(i,`pointercancel`,te,!0),Ou(i,`mousedown`,ee,!0),Ou(i,`mouseup`,te,!0),Ou(i,`touchstart`,R,{capture:!0,passive:!0}),Ou(i,`touchmove`,re,{capture:!0,passive:!0}),Ou(i,`touchend`,ae,{capture:!0,passive:!0})));return()=>{oe(),t.clear(),c(),S.current=!1}},[d,u,r,g,h,l,n,v,y,P,A,_,j,M,p,e,D,k]);let R=H.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),ee=H.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return H.useMemo(()=>n?{reference:R,floating:ee,trigger:R}:{},[n,R,ee])}function Vp(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=o;return t.useSyncedValue(`floatingId`,i),U(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};Yc(c)&&(e.domReferenceElement=c),r.state.positionReference===r.state.referenceElement&&(e.positionReference=c),r.update(e)},[s,i,c,l,r]),r.context.onOpenChange=u,r.context.nested=a,r}function Hp(e,t=!1,n=!1,r=!1){let[i,a]=H.useState(e&&t?`idle`:void 0),[o,s]=H.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),U(()=>{if(!e&&o&&i!==`ending`&&n){let e=Gu.request(()=>{a(`ending`)});return()=>{Gu.cancel(e)}}},[e,o,i,n]),U(()=>{if(!e||t||i===void 0)return;let n=Gu.request(()=>{a(void 0)});return()=>{Gu.cancel(n)}},[t,e,i]),U(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=Gu.request(()=>{a(`idle`)});return()=>{Gu.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}function Up(e,t){return e.getAnimations(t).filter(e=>{let t=e.effect?.getTiming();return t?.duration!==1/0&&t?.iterations!==1/0})}var Wp=null;function Gp(e){if(!Wp){let e=[];Wp=e,queueMicrotask(()=>{Wp=null,lp.flushSync(()=>{for(let t of e)t()})})}Wp.push(e)}function Kp(e,t=!1,n=!1){let r=Ku();return q((i,a=null)=>{r.cancel();let o=wp(e);if(o==null)return;let s=o,c=()=>{n?Gp(()=>{a?.aborted||i()}):lp.flushSync(i)};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(Up(s).map(e=>e.finished.then(fc))).then(()=>{a?.aborted||c()},()=>{a?.aborted||(Up(s).some(e=>e.pending||e.playState!==`finished`)?l():c())})}if(t){let e=wl;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}else r.request(l)})}function qp(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=q(a),s=Kp(r,n,i);H.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}function Jp(e){let{open:t,ref:n,preventUnmountOnClose:r,setPreventUnmountOnClose:i,onUnmount:a,animateInitialOpen:o}=e,s=q(i),{mounted:c,setMounted:l,transitionStatus:u}=Hp(t,!1,!1,o),d=!t&&r;U(()=>{t&&s(!1)},[t,s]);let f=H.useRef(c),p=H.useRef(!1),m=xf(),h=()=>{f.current=!1,l(!1),a()};U(()=>{f.current=c,p.current&&(p.current=!1,!t&&c&&h())});let g=q(()=>{f.current&&(t?(p.current=!0,m()):h())});return qp({enabled:c&&!t&&!d,open:t,ref:n,onComplete(){t||g()}}),{mounted:c,transitionStatus:u,preventUnmountingOnClose:d,forceUnmount:g}}var Yp={tabIndex:-1,[vl]:``};function Xp(e){return t=>t!==`touch`||e.current}function Zp(e,t=!1){let n=Tf(),r=yp()!=null,i=ic(()=>e(n,r)).current;return Vp({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Qp({handle:e,store:t}){return U(()=>e.attachStore(t),[e,t]),null}function $p(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function em(e,t){let n=H.useRef(null);return q(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),$p(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),$p(t))})}function tm(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s,openedWithoutTrigger:t?n==null:e.openedWithoutTrigger}}function nm(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function rm(e,t,n,r={}){let i=n.reason,a=i===ou,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=nm(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=tm(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?lp.flushSync(l):l()}function im(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=em(e,n),o=q(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e)}else if(a==null&&i&&!n.state.openedWithoutTrigger){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=q(e=>{a(e),e&&o(e)});return U(()=>(s(t.current),()=>s(null)),[s,t,n,e]),U(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function am(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=H.useRef(null),i=e.useState(`open`);U(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0),e.state.openedWithoutTrigger&&e.set(`openedWithoutTrigger`,!1);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&!e.state.openedWithoutTrigger&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=G(iu);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function om(e,t,n,r){let{mounted:i,transitionStatus:a,forceUnmount:o}=Jp({open:e,ref:t.context.popupRef,preventUnmountOnClose:t.useState(`preventUnmountingOnClose`),setPreventUnmountOnClose:e=>t.set(`preventUnmountingOnClose`,e),animateInitialOpen:r,onUnmount(){t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)}});return ic(()=>(t.set(`mounted`,i),null)),t.useSyncedValues({mounted:i,transitionStatus:a}),{forceUnmount:o,transitionStatus:a}}function sm(e,t){e.useSyncedValues(t),U(()=>()=>{e.update({activeTriggerProps:mc,inactiveTriggerProps:mc,popupProps:mc})},[e])}function cm(e,t){U(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),U(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var lm=class{idMap=new Map;add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}},um=me((e=>{var t=ce();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),dm=me(((e,t)=>{t.exports=um()})),fm=me((e=>{var t=ce(),n=dm();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),pm=me(((e,t)=>{t.exports=fm()})),mm=dm(),hm=pm(),gm=Df(19)?ym:bm;function _m(e,t,n,r,i){return gm(e,t,n,r,i)}function vm(e,t,n,r,i){let a=H.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,mm.useSyncExternalStore)(e.subscribe,a,a)}cc({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,mm.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function ym(e,t,n,r,i){let a=sc();if(!a)return vm(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],s.store===e&&s.selector===t&&Object.is(s.a1,n)&&Object.is(s.a2,r)&&Object.is(s.a3,i)||(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function bm(e,t,n,r,i){return(0,hm.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var xm=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return _m(this,e,t,n,r)}},Sm=class extends xm{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){H.useDebugValue(e);let n=this;U(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;U(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;U(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){H.useDebugValue(e);let n=this,r=t!==void 0;U(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return H.useDebugValue(e),_m(this,this.selectors[e],t,n,r)}useContextCallback(e,t){H.useDebugValue(e);let n=q(t??fc);this.context[e]=n}useStateSetter(e){let t=H.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},Cm={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},wm=class extends Sm{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:hp(),nested:n,triggerElements:i},Cm),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Uc(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Tm(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new wm({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,openedWithoutTrigger:!1,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:mc,inactiveTriggerProps:mc,popupProps:mc}}var Em=e=>e.triggerIdProp??e.activeTriggerId,Dm=e=>e.openProp??e.open,Om=e=>(e.popupElement?.id??e.floatingId)||void 0;function km(e,t){return t!==void 0&&Dm(e)&&Em(e)===t}function Am(e,t){return km(e,t)?!0:t!==void 0&&Dm(e)&&Em(e)==null&&!e.openedWithoutTrigger&&e.triggerCount===1}var jm={open:Dm,mounted:e=>e.mounted,transitionStatus:e=>Dm(e)&&!e.mounted?`starting`:e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Em,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Om,isTriggerActive:(e,t)=>t!==void 0&&Em(e)===t,isOpenedByTrigger:(e,t)=>km(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Em(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Am(e,t)?Om(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Mm(e){let t=H.useCallback(t=>e===void 0?fc:e.subscribeStore(t),[e]),n=H.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,mm.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Nm(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Tf(),a=yp()!=null,o=ic(()=>new wm({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new lm,floatingId:i,syncOnly:!1,nested:a})).current;return U(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=Yc(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}var Pm=Mc&&Pc;function Fm(e,t={}){let{enabled:n=!0,delay:r}=t,{events:i,dataRef:a}=e.context,o=H.useRef(!1),s=H.useRef(null),c=H.useRef(!0),l=Sc();H.useEffect(()=>{let t=e.select(`domReferenceElement`);if(!n)return;let r=Kc(t);function i(){let t=e.select(`domReferenceElement`);!e.select(`open`)&&Xc(t)&&t===hl(qu(t))&&(o.current=!0,s.current=t)}function a(){c.current=!0}function l(){c.current=!1}return ku(Ou(r,`blur`,i),Pm&&Ou(r,`keydown`,a,!0),Pm&&Ou(r,`pointerdown`,l,!0))},[e,n]),H.useEffect(()=>{if(!n)return;function t(t){if(t.reason===`trigger-press`||t.reason===`escape-key`){let t=e.select(`domReferenceElement`);Yc(t)&&(s.current=t,o.current=!0)}}return i.on(`openchange`,t),()=>{i.off(`openchange`,t)}},[i,n,e]);let u=H.useMemo(()=>{function t(){o.current=!1,s.current=null}return{onMouseLeave(){t()},onFocus(n){let i=n.currentTarget;if(o.current){if(s.current===i)return;t()}let a=_l(n.nativeEvent);if(Yc(a)){if(Pm&&!n.relatedTarget){if(!c.current&&!ql(a))return}else if(!Xl(a))return}let u=Wl(n.relatedTarget,e.context.triggerElements),{nativeEvent:d,currentTarget:f}=n;e.select(`open`)&&u||!r?e.setOpen(!0,G(su,d,f)):l.start(r,()=>{o.current||e.setOpen(!0,G(su,d,f))})},onBlur(n){t();let r=n.relatedTarget,i=n.nativeEvent,o=Yc(r)&&r.hasAttribute(sf(`focus-guard`))&&r.getAttribute(`data-type`)===`outside`;l.start(0,()=>{let t=e.select(`domReferenceElement`),n=hl(qu(t));!r&&n===t||W(a.current.floatingContext?.refs.floating.current,n)||W(t,n)||o||Wl(r??n,e.context.triggerElements)||e.setOpen(!1,G(su,i))})}}},[a,r,e,l]);return H.useMemo(()=>n?{reference:u,trigger:u}:{},[n,u])}var Im=class e{pointerType=void 0;interactedInside=!1;handler=void 0;blockMouseMove=!0;performedPointerEventsMutation=!1;pointerEventsScopeElement=null;pointerEventsReferenceElement=null;pointerEventsFloatingElement=null;restTimeoutPending=!1;openChangeTimeout=new xc;restTimeout=new xc;handleCloseOptions=void 0;static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},Lm=new WeakMap;function Rm(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Lm.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Lm.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function zm(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Lm.get(n);a&&a!==e&&Rm(a),Rm(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Lm.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function Bm(e){let t=e.context.dataRef.current,n=ic(()=>t.hoverInteractionState??Im.create()).current;return t.hoverInteractionState||=n,yc(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Vm(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=e.useState(`open`),o=e.useState(`floatingElement`),s=e.useState(`domReferenceElement`),{dataRef:c}=e.context,l=bp(),u=yp(),d=Bm(e),f=Sc(),p=q(()=>tu(c.current.openEvent?.type,d.interactedInside)),m=q(()=>nu(c.current.openEvent?.type)),h=q(()=>{Rm(d)});U(()=>{a||(d.pointerType=void 0,d.restTimeoutPending=!1,d.interactedInside=!1,h())},[a,d,h]),H.useEffect(()=>h,[h]),U(()=>{if(n&&a&&d.handleCloseOptions?.blockPointerEvents&&m()&&Yc(s)&&o){let e=s,t=o,n=qu(o),r=l?.nodesRef.current.find(e=>e.id===u)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=d.pointerEventsScopeElement===t?null:d.pointerEventsScopeElement,a=r===t?null:r,c=d.handleCloseOptions?.getScope?.()??i??a??gl(e,`[data-rootownerid]`)??n.body;return zm(d,{scopeElement:c,referenceElement:e,floatingElement:t}),()=>{h()}}},[n,a,s,o,d,m,l,u,h]),H.useEffect(()=>{if(!n)return;function t(){return!!(l&&u&&af(l.nodesRef.current,u).length>0)}function a(t){let n=$l(r,`close`,d.pointerType),i=()=>{e.setOpen(!1,G(ou,t)),l?.events.emit(`floating.closed`,t)};n?d.openChangeTimeout.start(n,i):(d.openChangeTimeout.clear(),i())}function s(e){let t=_l(e);Jl(t)?d.interactedInside=gl(t,`[aria-haspopup]`)!=null:d.interactedInside=!1}function g(){d.openChangeTimeout.clear(),f.clear(),l?.events.off(`floating.closed`,v),h()}function _(n){if(t()&&l){l.events.on(`floating.closed`,v);return}if(Wl(n.relatedTarget,e.context.triggerElements))return;let r=c.current.floatingContext?.nodeId??i,o=n.relatedTarget;l&&r&&Yc(o)&&af(l.nodesRef.current,r,!1).some(e=>W(e.context?.elements.floating,o))||(d.handler?d.handler(n):(h(),m()&&!p()&&a(n)))}function v(n){l&&u&&!t()&&f.start(0,()=>{l.events.off(`floating.closed`,v),e.setOpen(!1,G(ou,n)),l.events.emit(`floating.closed`,n)})}let y=o;return ku(y&&Ou(y,`mouseenter`,g),y&&Ou(y,`mouseleave`,_),y&&Ou(y,`pointerdown`,s,!0),()=>{l?.events.off(`floating.closed`,v)})},[n,o,e,c,r,i,m,p,h,d,l,u,f])}var Hm={current:null};function Um(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Hm,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=bp(l),v=Bm(e),y=H.useRef(!1),b=Iu(i),x=Iu(r),S=Iu(o),C=Iu(n),w=Iu(p),T=Iu(f),E=q(()=>tu(h.current.openEvent?.type,v.interactedInside)),D=q(()=>w.current?.()!==!1),O=q((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!W(t,n);if(!Yc(r))return!1;let a=r;return i.hasMatchingElement(e=>W(e,a))&&(!t||!W(t,a))}),k=q(()=>{v.handler&&=(qu(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),A=q(()=>{Rm(v)});return u&&(v.handleCloseOptions=i?.__options),H.useEffect(()=>k,[k]),H.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===ou,k(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,k]),H.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=$l(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,G(ou,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,G(ou,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!Yc(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!Hc(v.pointerType))return;let n=eu(S.current),r=$l(x.current,`open`,v.pointerType),i=_l(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(Yc(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(W(t,i)){c=t;break}}Yc(o)&&Yc(s)&&!e.context.triggerElements.hasElement(o)&&W(o,s)&&(c=s);let l=c!=null&&O(s,c,i),u=e.select(`open`),d=T.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&Yc(c)&&Yc(s)&&W(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;h?D()&&e.setOpen(!0,G(ou,t,c)):m||(r?v.openChangeTimeout.start(r,()=>{g&&D()&&e.setOpen(!0,G(ou,t,c))}):g&&D()&&e.setOpen(!0,G(ou,t,c)))}function o(n){if(E()){A();return}k();let r=qu(e.select(`domReferenceElement`));v.restTimeout.clear(),v.restTimeoutPending=!1;let i=h.current.floatingContext??d?.();if(!Wl(n.relatedTarget,e.context.triggerElements)){if(b.current&&i){e.select(`open`)||v.openChangeTimeout.clear();let a=c.current;v.handler=b.current({...i,tree:_,x:n.clientX,y:n.clientY,onClose(){A(),k(),C.current&&!E()&&a===e.select(`domReferenceElement`)&&t(n,!0)}}),r.addEventListener(`mousemove`,v.handler),v.handler(n)}else v.pointerType===`touch`&&W(e.select(`floatingElement`),n.relatedTarget)||t(n)}}function l(e){W(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?Ou(r,`mouseout`,l):void 0;return s?ku(Ou(r,`mousemove`,i,{once:!0}),Ou(r,`mouseenter`,i),Ou(r,`mouseleave`,o),f):ku(Ou(r,`mouseenter`,i),Ou(r,`mouseleave`,o),f)},[k,A,h,x,e,n,b,v,u,O,E,a,s,S,c,_,C,d,T,D,m]),H.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=O(i,r,t.target);if(a&&!Hc(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;zm(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=eu(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,E())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&D()&&e.setOpen(!0,G(ou,n,r))}v.pointerType===`touch`?lp.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,E,O,a,e,S,D])}function Wm(e){return Pc&&e.movementX===0&&e.movementY===0}function Gm(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function Km(e,t){return Gm(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function qm(e,t,n){return Gm(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Jm(e,t,n){return Gm(t,n?e===bl:e===xl,e===Cl)}function Ym(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===`Escape`:Gm(t,n?e===xl:e===bl,e===Sl)}function Xm(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,triggerOrientation:_=g,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,nestedReturnFocusRef:S,grid:C}=t,w=C!=null,T=e.useState(`open`),E=e.useState(`floatingElement`),D=e.useState(`domReferenceElement`),O=e.context.dataRef,k=Zl(E),A=Yl(D),j=Iu(k),M=yp(),N=bp(x),P=H.useRef(f),F=H.useRef(o??-1),I=H.useRef(null),L=H.useRef(!0),R=q(e=>{i(F.current===-1?null:F.current,e)}),ee=H.useRef(!!E),te=H.useRef(T),ne=H.useRef(!1),re=H.useRef(!1),ie=H.useRef(null),ae=Iu(h),oe=Iu(T),se=Iu(o),ce=Iu(b),le=Ku(),ue=Ku(),de=q(()=>{le.cancel();function e(e){d||(ie.current=lf(e,{sync:ne.current,preventScroll:!0}))}let t=n.current[F.current],r=re.current;t&&e(t),(ne.current?e=>e():e=>le.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),_e&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});U(()=>{O.current.orientation=g},[O,g]),U(()=>{T||(I.current=null),T&&f===`auto`||(P.current=f)},[T,f]),U(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(re.current=!0,R())):ee.current&&(F.current=-1,R()))},[a,T,E,o,R]),U(()=>{if(a){if(!T)ne.current=!1;else if(E){if(r==null){if(ne.current=!1,se.current!=null)return;if(ee.current&&(F.current=-1,de()),(!te.current||!ee.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ue.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||qm(I.current,_,u)||l?Dd(n):Od(n),I.current=null,R())};t()}}else Ed(n.current,r)||(F.current=r,de(),re.current=!1)}}},[a,T,E,r,se,l,n,_,u,R,de,ue]),U(()=>{if(!a||E||!N||d||!ee.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=hl(qu(D??t??null)),r=e.some(e=>e.context&&W(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,d]),U(()=>{te.current=T,ee.current=!!E});let fe=r!=null,pe=q(e=>{if(!oe.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),me=q(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),he=q(()=>Dd(n,ae.current)),ge=q(t=>{if(L.current=!1,ne.current=!0,t.which===229||!oe.current&&t.currentTarget===j.current)return;if(l&&Ym(t.key,g,u,w)){Km(t.key,me())||Rc(t),e.setOpen(!1,G(gu,t.nativeEvent));let n=S?.current??D;Xc(n)&&n.focus();return}r!=null&&r!==F.current&&!Ed(n.current,r)&&(F.current=r);let i=F.current,a=Dd(n,h),o=Od(n,h);if(A||(t.key===`Home`&&(Rc(t),F.current=a,R(t)),t.key===`End`&&(Rc(t),F.current=o,R(t))),C!=null){let e=C(t,F.current,n,g,c,u,h,a,o);if(e!=null&&e!==F.current&&(F.current=e,R(t)),g===`both`)return}if(Km(t.key,g)){Rc(t);let e=hl(t.currentTarget.ownerDocument);if(T&&!d&&W(t.currentTarget,e)&&!n.current.some(t=>t!=null&&W(t,e))){F.current=qm(t.key,g,u)?a:o,R(t),r===F.current&&de();return}let{index:l,wrapped:f}=kd(n.current,i,{decrement:!qm(t.key,g,u),loopFocus:c,allowEscape:s,disabledIndices:h,minIndex:a,maxIndex:o});f&&(ne.current=!1),F.current=l,R(t)}}),_e=H.useMemo(()=>({onFocus(e){ne.current=!0,pe(e)},onClick({currentTarget:e}){d||e.focus({preventScroll:!0})},onMouseMove(e){Wm(e)||(ne.current=!0,re.current=!1,p&&pe(e))},onPointerLeave(e){if(!oe.current||!L.current||e.pointerType===`touch`)return;ne.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ce.current&&(ie.current?.(),ie.current=null,F.current=-1,R(e),!d)){let e=j.current,t=hl(qu(e));e&&W(e,t)&&e.focus({preventScroll:!0})}}}),[pe,oe,j,p,n,R,ce,d]),ve=H.useMemo(()=>d&&T&&fe&&{"aria-activedescendant":`${y}-${r}`},[d,T,fe,y,r]),ye=H.useMemo(()=>({...A?{}:ve,onKeyDown(t){if(t.key===`Tab`&&t.shiftKey&&T&&!d){let n=_l(t.nativeEvent);if(n&&!W(j.current,n))return;Rc(t);let r=G(mu,t.nativeEvent);e.setOpen(!1,r);let i=S?.current??D;!r.isCanceled&&Xc(i)&&i.focus()}else ge(t)},onPointerMove(e){Wm(e)||(L.current=!0)}}),[ve,ge,j,A,e,T,d,D,S]),be=H.useMemo(()=>{function t(t){e.setOpen(!0,G(gu,t.nativeEvent,t.currentTarget))}function n(e){f===`auto`&&Bc(e.nativeEvent)&&(P.current=!d)}function r(e){P.current=f,f===`auto`&&Vc(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(n){let r=e.select(`open`);L.current=!1;let i=n.key.startsWith(`Arrow`),a=Jm(n.key,me(),u),o=Km(n.key,r?g:_),s=(l?a:o)||n.key===`Enter`||n.key.trim()===``;if(d&&r&&(!l||ql(n.currentTarget)))return ge(n);if(r||m||!i){if(s){let e=Km(n.key,me());I.current=l&&e?null:n.key}l?a&&(Rc(n),r?(F.current=he(),R(n),d&&j.current?.focus()):t(n)):o&&(se.current!=null&&(F.current=se.current),Rc(n),!r&&m?t(n):ge(n),r&&R(n))}},onFocus(t){t.target===t.currentTarget&&e.select(`open`)&&!d&&(F.current=-1,R(t))},onPointerDown:r,onPointerEnter:r,onMouseDown:n,onClick:n}},[ge,f,he,l,R,e,m,g,_,me,u,se,d,j]),xe=H.useMemo(()=>({...ve,...be}),[ve,be]);return H.useMemo(()=>a?{reference:xe,floating:ye,item:_e,trigger:be}:{},[a,xe,ye,be,_e])}function Zm(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=q(s),f=e.useState(`open`),p=Sc(),m=H.useRef(``),h=H.useRef(u??i??-1),g=H.useRef(null),_=q(e=>{function t(e){return r?.current[e]}function s(e){let n=t(e);return n&&!Pd(n)||n?.matches(`:disabled`)?!1:o==null||!Md(pc,e,o)}function c(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&s(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Rc(e),d?.(!0)),m.current.length>0&&m.current[0]!==` `&&c(_,m.current)===-1&&e.key!==` `&&d?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Rc(e),d?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&s(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,d?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=c(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,d?.(!1)):(a?.(b,e),g.current=b)}),v=q(t=>{let n=t.relatedTarget,r=e.select(`domReferenceElement`),i=e.select(`floatingElement`);W(r,n)||W(i,n)||(p.clear(),m.current=``,h.current=g.current,d?.(!1))});U(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``,d?.(!1)))},[f,u,p,d]);let y=H.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return H.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var Qm=.1,$m=Qm*Qm,eh=.5;function th(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function nh(e,t,n,r,i,a,o,s,c,l){let u=!1;return th(e,t,n,r,i,a)&&(u=!u),th(e,t,i,a,o,s)&&(u=!u),th(e,t,o,s,c,l)&&(u=!u),th(e,t,c,l,n,r)&&(u=!u),u}function rh(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function ih(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function ah(e={}){let{blockPointerEvents:t=!1}=e,n=new xc,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*$m;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=_l(r),g=r.type===`mouseleave`,_=W(u,h),v=W(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Yc(r.relatedTarget)&&W(u,r.relatedTarget))return;function y(){return!!(s&&af(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=ih(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=ih(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=ih(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=ih(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!rh(d,f,x)||!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?eh/2:eh*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+eh+1,o=C||T?S.bottom-eh:S.top,s=C?T?S.bottom-eh:S.top:S.bottom-eh;M=nh(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?eh/2:eh*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-eh,o=C||T?S.top+eh:S.bottom,s=C?T?S.top+eh:S.bottom:S.top+eh;M=nh(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?eh/2:eh*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+eh+1,o=w||E?S.right-eh:S.left,s=w?E?S.right-eh:S.left:S.right-eh;M=nh(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?eh/2:eh*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-eh,o=w||E?S.left+eh:S.right,s=w?E?S.left+eh:S.right:S.left+eh;M=nh(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function oh(e,t,n){let{reference:r,floating:i}=e,a=ud(t),o=dd(t),s=ld(o),c=od(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=sd(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function sh(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ad(t,e),p=Cd(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=wd(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=wd(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ch=50,lh=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:sh},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=oh(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ch&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=oh(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},uh=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ad(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=od(r),_=ud(o),v=od(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[xd(o)]:pd(o)),x=p!==`none`;!d&&x&&b.push(...bd(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=fd(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ud(t)||T.every(e=>ud(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ud(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},dh=new Set([`left`,`top`]);async function fh(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=od(n),s=sd(n),c=ud(n)===`y`,l=dh.has(o)?-1:1,u=a&&c?-1:1,d=ad(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ph=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fh(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},mh=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ad(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ud(i),p=cd(f),m=u[p],h=u[f],g=(e,t)=>id(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},hh=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ad(e,t),u={x:n,y:r},d=ud(i),f=cd(d),p=u[f],m=u[d],h=ad(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=dh.has(od(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},gh=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=ad(e,t),c=await i.detectOverflow(t,s),l=od(n),u=sd(n),d=ud(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Qu(p-c[m],g),y=Qu(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*$u(c.left,c.right):S=p-2*$u(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function _h(e){let t=ll(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Xc(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ed(n)!==a||ed(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function vh(e){return Yc(e)?e:e.contextElement}function yh(e){let t=vh(e);if(!Xc(t))return nd(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=_h(t),o=(a?ed(n.width):n.width)/r,s=(a?ed(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var bh=nd(0);function xh(e){let t=Kc(e);return!sl()||!t.visualViewport?bh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sh(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Kc(e)}function Ch(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=vh(e),o=nd(1);t&&(r?Yc(r)&&(o=yh(r)):o=yh(e));let s=Sh(a,n,r)?xh(a):nd(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Kc(a),t=Yc(r)?Kc(r):r,n=e,i=ml(n);for(;i&&t!==n;){let e=yh(i),t=i.getBoundingClientRect(),r=ll(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Kc(i),i=ml(n)}}return wd({width:u,height:d,x:c,y:l})}function wh(e,t){let n=ul(e).scrollLeft;return t?t.left+n:Ch(qc(e)).left+n}function Th(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-wh(e,n),y:n.top+t.scrollTop}}function Eh(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=qc(r),s=t?el(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=nd(1),u=nd(0),d=Xc(r);if((d||!a)&&((Gc(r)!==`body`||Qc(o))&&(c=ul(r)),d)){let e=Ch(r);l=yh(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Th(o,c):nd(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Dh(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Oh(e){let t=ul(e),n=e.ownerDocument.body,r=$u(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=$u(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+wh(e),o=-t.scrollTop;return ll(n).direction===`rtl`&&(a+=$u(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var kh=25;function Ah(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Kc(e),a=qc(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!sl()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(wh(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=kh&&(s-=o)}return{width:s,height:c,x:l,y:u}}function jh(e,t){let n=Ch(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=yh(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Mh(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ah(e,n,t);else if(t===`document`)r=Oh(qc(e));else if(Yc(t))r=jh(t,n);else{let n=xh(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return wd(r)}function Nh(e,t){let n=t.get(e);if(n)return n;let r=pl(e,[],!1).filter(e=>Yc(e)&&Gc(e)!==`body`),i=null,a=ll(e).position===`fixed`,o=a?dl(e):e;for(;Yc(o)&&!cl(o);){let e=ll(o),t=al(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=dl(o)}return t.set(e,r),r}function Ph(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?el(t)?[]:Nh(t,this._c):[].concat(n),r],o=Mh(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Mh(t,a[e],i);s=$u(n.top,s),c=Qu(n.right,c),l=Qu(n.bottom,l),u=$u(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Fh(e){let{width:t,height:n}=_h(e);return{width:t,height:n}}function Ih(e,t,n){let r=Xc(t),i=qc(t),a=n===`fixed`,o=Ch(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=nd(0);if((r||!a)&&((Gc(t)!==`body`||Qc(i))&&(s=ul(t)),r)){let e=Ch(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=wh(i));let l=i&&!r&&!a?Th(i,s):nd(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Lh(e){return ll(e).position===`static`}function Rh(e,t){if(!Xc(e)||ll(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return qc(e)===n&&(n=n.ownerDocument.body),n}function zh(e,t){let n=Kc(e);if(el(e))return n;if(!Xc(e)){let t=dl(e);for(;t&&!cl(t);){if(Yc(t)&&!Lh(t))return t;t=dl(t)}return n}let r=Rh(e,t);for(;r&&$c(r)&&Lh(r);)r=Rh(r,t);return r&&cl(r)&&Lh(r)&&!al(r)?n:r||ol(e)||n}var Bh=async function(e){let t=this.getOffsetParent||zh,n=this.getDimensions,r=await n(e.floating);return{reference:Ih(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vh(e){return ll(e).direction===`rtl`}var Hh={convertOffsetParentRelativeRectToViewportRelativeRect:Eh,getDocumentElement:qc,getClippingRect:Ph,getOffsetParent:zh,getElementRects:Bh,getClientRects:Dh,getDimensions:Fh,getScale:yh,isElement:Yc,isRTL:Vh};function Uh(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Wh(e,t,n){let r=null,i,a=qc(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=td(d),h=td(a.clientWidth-(u+f)),g=td(a.clientHeight-(d+p)),_=td(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:$u(0,Qu(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Uh(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Kc(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Gh(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=vh(e),u=i||a?[...l?pl(l):[],...t?pl(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Wh(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Ch(e):null;c&&g();function g(){let t=Ch(e);h&&!Uh(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Kh=ph,qh=mh,Jh=uh,Yh=gh,Xh=hh,Zh=(e,t,n)=>{let r=new Map,i=n??{},a={...Hh,...i.platform,_c:r};return lh(e,t,{...i,platform:a})},Qh=typeof document<`u`?H.useLayoutEffect:function(){};function $h(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$h(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!$h(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function eg(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function tg(e,t){let n=eg(e);return Math.round(t*n)/n}function ng(e){let t=H.useRef(e);return Qh(()=>{t.current=e}),t}function rg(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=H.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=H.useState(r);$h(f,r)||p(r);let[m,h]=H.useState(null),[g,_]=H.useState(null),v=H.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=H.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=H.useRef(null),C=H.useRef(null),w=H.useRef(u),T=c!=null,E=ng(c),D=ng(i),O=ng(l),k=H.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Zh(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!$h(w.current,t)&&(w.current=t,lp.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Qh(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=H.useRef(!1);Qh(()=>(A.current=!0,()=>{A.current=!1}),[]),Qh(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=H.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=H.useMemo(()=>({reference:b,floating:x}),[b,x]),N=H.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=tg(M.floating,u.x),r=tg(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...eg(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var ig=(e,t)=>{let n=Kh(e);return{name:n.name,fn:n.fn,options:[e,t]}},ag=(e,t)=>{let n=qh(e);return{name:n.name,fn:n.fn,options:[e,t]}},og=(e,t)=>({fn:Xh(e).fn,options:[e,t]}),sg=(e,t)=>{let n=Jh(e);return{name:n.name,fn:n.fn,options:[e,t]}},cg=(e,t)=>{let n=Yh(e);return{name:n.name,fn:n.fn,options:[e,t]}},lg={...jm,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,appliedTriggerProps:(e,t)=>t?e.activeTriggerProps:void 0,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},ug=class extends Sm{constructor(e,t,n){let r=new lm;super(dg(e,r,t,n),fg(r),lg)}setOpen=(e,t)=>{rm(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,G(au,e))}};function dg(e,t,n,r=!1){return{...Tm(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function fg(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var pg=lc(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=Zp((e,t)=>new ug({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),am(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=om(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=H.useRef(null);U(()=>{m&&t&&p.setOpen(!1,G(xu))},[m,t,p]),U(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),U(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),H.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,G(Su))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,K.jsxs)(_c.Provider,{value:p,children:[l&&(0,K.jsx)(Qp,{handle:l,store:p}),T&&(0,K.jsx)(mg,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function mg({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Bp(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Lp(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=H.useMemo(()=>Pf(a.reference,i.reference),[a.reference,i.reference]);return sm(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??mc}),null}function hg(e){return Tf(e,`base-ui`)}var gg=H.createContext(void 0);function _g(){return H.useContext(gg)}var vg=`data-base-ui-tooltip-trigger`;function yg(e){let t=_l(e);return Yc(t)?t:null}var bg=uc(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=vc(!0),m=Mm(a)??p;if(!m)throw Error(gc(82));let h=hg(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=H.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=im(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=_g(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=Du(v,{open:_}),O=Bm(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Iu(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=H.useRef(!1),F=Sc(),I=H.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=gl(e,`[${vg}]`);return n!==null&&n!==t&&W(t,n)}function ee(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let te=Um(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?ah():null,restMs:L,delay(){return u==null&&D?{close:$l(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),ne=Fm(v,{enabled:!A}).reference,re=e=>{let t=P.current,n=yg(e),r=ee(n),i=y.current,a=i&&n&&W(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`)m.setOpen(!1,G(ou,e));else if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&Hc(I.current)){let t=()=>{P.current||j.current||m.select(`open`)||m.setOpen(!0,G(ou,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},ie=m.useState(`appliedTriggerProps`,S||M!==`none`);return qf(`button`,e,{state:{open:_},ref:[t,x,y],props:[te,ne,ie,{onMouseOver(e){re(e.nativeEvent)},onFocus(e){R(yg(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[Ul]:A?``:void 0,[vg]:A?void 0:``},f],stateAttributesMapping:zl})}),xg=H.createContext(void 0);function Sg(){let e=H.useContext(xg);if(e===void 0)throw Error(gc(70));return e}var Cg=H.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=pp({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,K.jsxs)(H.Fragment,{children:[l,c&&lp.createPortal(n,c)]})}),wg=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return vc().useState(`mounted`)||n?(0,K.jsx)(xg.Provider,{value:n,children:(0,K.jsx)(Cg,{ref:t,...r})}):null}),Tg=H.createContext(void 0);function Eg(){let e=H.useContext(Tg);if(e===void 0)throw Error(gc(71));return e}function Dg(e){let{nodeId:t,externalTree:n,rootContext:r}=e,i=r.useState(`referenceElement`),a=r.useState(`floatingElement`),o=r.useState(`domReferenceElement`),s=r.useState(`open`),c=r.useState(`floatingId`),[l,u]=H.useState(null),d=H.useRef(null),f=bp(n),p=H.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),m=rg({...e,elements:{...p,...l&&{reference:l}}}),h=H.useCallback(e=>{let t=Yc(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),m.refs.setReference(t)},[m.refs]),g=H.useMemo(()=>({...m.refs,setPositionReference:h,domReference:d}),[m.refs,h]),_=H.useMemo(()=>({...m.elements,domReference:o}),[m.elements,o]),v=H.useMemo(()=>({...m,dataRef:r.context.dataRef,open:s,onOpenChange:r.setOpen,events:r.context.events,floatingId:c,refs:g,elements:_,nodeId:t,rootStore:r}),[m,g,_,t,r,s,c]);return U(()=>{o&&(d.current=o)},[o]),U(()=>{r.context.dataRef.current.floatingContext=v;let e=f?.nodesRef.current.find(e=>e.id===t);e&&(e.context=v)}),H.useMemo(()=>({...m,context:v,refs:g,elements:_,rootStore:r}),[m,g,_,v,r])}var Og=H.createContext(void 0);function kg(){return H.useContext(Og)?.direction??`ltr`}var Ag=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ad(e,t)||{};if(l==null)return{};let d=Cd(u),f={x:n,y:r},p=dd(i),m=ld(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=s.floating[y]||a.floating[m],C=b/2-x/2,w=S/2-h[m]/2-1,T=Math.min(d[_],w),E=Math.min(d[v],w),D=T,O=S-h[m]-E,k=S/2-h[m]/2+C,A=id(D,k,O),j=!c.arrow&&sd(i)!=null&&k!==A&&a.reference[m]/2-(k<D?T:E)-h[m]/2<0,M=j?k<D?k-D:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),jg=(e,t)=>{let{name:n,fn:r}=Ag(e);return{name:n,fn:r,options:[e,t]}},Mg={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Ng={sideX:`left`,sideY:`top`},Pg=`--available-width`,Fg=`--available-height`,Ig=`--anchor-width`,Lg=`--anchor-height`,Rg=`--transform-origin`,zg=Pg,Bg=Fg;function Vg(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function Hg(e,t,n){let{rects:r,placement:i}=e;return{side:Vg(t,od(i),n),align:sd(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Ug(e){return Wg(e,Dg)}function Wg(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,C=_.side||`flip`,w=_.align||`flip`,T=_.fallbackAxisSide||`end`,E=v?.crossAxis??!1,D=v?.rootBoundary,O=typeof n==`function`?n:void 0,k=q(O),A=O?k:n,j=Iu(n),M=Iu(g),N=kg()===`rtl`,[P,F]=H.useState(null);!g&&P!==null&&F(null);let I=x===`placement`,L=P?od(P):null,R=P&&I?sd(P)||`center`:null,ee=L||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":N?`left`:`right`,"inline-start":N?`right`:`left`}[i],te=R||o,ne=te===`center`?ee:`${ee}-${te}`,re=l;typeof re==`number`?re={top:re,right:re,bottom:re,left:re}:re&&={top:re.top||0,right:re.right||0,bottom:re.bottom||0,left:re.left||0};let ie=+(i===`bottom`),ae=+(i===`top`),oe=+(i===`right`),se=+(i===`left`),ce={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:re},le=H.useRef(null),ue=Iu(a),de=Iu(s),fe=typeof a==`function`?0:a,pe=typeof s==`function`?0:s,me=[];p&&me.push(p),me.push(ig(e=>{let t=Hg(e,i,N),n=typeof ue.current==`function`?ue.current(t):ue.current,r=typeof de.current==`function`?de.current(t):de.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[fe,pe,N,i]));let he=w===`none`&&C!==`shift`,ge=!he&&(u||E||C===`shift`),_e=C===`none`?null:sg({...ce,padding:{top:re.top+1+ie,right:re.right+1+se,bottom:re.bottom+1+ae,left:re.left+1+oe},mainAxis:!E&&C===`flip`,crossAxis:w===`flip`&&`alignment`,fallbackAxisSideDirection:T}),ve=he?null:ag({...ce,rootBoundary:D,mainAxis:w!==`none`,crossAxis:ge,limiter:u||E?void 0:og(e=>{if(!le.current)return{};let{width:t,height:n}=le.current.getBoundingClientRect(),r=ud(od(e.placement)),i=r===`y`?t:n,a=r===`y`?re.left+re.right:re.top+re.bottom;return{offset:i/2+a/2}})},[ce,u,E,D,re,w]);C===`shift`||w===`shift`||te===`center`?me.push(ve,_e):me.push(_e,ve),me.push(cg({...ce,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!M.current)return;let i=e.style;i.setProperty(zg,`${t}px`),i.setProperty(Bg,`${n}px`);let a=Kc(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Ig,`${u}px`),i.setProperty(Lg,`${d}px`)}}),jg(e=>({element:le.current||qu(e.elements.floating).createElement(`div`),padding:le.current?d:0}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=od(r),u=sd(r),d=ud(l)===`y`,f=le.current,p=typeof a==`function`?a(Hg(e,i,N)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return ge&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Rg,d?`${m} ${h}`:`${h} ${m}`),{}}},Mg,b),U(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let ye=H.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:be,elements:xe,x:z,y:Se,middlewareData:Ce,update:we,placement:Te,context:Ee,isPositioned:De,floatingStyles:Oe}=t({rootContext:h,open:m?g:void 0,placement:ne,middleware:me,strategy:r,whileElementsMounted:m?void 0:(...e)=>Gh(...e,ye),nodeId:y,externalTree:S}),{sideX:ke,sideY:Ae}=Ce.adaptiveOrigin||Ng,je=De?r:`fixed`,Me=H.useMemo(()=>{let e;return e=De?b?{position:je,[ke]:z,[Ae]:Se}:{...Oe,position:je}:{position:je,top:0,left:0},e[zg]=`100vw`,e[Bg]=`100vh`,De||(e.opacity=0),e},[b,je,ke,z,Ae,Se,Oe,De]),Ne=H.useRef(null);U(()=>{if(!g)return;let e=j.current,t=typeof e==`function`?e():e,n=(Gg(t)?t.current:t)||null;n!==Ne.current&&(be.setPositionReference(n),Ne.current=n)},[g,be,A,j]),H.useEffect(()=>{if(!g)return;let e=j.current;typeof e!=`function`&&Gg(e)&&e.current!==Ne.current&&(be.setPositionReference(e.current),Ne.current=e.current)},[g,be,A,j]),H.useEffect(()=>{if(m&&g&&xe.reference&&xe.floating)return Gh(xe.reference,xe.floating,we,ye)},[m,g,xe,we,ye]);let Pe=od(Te),Fe=Vg(i,Pe,N),Ie=sd(Te)||`center`,Le=!!Ce.hide?.referenceHidden;U(()=>{x&&g&&De&&(Pe!==ee||I&&Ie!==te)&&F(Te)},[x,I,g,De,Te,Pe,Ie,ee,te]);let Re=H.useMemo(()=>({position:`absolute`,top:Ce.arrow?.y,left:Ce.arrow?.x}),[Ce.arrow]),ze=Ce.arrow?.centerOffset!==0;return H.useMemo(()=>({positionerStyles:Me,arrowStyles:Re,arrowRef:le,arrowUncentered:ze,side:Fe,align:Ie,physicalSide:Pe,anchorHidden:Le,refs:be,context:Ee,isPositioned:De,update:we}),[Me,Re,le,ze,Fe,Ie,Pe,Le,be,Ee,De,we])}function Gg(e){return e!=null&&`current`in e}function Kg(e){return e===`starting`?ep:mc}function qg(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),qf(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},Kg(r),i],stateAttributesMapping:Vl})}var Jg=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=sp,style:g,..._}=e,v=vc(),y=Sg(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=Ug({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=qg(e,H.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,K.jsx)(Tg.Provider,{value:D,children:O})}),Yg=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=vc(),{side:s,align:c}=Eg(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);qp({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Vm(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return qf(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Yp,f,Kg(d),a],stateAttributesMapping:Hl})}),Xg=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=H.useMemo(()=>({open:t,close:n}),[t,n]);return(0,K.jsx)(gg.Provider,{value:t,children:(0,K.jsx)(Eu,{delay:i,timeoutMs:r,children:e.children})})};function Zg(e){return Df(19)?e:e?`true`:void 0}function Qg(e){let[t,n]=H.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}var $g=/(?<!`)(`+)(?!`)(.+?)(?<!`)\1(?!`)/gu,e_=e=>e.startsWith(` `)&&e.endsWith(` `)?e.slice(1,-1):e,t_=e=>{let t=[],n=``,r=0;for(let i of e.matchAll($g)){let a=i[2]??``;a.trim()!==``&&(n+=e.slice(r,i.index),n!==``&&t.push({code:!1,text:n}),n=``,t.push({code:!0,text:e_(a)}),r=i.index+i[0].length)}return n+=e.slice(r),n===``?t:[...t,{code:!1,text:n}]},n_=e=>t_(e).map(e=>e.text).join(``),J=({text:e})=>t_(e).map(({code:e,text:t},n)=>e?(0,K.jsx)(`code`,{children:t},n):t),r_={keys:`_keys_pj1z3_6`,key:`_key_pj1z3_6`,empty:`_empty_pj1z3_37`,emptyTitle:`_emptyTitle_pj1z3_47`,emptyBody:`_emptyBody_pj1z3_57`,emptyCommand:`_emptyCommand_pj1z3_63`},i_=({keys:e})=>(0,K.jsx)(`span`,{className:r_.keys,children:e.map(e=>(0,K.jsx)(`kbd`,{className:r_.key,children:e},e))}),a_={positioner:`_positioner_c9seh_6`,popup:`_popup_c9seh_12`,panel:`_panel_c9seh_45 _popup_c9seh_12`,title:`_title_c9seh_52`,description:`_description_c9seh_62`,item:`_item_c9seh_69`,itemDetail:`_itemDetail_c9seh_112`,separator:`_separator_c9seh_125`,tip:`_tip_c9seh_136`,tipPositioner:`_tipPositioner_c9seh_142`,tipCommand:`_tipCommand_c9seh_181`,suggestions:`_suggestions_c9seh_221`},o_=300,s_=({children:e})=>(0,K.jsx)(Xg,{delay:o_,children:e}),c_=(e,t)=>{let n=[t,e===void 0?void 0:`CLI: ${e}`].filter(e=>e!==void 0);return n.length===0?{}:{"aria-description":n.join(`. `)}},l_=({children:e,label:t,cli:n,keys:r,disabled:i})=>(0,K.jsxs)(pg,{disabled:i===!0,children:[(0,K.jsx)(bg,{render:e}),(0,K.jsx)(wg,{children:(0,K.jsx)(Jg,{className:a_.tipPositioner,sideOffset:6,children:(0,K.jsxs)(Yg,{className:a_.tip,children:[t===void 0?null:(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:t})}),n===void 0?null:(0,K.jsx)(`code`,{className:a_.tipCommand,children:n}),r===void 0?null:(0,K.jsx)(i_,{keys:r})]})})})]}),u_=H.createContext(void 0);function d_(){let e=H.useContext(u_);if(!e)throw Error(gc(73));return e}var f_=0;function p_(e){return f_+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${f_}`}function m_(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}function h_(e){let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}function g_(e,t){let n=0;return e.map(e=>{if(e.transitionStatus===`ending`)return e;let r=n>=t;return n+=1,e.limited===r?e:{...e,limited:r}})}var __={toasts:e=>e.toasts,isEmpty:e=>e.toasts.length===0,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement},v_=class extends Sm{timers=new Map;areTimersPaused=!1;constructor(e){super({...e,toastMetadata:h_(e.toasts)},{},__)}setViewport=e=>{this.set(`viewport`,e)};syncProviderProps(e,t){let n=this.state.limit!==t;if(this.state.timeout===e&&!n)return;let r={timeout:e,limit:t};if(n){let e=g_(this.state.toasts,t);r.toasts=e,r.toastMetadata=h_(e)}this.update(r)}disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e,t=!1){let n=__.toastIndex(this.state,e);if(n===-1)return;let r=this.state.toasts[n];t||r?.onRemove?.();let i=[...this.state.toasts];i.splice(n,1),this.setToasts(i)}addToast=e=>{let{timeout:t,limit:n}=this.state,r=e.id||p_(`toast`);if(e.id){let t=__.toast(this.state,e.id);if(t){if(t.transitionStatus===`ending`)this.removeToast(e.id,!0);else{let{id:t,transitionStatus:n,...r}=e;return this.updateToastInternal(e.id,r,!0,!0),e.id}}}let i={...e,id:r,updateKey:0,transitionStatus:`starting`},a=[i,...this.state.toasts];this.setToasts(g_(a,n));let o=i.timeout??t;return i.type!==`loading`&&o>0&&this.scheduleTimer(r,o,()=>this.closeToast(r)),__.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),r};updateToast=(e,t)=>{let n=__.toast(this.state,e);n&&n.transitionStatus!==`ending`&&this.updateToastInternal(e,typeof t==`function`?t(n):t,!1,!0)};updateToastInternal=(e,t,n=!1,r=!1)=>{let{timeout:i,toasts:a}=this.state,o=__.toast(this.state,e);if(!o||o.transitionStatus===`ending`)return;let s={...o,...t,...r&&{updateKey:o.updateKey+1}};this.setToasts(a.map(t=>t.id===e?s:t));let c=s.timeout??i,l=o.timeout??i,u=Object.hasOwn(t,`timeout`),d=s.transitionStatus!==`ending`&&s.type!==`loading`&&c>0,f=this.timers.has(e),p=l!==c,m=o.type===`loading`;!d&&f?this.clearTimer(e):d&&(!f||p||u||m||n)&&(this.clearTimer(e),this.scheduleTimer(e,c,()=>this.closeToast(e)),__.expandedOrOutOfFocus(this.state)&&this.pauseTimers())};closeToast=e=>{let t=e===void 0,{limit:n,toasts:r}=this.state,i;if(t)i=r,this.clearTimers();else{let t=__.toast(this.state,e);if(!t)return;i=[t],this.clearTimer(e)}let a=g_(r.map(n=>t||n.id===e?{...n,transitionStatus:`ending`,height:0}:n),n);this.setToasts(a,!a.some(e=>e.transitionStatus!==`ending`)),i.forEach(e=>{e.transitionStatus!==`ending`&&e.onClose?.()}),this.handleFocusManagement(e)};promiseToast=(e,t)=>{let n=m_(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=m_(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=m_(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{e.timeout&&(e.timeout.clear(),e.remaining=Math.max(e.remaining-(Date.now()-e.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=xc.create(),e.timeout.start(e.remaining,()=>{this.handleTimerFired(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=_l(e);W(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=__.expandedOrOutOfFocus(this.state)?void 0:xc.create();i?.start(t,()=>{this.handleTimerFired(e),n()}),this.timers.set(e,{timeout:i,start:r,delay:t,remaining:t,callback:n})}clearTimers(){this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(e){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(e){this.timers.delete(e),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){this.timers.size===0&&(this.areTimersPaused=!1)}setToasts(e,t=e.length===0){let n={toasts:e,toastMetadata:h_(e)};t&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(e){let t=hl(qu(this.state.viewport));if(!this.state.viewport||!W(this.state.viewport,t)||!Xl(t))return;if(e===void 0){this.restoreFocusToPrevElement();return}let n=__.toasts(this.state),r=__.toastIndex(this.state,e),i=(e,t)=>{for(let r=e;r>=0&&r<n.length;r+=t)if(n[r].transitionStatus!==`ending`)return n[r];return null},a=i(r+1,1)??i(r-1,-1);a?a.ref?.current?.focus():this.restoreFocusToPrevElement()}},y_=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=ic(()=>new v_({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return yc(a.disposeEffect),H.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t.updates):e===`close`?a.closeToast(n):a.addToast(t)})},[a,i]),(0,K.jsxs)(u_.Provider,{value:a,children:[(0,K.jsx)(b_,{store:a,timeout:n,limit:r}),t]})};function b_(e){let{store:t,timeout:n,limit:r}=e;return U(()=>{t.syncProviderProps(n,r)},[t,n,r]),null}var x_=`--toast-frontmost-height`,S_=H.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=d_(),c=Sc(),l=H.useRef(!1),u=H.useRef(!1),d=H.useRef(!1),f=s.useState(`isEmpty`),p=s.useState(`toasts`),m=s.useState(`focused`),h=s.useState(`expanded`),g=s.useState(`prevFocusElement`),_=p[0]?.height,v=p.some(e=>e.transitionStatus===`ending`),y=p.filter(e=>e.priority===`high`);H.useEffect(()=>{let e=s.state.viewport;if(!e||f)return;let t=Kc(e),n=qu(e);function r(t){t.key===`F6`&&_l(t)!==e&&(t.preventDefault(),s.set(`prevFocusElement`,hl(n)),e?.focus({preventScroll:!0}),s.pauseTimers(),s.set(`focused`,!0))}function i(e){_l(e)===t&&(s.set(`isWindowFocused`,!1),s.pauseTimers())}function a(n){if(n.relatedTarget)return;let r=_l(n),i=hl(qu(e));r!==t&&W(e,r)&&Xl(i)||s.resumeTimers(),c.start(0,()=>s.set(`isWindowFocused`,!0))}return ku(Ou(t,`keydown`,r),Ou(t,`blur`,i,!0),Ou(t,`focus`,a,!0),Ou(n,`pointerdown`,s.handleDocumentPointerDown,!0))},[s,c,f]);function b(e){l.current=!0;let t=e.relatedTarget===s.state.viewport?p.find(e=>e.transitionStatus!==`ending`&&!e.limited):void 0;t?t.ref?.current?.focus():s.restoreFocusToPrevElement()}function x(e){e.key===`Tab`&&e.shiftKey&&_l(e.nativeEvent)===s.state.viewport&&(e.preventDefault(),s.restoreFocusToPrevElement())}function S(){s.state.toasts.some(e=>e.transitionStatus===`ending`)||d.current||!u.current||(s.set(`hovering`,!1),s.select(`expandedOrOutOfFocus`)||s.resumeTimers(),u.current=!1)}H.useEffect(S,[v,s]);function C(){s.pauseTimers(),s.set(`hovering`,!0),u.current=!1}function w(){u.current=!0,S()}function T(e){e.pointerType===`touch`&&(d.current=!0)}function E(e){e.pointerType===`touch`&&(d.current=!1,S())}function D(){l.current?l.current=!1:m||Xl(hl(qu(s.state.viewport)))&&(s.set(`focused`,!0),s.pauseTimers())}function O(e){m&&!W(s.state.viewport,e.relatedTarget)&&(s.set(`focused`,!1),s.select(`expandedOrOutOfFocus`)||s.resumeTimers())}let k={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:C,onMouseMove:C,onMouseLeave:w,onFocus:D,onBlur:O,onKeyDown:x,onClick:D,onPointerDown:T,onPointerUp:E,onPointerCancel:E,style:{[x_]:_?`${_}px`:void 0}},A={expanded:h},j=!f&&g&&(0,K.jsx)(Zu,{onFocus:b}),M=qf(`div`,e,{ref:[t,s.setViewport],state:A,props:[k,o,{children:(0,K.jsxs)(H.Fragment,{children:[j,a,j]})}]});return(0,K.jsxs)(H.Fragment,{children:[j,M,!m&&y.length>0&&(0,K.jsx)(`div`,{style:Yu,children:y.map(e=>(0,K.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,K.jsx)(`div`,{children:e.title}),(0,K.jsx)(`div`,{children:e.description})]},e.id))})]})}),C_=H.createContext(void 0);function w_(){let e=H.useContext(C_);if(!e)throw Error(gc(66));return e}function T_(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function E_(e,t=!1){let{overflowY:n}=ll(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function D_(e,t){let n=(t??Kc(e).getComputedStyle(e)).transform,r=0,i=0,a=1;if(n&&n!==`none`){let e=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(r=t[4],i=t[5],a=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(r=t[12],i=t[13],a=t[0])}}return{x:r,y:i,scale:a}}function O_(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}var k_=`--toast-index`,A_=`--toast-offset-y`,j_=`--toast-height`,M_=`--toast-swipe-movement-x`,N_=`--toast-swipe-movement-y`,P_=`data-swipe-direction`,F_={...Ol,swipeDirection(e){return e?{[P_]:e}:null}},I_=40,L_=10,R_=.5,z_=1,B_=`${ip},${ap}`,V_=H.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],style:o,...s}=e,c=n.positionerProps?.anchor!==void 0,l=[];c||(l=Array.isArray(a)?a:[a]);let u=l.length>0,d=d_(),[f,p]=H.useState(void 0),[m,h]=H.useState(!1),[g,_]=H.useState(!1),[v,y]=H.useState({x:0,y:0}),[b,x]=H.useState({x:0,y:0,scale:1}),[S,C]=H.useState(),[w,T]=H.useState(),[E,D]=H.useState(null),O=H.useRef(null),k=H.useRef(void 0),A=H.useRef({x:0,y:0}),j=H.useRef({x:0,y:0,scale:1}),M=H.useRef(void 0),N=H.useRef(0),P=H.useRef(!1),F=H.useRef({x:0,y:0}),I=H.useRef(!1),L=H.useRef({x:0,y:0}),R=H.useRef(null),ee=H.useRef(null),te=d.useState(`toastIndex`,n.id),ne=d.useState(`toastVisibleIndex`,n.id),re=d.useState(`toastOffsetY`,n.id),ie=d.useState(`focused`),ae=d.useState(`expanded`);qp({open:n.transitionStatus!==`ending`,ref:O,onComplete(){n.transitionStatus===`ending`&&d.removeToast(n.id)}});let oe=q((e=!1)=>{let t=O.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){d.updateToastInternal(n.id,{ref:O,height:i,transitionStatus:void 0})}e?lp.flushSync(a):a()});U(()=>{let e=k.current;(n.transitionStatus===`starting`||e!==n.id)&&(e!==void 0&&(p(void 0),x({x:0,y:0,scale:1}),se({x:0,y:0})),k.current=n.id,oe())},[oe,n.id,n.transitionStatus]);function se(e){L.current=e,y(e)}U(()=>()=>{ee.current?.abort()},[]);function ce(e,t){let n=e=>e>0?e**R_:-(Math.abs(e)**R_),r=e>0&&!l.includes(`right`)||e<0&&!l.includes(`left`),i=t>0&&!l.includes(`down`)||t<0&&!l.includes(`up`);return{x:r?n(e):e,y:i?n(t):t}}let le=q(e=>{if(e.pointerId!==R.current)return;R.current=null,ee.current?.abort(),ee.current=null,h(!1),_(!1),D(null);let t=j.current;if(e.type===`pointercancel`||P.current){se({x:t.x,y:t.y}),p(void 0);return}let r=L.current,i=r.x-t.x,a=r.y-t.y,o;for(let e of l)if(O_(e,i,a)>I_){o=e;break}o?(p(o),d.closeToast(n.id)):(se({x:t.x,y:t.y}),p(void 0))});function ue(e){if(e.button!==0||(e.pointerType===`touch`&&d.pauseTimers(),gl(_l(e.nativeEvent),`button,a,input,textarea,[role="button"],${B_}`)))return;P.current=!1,M.current=void 0,N.current=0,R.current=e.pointerId,A.current={x:e.clientX,y:e.clientY},F.current=A.current;let t=e.currentTarget,n=D_(t);j.current=n,x(n),se({x:n.x,y:n.y}),d.set(`hovering`,!0),h(!0),_(!1),D(null),I.current=!0,ee.current?.abort();let r=new AbortController;ee.current=r;let i=qu(t);i.addEventListener(`pointerup`,le,{signal:r.signal}),i.addEventListener(`pointercancel`,le,{signal:r.signal}),t.setPointerCapture?.(e.pointerId)}function de(e){if(e.pointerId!==R.current)return;e.preventDefault(),I.current&&=(A.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>F.current.y||i>0&&t<F.current.y)&&(F.current={x:F.current.x,y:t}),(r<0&&n>F.current.x||r>0&&n<F.current.x)&&(F.current={x:n,y:F.current.y});let a=n-A.current.x,o=t-A.current.y,s=t-F.current.y,c=n-F.current.x,u=E;if(!g&&Math.sqrt(a*a+o*o)>=z_){_(!0);let e=l.includes(`left`)||l.includes(`right`),t=l.includes(`up`)||l.includes(`down`);e&&t&&(u=Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`,D(u))}let d;if(!M.current)u===`vertical`?o>0?d=`down`:o<0&&(d=`up`):u===`horizontal`?a>0?d=`right`:a<0&&(d=`left`):d=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,d&&l.includes(d)&&(M.current=d,N.current=O_(d,a,o),p(d));else{let e=M.current,t=O_(e,c,s);t>I_?(P.current=!1,p(e)):!(l.includes(`left`)&&l.includes(`right`))&&!(l.includes(`up`)&&l.includes(`down`))&&N.current-t>=L_&&(P.current=!0)}let f=ce(a,o),m=j.current.x,h=j.current.y,v=l.includes(`left`)||l.includes(`right`),y=l.includes(`up`)||l.includes(`down`);u!==`vertical`&&v&&(m+=f.x),u!==`horizontal`&&y&&(h+=f.y),se({x:m,y:h})}function fe(e){if(e.key===`Escape`){if(!O.current||!W(O.current,hl(qu(O.current))))return;d.closeToast(n.id)}}H.useEffect(()=>{let e=O.current;if(!u||!e)return;function t(t){R.current!==null&&W(e,_l(t))&&t.preventDefault()}return Ou(e,`touchmove`,t,{passive:!1})},[u]);function pe(){let e=v.x-b.x,t=v.y-b.y;return{transition:m?`none`:void 0,transform:m?`translateX(${v.x}px) translateY(${v.y}px) scale(${b.scale})`:void 0,[M_]:`${e}px`,[N_]:`${t}px`}}let me=n.priority===`high`,he={role:me?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":S,"aria-describedby":w,"aria-hidden":me&&!ie?!0:void 0,onPointerDown:u?ue:void 0,onPointerMove:u?de:void 0,onPointerUp:u?le:void 0,onPointerCancel:u?le:void 0,onKeyDown:fe,inert:Zg(n.limited),style:{...pe(),[k_]:n.transitionStatus===`ending`?te:ne,[A_]:`${re}px`,[j_]:n.height?`${n.height}px`:void 0}},ge=H.useMemo(()=>({toast:n,setTitleId:C,setDescriptionId:T,recalculateHeight:oe,visibleIndex:ne,expanded:ae}),[n,C,T,oe,ne,ae]),_e={transitionStatus:n.transitionStatus,expanded:ae,limited:n.limited||!1,type:n.type,swiping:m,swipeDirection:f},ve=qf(`div`,e,{ref:[t,O],state:_e,stateAttributesMapping:F_,props:[he,s]});return(0,K.jsx)(C_.Provider,{value:ge,children:ve})}),H_=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{visibleIndex:o,expanded:s,recalculateHeight:c}=w_(),l=H.useRef(null);return U(()=>{c();let e=l.current;if(!e||typeof ResizeObserver!=`function`||typeof MutationObserver!=`function`)return;let t=new ResizeObserver(()=>c(!0)),n=new MutationObserver(()=>c(!0));return t.observe(e),n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{t.disconnect(),n.disconnect()}},[c]),qf(`div`,e,{ref:[t,l],state:{expanded:s,behind:o>0},props:a})});function U_(e){return e==null||typeof e==`boolean`||e===``?!1:!Array.isArray(e)||e.some(U_)}function W_(e){return H.isValidElement(e)&&U_(e.props.children)}function G_(e,t,n){let{toast:r,setTitleId:i,setDescriptionId:a}=w_(),o=n===`title`?i:a,s=t??(n===`title`?r.title:r.description);return{id:Tf(e),children:s,type:r.type,setId:o}}function K_(e,t,n){let r=W_(e);return U(()=>{if(r)return n(t),()=>{n(e=>e===t?void 0:e)}},[r,t,n]),r?e:null}var q_=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,children:o,...s}=e,{id:c,children:l,type:u,setId:d}=G_(a,o,`description`);return K_(qf(`p`,e,{ref:t,state:{type:u},props:{...s,id:c,children:l}}),c,d)}),J_=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,children:o,...s}=e,{id:c,children:l,type:u,setId:d}=G_(a,o,`title`);return K_(qf(`h2`,e,{ref:t,state:{type:u},props:{...s,id:c,children:l}}),c,d)}),Y_=H.createContext(void 0);function X_(e=!1){let t=H.useContext(Y_);if(t===void 0&&!e)throw Error(gc(16));return t}function Z_(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:H.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function Q_(e,t,{detail:n=0,pointerType:r=``}={}){e.dispatchEvent(new(Kc(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,pointerType:r,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function $_(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=H.useRef(null),s=X_(!0),c=a??s!==void 0,{props:l}=Z_({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=H.useCallback(()=>{let e=o.current;ev(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return U(u,[u]),{getButtonProps:H.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Pf({onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Wf(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=ev(r),s=!i&&tv(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),Q_(r,e))}else!l||i||!d&&!u?n&&s&&d&&e.preventDefault():e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Q_(r,e)))},onKeyUp(e){t||(Wf(e),a?.(e),e.target===e.currentTarget&&i&&c&&ev(e.currentTarget)&&e.key===` `?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||c||e.defaultPrevented||e.key!==` `||(e.preventBaseUIHandler(),Q_(e.currentTarget,e)))},onPointerDown(e){t?e.preventDefault():s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:q(e=>{o.current=e,u()})}}function ev(e){return Xc(e)&&e.tagName===`BUTTON`}function tv(e){return Xc(e)&&e.tagName===`A`&&!!e.href}var nv=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a,nativeButton:o=!0,...s}=e,c=d_(),{toast:l,expanded:u}=w_(),[d,f]=H.useState(!1),{getButtonProps:p,buttonRef:m}=$_({disabled:a,native:o}),h={type:l.type};return qf(`button`,e,{ref:[t,m],state:h,props:[{"aria-hidden":!u&&!d,onClick(){c.closeToast(l.id)},onFocus(){f(!0)},onBlur(){f(!1)}},s,p]})}),rv=H.forwardRef(function(e,t){return(0,K.jsx)(Cg,{ref:t,...e})});function iv(){let e=d_(),t=e.useState(`toasts`);return H.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function av(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||p_(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{id:e,updates:n}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var ov=`M21.1,12.5L22.5,13.91L15.97,20.5L12.5,17L13.9,15.59L15.97,17.67L21.1,12.5M11,4A4,4 0 0,1 15,8A4,4 0 0,1 11,12A4,4 0 0,1 7,8A4,4 0 0,1 11,4M11,6A2,2 0 0,0 9,8A2,2 0 0,0 11,10A2,2 0 0,0 13,8A2,2 0 0,0 11,6M11,13C11.68,13 12.5,13.09 13.41,13.26L11.74,14.93L11,14.9C8.03,14.9 4.9,16.36 4.9,17V18.1H11.1L13,20H3V17C3,14.34 8.33,13 11,13Z`,sv=`M15,4A4,4 0 0,1 19,8A4,4 0 0,1 15,12A4,4 0 0,1 11,8A4,4 0 0,1 15,4M15,5.9A2.1,2.1 0 0,0 12.9,8A2.1,2.1 0 0,0 15,10.1C16.16,10.1 17.1,9.16 17.1,8C17.1,6.84 16.16,5.9 15,5.9M15,13C17.67,13 23,14.33 23,17V20H7V17C7,14.33 12.33,13 15,13M15,14.9C12,14.9 8.9,16.36 8.9,17V18.1H21.1V17C21.1,16.36 17.97,14.9 15,14.9M5,13.28L2.5,14.77L3.18,11.96L1,10.08L3.87,9.83L5,7.19L6.11,9.83L9,10.08L6.8,11.96L7.45,14.77L5,13.28Z`,cv=`M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16`,lv=`M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z`,uv=`M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z`,dv=`M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z`,fv=`M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z`,pv=`M13,18H11V10L7.5,13.5L6.08,12.08L12,6.16L17.92,12.08L16.5,13.5L13,10V18M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z`,mv=`M7.64,10.38C7.64,10.63 7.66,10.83 7.71,11C7.76,11.12 7.83,11.28 7.92,11.46C7.96,11.5 7.97,11.56 7.97,11.61C7.97,11.68 7.93,11.74 7.84,11.81L7.42,12.09C7.36,12.13 7.3,12.15 7.25,12.15C7.18,12.15 7.12,12.11 7.05,12.05C6.96,11.95 6.88,11.85 6.81,11.74C6.75,11.63 6.68,11.5 6.61,11.35C6.09,11.96 5.44,12.27 4.65,12.27C4.09,12.27 3.65,12.11 3.32,11.79C3,11.47 2.83,11.04 2.83,10.5C2.83,9.95 3.03,9.5 3.43,9.14C3.84,8.8 4.38,8.62 5.06,8.62C5.29,8.62 5.5,8.64 5.77,8.68C6,8.71 6.27,8.76 6.53,8.82V8.34C6.53,7.83 6.43,7.5 6.22,7.27C6,7.06 5.65,6.97 5.14,6.97C4.9,6.97 4.66,7 4.42,7.05C4.17,7.11 3.93,7.18 3.7,7.28C3.59,7.32 3.5,7.35 3.47,7.36C3.42,7.38 3.39,7.38 3.36,7.38C3.27,7.38 3.22,7.32 3.22,7.18V6.85C3.22,6.75 3.23,6.67 3.27,6.62C3.3,6.57 3.36,6.53 3.45,6.5C3.69,6.36 3.96,6.26 4.29,6.18C4.62,6.09 4.96,6.05 5.33,6.05C6.12,6.05 6.7,6.23 7.07,6.59C7.44,6.95 7.62,7.5 7.62,8.23V10.38H7.64M4.94,11.4C5.16,11.4 5.38,11.36 5.62,11.28C5.86,11.2 6.07,11.05 6.25,10.85C6.36,10.72 6.44,10.58 6.5,10.42C6.5,10.26 6.55,10.07 6.55,9.84V9.57C6.35,9.5 6.15,9.5 5.93,9.45C5.72,9.43 5.5,9.41 5.31,9.41C4.86,9.41 4.54,9.5 4.32,9.68C4.1,9.86 4,10.11 4,10.44C4,10.76 4.07,11 4.24,11.15C4.4,11.32 4.63,11.4 4.94,11.4M10.28,12.11C10.16,12.11 10.08,12.09 10,12.05C9.97,12 9.92,11.91 9.88,11.79L8.32,6.65C8.28,6.5 8.26,6.43 8.26,6.38C8.26,6.27 8.31,6.21 8.42,6.21H9.07C9.2,6.21 9.29,6.23 9.33,6.28C9.39,6.32 9.43,6.41 9.47,6.54L10.58,10.94L11.62,6.54C11.65,6.41 11.69,6.32 11.75,6.28C11.8,6.24 11.89,6.21 12,6.21H12.55C12.67,6.21 12.76,6.23 12.81,6.28C12.86,6.32 12.91,6.41 12.94,6.54L14,11L15.14,6.54C15.18,6.41 15.23,6.32 15.27,6.28C15.33,6.24 15.41,6.21 15.53,6.21H16.15C16.26,6.21 16.32,6.27 16.32,6.38C16.32,6.41 16.31,6.45 16.3,6.5C16.3,6.5 16.28,6.58 16.26,6.65L14.65,11.79C14.61,11.93 14.57,12 14.5,12.05C14.46,12.09 14.37,12.12 14.26,12.12H13.69C13.56,12.12 13.5,12.1 13.42,12.05C13.37,12 13.32,11.92 13.3,11.79L12.27,7.5L11.24,11.78C11.21,11.91 11.17,12 11.12,12.05C11.06,12.09 10.97,12.11 10.85,12.11H10.28M18.83,12.29C18.5,12.29 18.13,12.25 17.8,12.17C17.47,12.09 17.21,12 17.04,11.91C16.93,11.85 16.86,11.78 16.83,11.72C16.8,11.66 16.79,11.6 16.79,11.54V11.2C16.79,11.06 16.84,11 16.94,11C17,11 17,11 17.06,11C17.1,11 17.16,11.05 17.23,11.08C17.45,11.18 17.7,11.26 17.96,11.31C18.23,11.36 18.5,11.39 18.75,11.39C19.17,11.39 19.5,11.32 19.72,11.17C19.95,11 20.07,10.81 20.07,10.54C20.07,10.35 20,10.2 19.89,10.07C19.77,9.95 19.54,9.83 19.22,9.73L18.25,9.43C17.77,9.27 17.41,9.05 17.19,8.75C16.97,8.46 16.86,8.13 16.86,7.78C16.86,7.5 16.92,7.26 17.04,7.05C17.16,6.83 17.32,6.65 17.5,6.5C17.72,6.35 17.94,6.24 18.21,6.16C18.47,6.08 18.75,6.04 19.05,6.04C19.19,6.04 19.34,6.05 19.5,6.07C19.64,6.09 19.78,6.12 19.92,6.14C20.06,6.18 20.18,6.21 20.3,6.25C20.42,6.29 20.5,6.33 20.58,6.37C20.67,6.42 20.74,6.47 20.78,6.53C20.82,6.59 20.84,6.66 20.84,6.75V7.07C20.84,7.21 20.79,7.28 20.69,7.28C20.64,7.28 20.55,7.25 20.43,7.2C20.06,7.03 19.63,6.94 19.16,6.94C18.78,6.94 18.5,7 18.27,7.13C18.07,7.25 17.96,7.45 17.96,7.72C17.96,7.91 18.03,8.07 18.16,8.19C18.29,8.32 18.54,8.44 18.89,8.56L19.84,8.86C20.32,9 20.66,9.22 20.87,9.5C21.07,9.77 21.17,10.08 21.17,10.43C21.17,10.71 21.11,10.97 21,11.2C20.88,11.42 20.72,11.62 20.5,11.78C20.31,11.95 20.06,12.07 19.78,12.16C19.5,12.25 19.16,12.29 18.83,12.29M20.08,15.53C17.89,17.14 14.71,18 12,18C8.15,18 4.7,16.58 2.09,14.23C1.88,14.04 2.07,13.79 2.32,13.94C5.14,15.57 8.61,16.56 12.21,16.56C14.64,16.56 17.31,16.06 19.76,15C20.13,14.85 20.44,15.26 20.08,15.53M21,14.5C20.71,14.13 19.14,14.32 18.43,14.4C18.22,14.43 18.19,14.24 18.38,14.1C19.63,13.23 21.69,13.5 21.92,13.77C22.16,14.07 21.86,16.13 20.69,17.11C20.5,17.26 20.33,17.18 20.41,17C20.68,16.32 21.27,14.84 21,14.5Z`,hv=`M10 21H14C14 22.1 13.1 23 12 23S10 22.1 10 21M21 19V20H3V19L5 17V11C5 7.9 7 5.2 10 4.3V4C10 2.9 10.9 2 12 2S14 2.9 14 4V4.3C17 5.2 19 7.9 19 11V17L21 19M17 11C17 8.2 14.8 6 12 6S7 8.2 7 11V18H17V11Z`,gv=`M17,20.41L18.41,19L15,15.59L13.59,17M7.5,8H11V13.59L5.59,19L7,20.41L13,14.41V8H16.5L12,3.5`,_v=`M14,4L16.29,6.29L13.41,9.17L14.83,10.59L17.71,7.71L20,10V4M10,4H4V10L6.29,7.71L11,12.41V20H13V11.59L7.71,6.29`,vv=`M22,21H2V3H4V19H6V10H10V19H12V6H16V19H18V14H22V21Z`,yv=`M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z`,bv=`M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z`,xv=`M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z`,Sv=`M19,3H14.82C14.4,1.84 13.3,1 12,1C10.7,1 9.6,1.84 9.18,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M7,7H17V5H19V19H5V5H7V7M7.5,13.5L9,12L11,14L15.5,9.5L17,11L11,17L7.5,13.5Z`,Cv=`M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z`,wv=`M13,19V16H21V19H13M8.5,13L2.47,7H6.71L11.67,11.95C12.25,12.54 12.25,13.5 11.67,14.07L6.74,19H2.5L8.5,13Z`,Tv=`M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z`,Ev=`M20 4H4A2 2 0 0 0 2 6V18A2 2 0 0 0 4 20H20A2 2 0 0 0 22 18V6A2 2 0 0 0 20 4M20 13H4V6H20Z`,Dv=`M18 18V20H4A2 2 0 0 1 2 18V8H4V18M22 6V14A2 2 0 0 1 20 16H8A2 2 0 0 1 6 14V6A2 2 0 0 1 8 4H20A2 2 0 0 1 22 6M20 6H8V14H20Z`,Ov=`M12 13H7V18H12V20H5V10H7V11H12V13M8 4V6H4V4H8M10 2H2V8H10V2M20 11V13H16V11H20M22 9H14V15H22V9M20 18V20H16V18H20M22 16H14V22H22V16Z`,kv=`M17 4H20C21.1 4 22 4.9 22 6V8H20V6H17V4M4 8V6H7V4H4C2.9 4 2 4.9 2 6V8H4M20 16V18H17V20H20C21.1 20 22 19.1 22 18V16H20M7 18H4V16H2V18C2 19.1 2.9 20 4 20H7V18M16 10V14H8V10H16M18 8H6V16H18V8Z`,Av=`M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z`,jv=`M15,4V11H5.17L4,12.17V4H15M16,2H3A1,1 0 0,0 2,3V17L6,13H16A1,1 0 0,0 17,12V3A1,1 0 0,0 16,2M21,6H19V15H6V17A1,1 0 0,0 7,18H18L22,22V7A1,1 0 0,0 21,6Z`,Mv=`M2.6,10.59L8.38,4.8L10.07,6.5C9.83,7.35 10.22,8.28 11,8.73V14.27C10.4,14.61 10,15.26 10,16A2,2 0 0,0 12,18A2,2 0 0,0 14,16C14,15.26 13.6,14.61 13,14.27V9.41L15.07,11.5C15,11.65 15,11.82 15,12A2,2 0 0,0 17,14A2,2 0 0,0 19,12A2,2 0 0,0 17,10C16.82,10 16.65,10 16.5,10.07L13.93,7.5C14.19,6.57 13.71,5.55 12.78,5.16C12.35,5 11.9,4.96 11.5,5.07L9.8,3.38L10.59,2.6C11.37,1.81 12.63,1.81 13.41,2.6L21.4,10.59C22.19,11.37 22.19,12.63 21.4,13.41L13.41,21.4C12.63,22.19 11.37,22.19 10.59,21.4L2.6,13.41C1.81,12.63 1.81,11.37 2.6,10.59Z`,Nv=`M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z`,Pv=`M19.5 17C19.36 17 19.24 17 19.11 17.04L17.5 13.8C17.95 13.35 18.25 12.71 18.25 12C18.25 10.62 17.13 9.5 15.75 9.5C15.61 9.5 15.5 9.5 15.35 9.54L13.74 6.3C14.21 5.84 14.5 5.21 14.5 4.5C14.5 3.12 13.38 2 12 2S9.5 3.12 9.5 4.5C9.5 5.2 9.79 5.84 10.26 6.29L8.65 9.54C8.5 9.5 8.39 9.5 8.25 9.5C6.87 9.5 5.75 10.62 5.75 12C5.75 12.71 6.04 13.34 6.5 13.79L4.89 17.04C4.76 17 4.64 17 4.5 17C3.12 17 2 18.12 2 19.5C2 20.88 3.12 22 4.5 22S7 20.88 7 19.5C7 18.8 6.71 18.16 6.24 17.71L7.86 14.46C8 14.5 8.12 14.5 8.25 14.5C8.38 14.5 8.5 14.5 8.63 14.46L10.26 17.71C9.79 18.16 9.5 18.8 9.5 19.5C9.5 20.88 10.62 22 12 22S14.5 20.88 14.5 19.5C14.5 18.12 13.38 17 12 17C11.87 17 11.74 17 11.61 17.04L10 13.8C10.45 13.35 10.75 12.71 10.75 12C10.75 11.3 10.46 10.67 10 10.21L11.61 6.96C11.74 7 11.87 7 12 7C12.13 7 12.26 7 12.39 6.96L14 10.21C13.54 10.66 13.25 11.3 13.25 12C13.25 13.38 14.37 14.5 15.75 14.5C15.88 14.5 16 14.5 16.13 14.46L17.76 17.71C17.29 18.16 17 18.8 17 19.5C17 20.88 18.12 22 19.5 22S22 20.88 22 19.5C22 18.12 20.88 17 19.5 17M4.5 20.5C3.95 20.5 3.5 20.05 3.5 19.5S3.95 18.5 4.5 18.5 5.5 18.95 5.5 19.5 5.05 20.5 4.5 20.5M13 19.5C13 20.05 12.55 20.5 12 20.5S11 20.05 11 19.5 11.45 18.5 12 18.5 13 18.95 13 19.5M7.25 12C7.25 11.45 7.7 11 8.25 11S9.25 11.45 9.25 12 8.8 13 8.25 13 7.25 12.55 7.25 12M11 4.5C11 3.95 11.45 3.5 12 3.5S13 3.95 13 4.5 12.55 5.5 12 5.5 11 5.05 11 4.5M14.75 12C14.75 11.45 15.2 11 15.75 11S16.75 11.45 16.75 12 16.3 13 15.75 13 14.75 12.55 14.75 12M19.5 20.5C18.95 20.5 18.5 20.05 18.5 19.5S18.95 18.5 19.5 18.5 20.5 18.95 20.5 19.5 20.05 20.5 19.5 20.5Z`,Fv=`M20 16V4H8V16H20M22 16C22 17.1 21.1 18 20 18H8C6.9 18 6 17.1 6 16V4C6 2.9 6.9 2 8 2H20C21.1 2 22 2.9 22 4V16M16 20V22H4C2.9 22 2 21.1 2 20V7H4V20H16M14.2 5C13.3 5 12.6 5.2 12.1 5.6C11.6 6 11.3 6.6 11.3 7.4H13.2C13.2 7.1 13.3 6.9 13.5 6.7C13.7 6.6 13.9 6.5 14.2 6.5C14.5 6.5 14.8 6.6 15 6.8C15.2 7 15.3 7.2 15.3 7.6C15.3 7.9 15.2 8.2 15.1 8.4C15 8.6 14.7 8.8 14.5 9C14 9.3 13.6 9.6 13.5 9.9C13.1 10.1 13 10.5 13 11H15C15 10.7 15 10.4 15.1 10.3C15.2 10.1 15.4 9.9 15.6 9.8C16 9.6 16.4 9.3 16.7 8.9C17 8.4 17.2 8 17.2 7.5C17.2 6.7 16.9 6.1 16.4 5.7C15.9 5.2 15.1 5 14.2 5M13 12V14H15V12H13Z`,Iv=`M4,5A2,2 0 0,0 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7A2,2 0 0,0 20,5H4M4,7H20V17H4V7M5,8V10H7V8H5M8,8V10H10V8H8M11,8V10H13V8H11M14,8V10H16V8H14M17,8V10H19V8H17M5,11V13H7V11H5M8,11V13H10V11H8M11,11V13H13V11H11M14,11V13H16V11H14M17,11V13H19V11H17M8,14V16H16V14H8Z`,Lv=`M12,18.54L19.37,12.8L21,14.07L12,21.07L3,14.07L4.62,12.81L12,18.54M12,16L3,9L12,2L21,9L12,16M12,4.53L6.26,9L12,13.47L17.74,9L12,4.53Z`,Rv=`M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z`,zv=`M13,10H11V6H13V10M13,12H11V14H13V12M22,4V16A2,2 0 0,1 20,18H6L2,22V4A2,2 0 0,1 4,2H20A2,2 0 0,1 22,4M20,4H4V17.2L5.2,16H20V4Z`,Bv=`M19,13H5V11H19V13Z`,Vv=`M18.13 12L19.39 10.74C19.83 10.3 20.39 10.06 21 10V9L15 3H5C3.89 3 3 3.89 3 5V19C3 20.1 3.89 21 5 21H11V19.13L11.13 19H5V5H12V12H18.13M14 4.5L19.5 10H14V4.5M19.13 13.83L21.17 15.87L15.04 22H13V19.96L19.13 13.83M22.85 14.19L21.87 15.17L19.83 13.13L20.81 12.15C21 11.95 21.33 11.95 21.53 12.15L22.85 13.47C23.05 13.67 23.05 14 22.85 14.19Z`,Hv=`M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z`,Uv=`M14,19H18V5H14M6,19H10V5H6V19Z`,Wv=`M3 17.25V21H6.75L17.81 9.93L14.06 6.18L3 17.25M22.61 18.36L18.36 22.61L13.16 17.41L14.93 15.64L15.93 16.64L18.4 14.16L19.82 15.58L18.36 17L19.42 18L20.84 16.6L22.61 18.36M6.61 10.83L1.39 5.64L5.64 1.39L7.4 3.16L4.93 5.64L6 6.7L8.46 4.22L9.88 5.64L8.46 7.05L9.46 8.05L6.61 10.83M20.71 7C21.1 6.61 21.1 6 20.71 5.59L18.37 3.29C18 2.9 17.35 2.9 16.96 3.29L15.12 5.12L18.87 8.87L20.71 7Z`,Gv=`M8,5.14V19.14L19,12.14L8,5.14Z`,Kv=`M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z`,qv=`M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z`,Jv=`M10.5 15.5C10.5 15.87 10.4 16.2 10.22 16.5C9.88 15.91 9.24 15.5 8.5 15.5S7.12 15.91 6.78 16.5C6.61 16.2 6.5 15.87 6.5 15.5C6.5 14.4 7.4 13.5 8.5 13.5S10.5 14.4 10.5 15.5M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C17.87 7 21 10.13 21 14H22C22.55 14 23 14.45 23 15M21 16H19V14C19 11.24 16.76 9 14 9H10C7.24 9 5 11.24 5 14V16H3V17H5V20H19V17H21V16M15.5 13.5C14.4 13.5 13.5 14.4 13.5 15.5C13.5 15.87 13.61 16.2 13.78 16.5C14.12 15.91 14.76 15.5 15.5 15.5S16.88 15.91 17.22 16.5C17.4 16.2 17.5 15.87 17.5 15.5C17.5 14.4 16.61 13.5 15.5 13.5Z`,Yv=`M17.5 15.5C17.5 16.61 16.61 17.5 15.5 17.5S13.5 16.61 13.5 15.5 14.4 13.5 15.5 13.5 17.5 14.4 17.5 15.5M8.5 13.5C7.4 13.5 6.5 14.4 6.5 15.5S7.4 17.5 8.5 17.5 10.5 16.61 10.5 15.5 9.61 13.5 8.5 13.5M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C17.87 7 21 10.13 21 14H22C22.55 14 23 14.45 23 15M21 16H19V14C19 11.24 16.76 9 14 9H10C7.24 9 5 11.24 5 14V16H3V17H5V20H19V17H21V16Z`,Xv=`M13,14C9.64,14 8.54,15.35 8.18,16.24C9.25,16.7 10,17.76 10,19A3,3 0 0,1 7,22A3,3 0 0,1 4,19C4,17.69 4.83,16.58 6,16.17V7.83C4.83,7.42 4,6.31 4,5A3,3 0 0,1 7,2A3,3 0 0,1 10,5C10,6.31 9.17,7.42 8,7.83V13.12C8.88,12.47 10.16,12 12,12C14.67,12 15.56,10.66 15.85,9.77C14.77,9.32 14,8.25 14,7A3,3 0 0,1 17,4A3,3 0 0,1 20,7C20,8.34 19.12,9.5 17.91,9.86C17.65,11.29 16.68,14 13,14M7,18A1,1 0 0,0 6,19A1,1 0 0,0 7,20A1,1 0 0,0 8,19A1,1 0 0,0 7,18M7,4A1,1 0 0,0 6,5A1,1 0 0,0 7,6A1,1 0 0,0 8,5A1,1 0 0,0 7,4M17,6A1,1 0 0,0 16,7A1,1 0 0,0 17,8A1,1 0 0,0 18,7A1,1 0 0,0 17,6Z`,Zv=`M8,0H20A2,2 0 0,1 22,2V18A2,2 0 0,1 20,20H8A2,2 0 0,1 6,18V2A2,2 0 0,1 8,0M14.75,11.5C17.5,11.5 18.24,9.47 18.43,8.4C19.34,8.11 20,7.26 20,6.25C20,5 19,4 17.75,4C16.5,4 15.5,5 15.5,6.25C15.5,7.19 16.07,8 16.89,8.33C16.67,9 16,10 14,10C12.62,10 11.66,10.35 11,10.84V6.87C11.87,6.56 12.5,5.73 12.5,4.75C12.5,3.5 11.5,2.5 10.25,2.5C9,2.5 8,3.5 8,4.75C8,5.73 8.63,6.56 9.5,6.87V13.13C8.63,13.44 8,14.27 8,15.25C8,16.5 9,17.5 10.25,17.5C11.5,17.5 12.5,16.5 12.5,15.25C12.5,14.32 11.94,13.5 11.13,13.18C11.41,12.5 12.23,11.5 14.75,11.5M10.25,14.5A0.75,0.75 0 0,1 11,15.25A0.75,0.75 0 0,1 10.25,16A0.75,0.75 0 0,1 9.5,15.25A0.75,0.75 0 0,1 10.25,14.5M10.25,4A0.75,0.75 0 0,1 11,4.75A0.75,0.75 0 0,1 10.25,5.5A0.75,0.75 0 0,1 9.5,4.75A0.75,0.75 0 0,1 10.25,4M17.75,5.5A0.75,0.75 0 0,1 18.5,6.25A0.75,0.75 0 0,1 17.75,7A0.75,0.75 0 0,1 17,6.25A0.75,0.75 0 0,1 17.75,5.5M16,22V24H4A2,2 0 0,1 2,22V6H4V22H16Z`,Qv=`M18,18H6V6H18V18Z`,$v=`M5,3C3.89,3 3,3.89 3,5V19C3,20.11 3.89,21 5,21H19C20.11,21 21,20.11 21,19V5C21,3.89 20.11,3 19,3H5M5,5H19V19H5V5M7,7V9H17V7H7M7,11V13H17V11H7M7,15V17H14V15H7Z`,ey=`M4,4H20V20H4V4M6,8V18H18V8H6Z`,ty=`M20,14H4V10H20`,ny=`M4,8H8V4H20V16H16V20H4V8M16,8V14H18V6H10V8H16M6,12V18H14V12H6Z`,ry=e=>()=>(0,K.jsx)(`svg`,{"aria-hidden":`true`,fill:`currentColor`,focusable:`false`,height:`1em`,viewBox:`0 0 24 24`,width:`1em`,children:(0,K.jsx)(`path`,{d:e})}),iy=ry(Gv),ay=ry(Uv),oy=ry(Qv),sy=ry(Cv),cy=ry(yv),ly=ry(bv),uy=ry(xv),dy=ry(uv),fy=ry(dv),py=ry(fv),my=ry(lv),hy=ry(Tv),gy=ry(Rv),_y=ry(wv),vy=ry(ty),yy=ry(ey),by=ry(ny),xy=ry(Dv),Sy=ry(Ev),Cy=ry(Av),wy=ry(Pv),Ty=ry($v),Ey=ry(Fv),Dy=ry(jv),Oy=ry(hv),ky=ry(vv),Ay=ry(Wv),jy=ry(Lv),My=ry(cv),Ny=ry(zv),Py=ry(Vv),Fy=ry(Hv),Iy=ry(Zv),Ly=ry(Sv),Ry=ry(sv),zy=ry(Yv),By=ry(Jv),Vy=ry(_v),Hy=ry(gv),Uy=ry(Xv),Wy=ry(ov),Gy=ry(Ov),Ky=ry(Nv),qy=ry(mv),Jy=ry(Mv),Yy=ry(Kv),Xy=ry(Bv),Zy=ry(kv),Qy=ry(Iv),$y=ry(pv),eb=ry(qv),tb={viewport:`_viewport_1wznh_6`,toast:`_toast_1wznh_25`,content:`_content_1wznh_62`,title:`_title_1wznh_66`,description:`_description_1wznh_75`,close:`_close_1wznh_82`},nb=av(),rb=()=>{let{toasts:e}=iv();return e.map(e=>(0,K.jsxs)(V_,{className:tb.toast,toast:e,children:[(0,K.jsxs)(H_,{className:tb.content,children:[(0,K.jsx)(J_,{className:tb.title,children:typeof e.title==`string`?(0,K.jsx)(J,{text:e.title}):e.title}),(0,K.jsx)(q_,{className:tb.description,children:typeof e.description==`string`?(0,K.jsx)(J,{text:e.description}):e.description})]}),(0,K.jsx)(nv,{"aria-label":`Dismiss`,className:tb.close,children:(0,K.jsx)(sy,{})})]},e.id))},ib=({children:e})=>(0,K.jsxs)(y_,{toastManager:nb,children:[e,(0,K.jsx)(rv,{children:(0,K.jsx)(S_,{"aria-label":`Messages`,className:tb.viewport,children:(0,K.jsx)(rb,{})})})]}),ab=(0,H.createContext)(null),ob=ab.Provider,sb=()=>{let e=(0,H.useContext)(ab);if(e===null)throw Error(`No AppStateProvider above this.`);return e},cb={DEFAULT:`default`,COMPUTED:`computed`},lb=class e{_value;_subscribers;_initialValue;#e=[];#t=!1;static create(t){return new e(t)}constructor(e){let t=typeof e==`function`?e():e;this._initialValue=t,this._value=t,this._subscribers=new Set}getValue(){return this._value}getServerValue(){return this._value}setValue(e){let t=this._value;return this._value=e,new Promise(n=>{this.#e.push(()=>{let r=[...this._subscribers];n(this.#r(r,t,e))}),this.#n()})}#n(){if(!this.#t){this.#t=!0;for(let e of this.#e)e();this.#e.length=0,this.#t=!1}}async#r(e,t,n){let r=(await Promise.allSettled(e.map(e=>this.#i(e,t,n)))).flatMap(e=>e.status===`rejected`?[e.reason]:[]);if(r.length>1)throw AggregateError(r,`Several subscribers failed.`);if(r.length===1)throw r[0]}async#i(e,t,n){if(!this._subscribers.has(e))return;if(e.type!==cb.COMPUTED){Object.is(t,n)||await e.cb(n);return}let{computeValue:r,cb:i,isEqual:a}=e;if(a===void 0&&Object.is(t,n))return;let o=r(n),s=r(t);(a?.(s,o)??Object.is(o,s))||await i(o)}subscribe(e,t){let{signal:n}=t??{},r={type:cb.DEFAULT,cb:e};this._subscribers.add(r);let i=()=>{this._subscribers.delete(r),n?.removeEventListener(`abort`,i)};return n?.addEventListener(`abort`,i),n?.aborted===!0&&i(),i}computedSubscribe(e,t,n){let{isEqual:r,signal:i}=n??{},a={type:cb.COMPUTED,computeValue:e,cb:t,isEqual:r};this._subscribers.add(a);let o=()=>{this._subscribers.delete(a),i?.removeEventListener(`abort`,o)};return i?.addEventListener(`abort`,o),i?.aborted===!0&&o(),o}reset(){return this.setValue(this._initialValue)}},ub=e=>typeof e==`object`&&!!e&&`timestamp`in e&&typeof e.timestamp==`number`,db=class extends lb{#e;#t;#n;#r;#i;#a;constructor(e,t){super(e),this.#e=t.key,this.#t=t.storage,this.#n=t.ttl,this.#r=e=>t.serialize===void 0?e:t.serialize(e),this.#i=e=>t.deserialize===void 0?e:t.deserialize(e),this.#a=t.onError;let n=this.#o();n!==null&&(this._value=n.value)}getServerValue(){return this._initialValue}async setValue(e){this.#c(e),await super.setValue(e)}async reset(){this.#s(),await super.setValue(this._initialValue)}#o(){try{let e=this.#t.getItem(this.#e);if(e===null)return null;let t=JSON.parse(e);if(!ub(t))throw TypeError(`Unexpected data in "${this.#e}".`);return this.#n!==void 0&&Date.now()-t.timestamp>this.#n?(this.#t.removeItem(this.#e),null):{...t,value:this.#i(t.value)}}catch(e){return this.#l(e),null}}#s(){try{this.#t.removeItem(this.#e)}catch(e){this.#l(e)}}#c(e){try{let t=this.#r(e);if(typeof t==`function`||typeof t==`symbol`)throw TypeError(`Cannot save a ${typeof t} as JSON.`);let n={value:t,timestamp:Date.now()};this.#t.setItem(this.#e,JSON.stringify(n))}catch(e){this.#l(e)}}#l(e){try{this.#a?.(e)}catch{}}},fb=`ork.preferences.v1`,pb=gs({theme:ks([`system`,`dark`,`light`]).default(`system`),density:ks([`compact`,`comfortable`]).default(`compact`),desktopNotifications:cs().default(!1),updateDismissed:gs({version:B(),at:B()}).optional(),decisionFilter:Ds(B(),B()).default({})}),mb={theme:`system`,density:`compact`,desktopNotifications:!1,decisionFilter:{}},hb=e=>{let t=new db(mb,{key:fb,storage:e}),n=pb.safeParse(t.getValue());return n.success?t.setValue(n.data):t.reset(),{value:t,update:e=>{t.setValue({...t.getValue(),...e})}}},gb=(e,t)=>{let{value:n}=t,r=e.document.documentElement,i=()=>{r.dataset.density=n.getValue().density};i();let a=ae(e,()=>n.getValue().theme),o=n.subscribe(()=>{i(),he(e,n.getValue().theme)});return()=>{a(),o()}},_b=e=>typeof e.getServerValue==`function`?e.getServerValue():e.getValue(),vb=(e,t,n)=>{let{subscribe:r,getServerSnapshot:i,getSnapshot:a}=(0,H.useMemo)(()=>({subscribe:e.subscribe.bind(e),getSnapshot:e.getValue.bind(e),getServerSnapshot:()=>_b(e)}),[e]);return(0,hm.useSyncExternalStoreWithSelector)(r,a,i,t,n)},yb=e=>{let{subscribe:t,getServerSnapshot:n,getSnapshot:r}=(0,H.useMemo)(()=>({subscribe:e.subscribe.bind(e),getSnapshot:e.getValue.bind(e),getServerSnapshot:()=>_b(e)}),[e]);return(0,mm.useSyncExternalStore)(t,r,n)},bb=H.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=$_({disabled:i,focusableWhenDisabled:a,native:o});return qf(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),xb={button:`_button_bj0an_7`,icon:`_icon_bj0an_8`},Y=({variant:e=`default`,cli:t,tip:n,...r})=>{let i=(0,K.jsx)(bb,{...r,...c_(t),className:xb.button,"data-variant":e});return t===void 0&&n===void 0?i:(0,K.jsx)(l_,{cli:t,label:n,children:i})},Sb=({label:e,variant:t=`ghost`,cli:n,keys:r,...i})=>(0,K.jsx)(l_,{cli:n,keys:r,label:e,children:(0,K.jsx)(bb,{...i,...c_(n),"aria-label":e,className:xb.icon,"data-variant":t})});function Cb({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=H.useRef(e!==void 0),[a,o]=H.useState(()=>t);return[i&&e!==void 0?e:a,H.useCallback(e=>{i||o(e)},[])]}function wb(e){let t=H.useRef(!0);t.current&&(t.current=!1,e())}function Tb(e,t,n,r,i,a,o,s,c,l=2){let u=jd(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return Ed(n.current,u)?void 0:u}function Eb(e){return e==null?iu:e.type.startsWith(`key`)?_u:e.type.startsWith(`mouse`)||e.type.startsWith(`pointer`)?vu:iu}var Db=H.createContext(void 0),Ob=H.createContext(void 0),kb=H.createContext(void 0),Ab=H.createContext(!1),jb=H.createContext(``);function Mb(){let e=H.useContext(Db);if(!e)throw Error(gc(22));return e}function Nb(){let e=H.useContext(Ob);if(!e)throw Error(gc(23));return e}function Pb(){let e=H.useContext(kb);if(!e)throw Error(gc(24));return e}function Fb(){return H.useContext(jb)}function Ib(){return H.useContext(Ab)}function Lb(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var Rb=(e,t)=>Object.is(e,t);function zb(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Bb(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Lb(e,t,(e,t)=>zb(e,t,n)):e!==t}function Vb(e,t,n){return e?e.some(e=>e!==void 0&&zb(t,e,n)):!1}function Hb(e,t,n){return e?e.findIndex(e=>e!==void 0&&zb(e,t,n)):-1}function Ub(e,t){if(t!==Rb)return n=>Vb(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Wb(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Ub(t,n)):Hb(e,t,n);return i===-1?null:i}function Gb(e,t,n,r,i,a){return Vb(r,t,i)?a!=null&&e>a&&Vb(r,n[a],i)?a:e:e===a?Wb(n,r,i,!0):a}function Kb(e,t,n){return e.filter(e=>!zb(t,e,n))}function qb(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Jb(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Yb(e){return Jb(e?.[0])}function Xb(e){return Yb(e)?e.flatMap(e=>e.items):e}function Zb(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Yb(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Qb(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return qb(e)}function $b(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?qb(e.value):qb(e)}function ex(e,t,n){function r(){return Qb(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=Xb(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function tx(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,K.jsx)(H.Fragment,{children:ex(r,t,n)},i)),e),[])}var nx={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Zb(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>zb(t,e,n)):zb(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},rx=`data-valid`,ix=`data-invalid`,ax={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},ox={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},sx={disabled:!1,...ox},cx={valid(e){return e===null?null:e?{[rx]:``}:{[ix]:``}}},lx={invalid:void 0,name:void 0,validityData:{state:ax,errors:[],error:``,value:``,initialValue:null},setValidityData:fc,disabled:void 0,setTouched:fc,setDirty:fc,setFilled:fc,setFocused:fc,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:sx,registerFieldControl:fc,validation:{getValidationProps:(e,t=mc)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:fc,getInputControl:()=>null,commit:async()=>{},change:fc}},ux=H.createContext(lx);function dx(e=!0){let t=H.useContext(ux);if(t.setValidityData===fc&&!e)throw Error(gc(28));return t}function fx(e,t,n,r,i=!0,a){let{registerFieldControl:o}=dx(),s=ic(()=>Symbol());U(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),U(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var px=H.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:fc,validationMode:`onSubmit`,submitCountRef:{current:0}});function mx(){return H.useContext(px)}var hx=H.createContext({controlId:void 0,registerControlId:fc,resetControlId:fc,labelId:void 0,setLabelId:fc,messageIds:[],setMessageIds:fc,getDescriptionProps:e=>e});function gx(){return H.useContext(hx)}function _x(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=gx(),o=hg(),s=ic(()=>Symbol()),c=H.useRef(!1),l=H.useRef(!1),u=q(()=>{c.current&&i!==fc&&(c.current=!1,i(s.current,void 0))});return U(()=>{if(!n||i===fc){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),U(()=>u,[u]),(n?r:void 0)??t??o}function vx(e){return e==null?void 0:`${e}-popup`}function yx(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function bx(e){return Array.isArray(e)?e.map(e=>bx(e)).join(`,`):e==null?``:String(e)}var xx=new Map;function Sx(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${bx(t)}|${JSON.stringify(r)}`,a=xx.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=Qb(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Qb(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Qb(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return xx.set(i,s),s}var Cx=Sx;function wx(e){let t=H.useRef(``),n=H.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:H.useCallback(n=>{n.detail===0?e(n,`keyboard`):(`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``)},[e]),onPointerDown:n}}function Tx(e,t){let n=H.useRef(e),r=q(t);U(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function Ex(e,t){let{onClick:n,onPointerDown:r}=wx(q((n,r)=>{(typeof e==`function`?e():e)||t(r||(kc?`touch`:``))}));return H.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function Dx(e){let[t,n]=H.useState(null),r=Ex(e,n);return Tx(e,t=>{t&&!e&&n(null)}),H.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var Ox=Symbol(`none`),kx={value:Ox,index:-1};function Ax(e,t,n){let r=e.get(t);if(r!==void 0||n===Rb)return r;for(let[r,i]of e)if(zb(r,t,n))return i}function jx(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:l=!1,selectionMode:u,onItemHighlighted:d,name:f,form:p,disabled:m=!1,readOnly:h=!1,required:g=!1,inputRef:_,grid:v=!1,items:y,filteredItems:b,filter:x,filterQuery:S,openOnInputClick:C=!0,autoHighlight:w=!1,keepHighlight:T=!1,highlightItemOnHover:E=!0,loopFocus:D=!0,itemToStringLabel:O,itemToStringValue:k,isItemEqualToValue:A=Rb,virtualized:j=!1,inline:M=!1,fillInputOnItemPress:N=!0,modal:P=!1,limit:F=-1,autoComplete:I=`list`,formAutoComplete:L,locale:R,submitOnItemClick:ee=!1}=e,{clearErrors:te}=mx(),{setDirty:ne,validityData:re,setFilled:ie,name:ae,disabled:oe,setTouched:se,setFocused:ce,validationMode:le,validation:ue}=dx(),de=kg(),fe=_x({id:t}),pe=Cx({locale:R}),me=Array.isArray(y)?null:y;if(me&&typeof me.label!=`function`)throw Error(gc(100));let he=me?me.data:y,ge=me?.value,_e=ge?void 0:he,ve=H.useMemo(()=>{if(!b||!ge)return;let e=Xb(b),t=e.map(ge),n;return{values:t,findItem(r,i){if(!n){n=new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return Ax(n,r,i)}}},[b,ge]),ye=H.useMemo(()=>me?e=>me.label(e,A,e=>{let t=ve?.findItem(e,A);return t==null?Qb(e,O):me.itemLabel(t)}):O,[me,O,ve,A]),be=H.useMemo(()=>me?Object.assign(e=>me.itemLabel(e),{selected:e=>Qb(e,ye)}):O,[me,ye,O]);function xe(e){return Qb(e,ye)}let[z,Se]=H.useState(!1),[Ce,we]=H.useState(null),Te=H.useRef(Ce),Ee=H.useRef([]),De=H.useRef([]),Oe=H.useRef(null),ke=H.useRef(null),Ae=H.useRef(null),je=H.useRef(null),Me=H.useRef(null),Ne=H.useRef(!1),Pe=H.useRef(null),Fe=H.useRef(null),Ie=H.useRef(null),Le=H.useRef(kx),Re=H.useRef(null),ze=H.useRef([]),Be=H.useRef(null),Ve=oe||m,He=ae??f,Ue=u===`multiple`,We=u===`single`,Ge=s!==void 0||o!==void 0,Ke=he!==void 0,qe=b!==void 0,Je;Je=w===`always`?`always`:w?`input-change`:!1;let[Ye,Xe]=Cb({controlled:i,default:Ue?r??pc:r,name:`Combobox`,state:`selectedValue`}),Ze=H.useMemo(()=>x===null?()=>!0:x===void 0?yx(pe,be):x,[x,pe,be]),Qe=ic(()=>Ge?o??``:We?xe(Ye):``).current,[$e,et]=Cb({controlled:s,default:Qe,name:`Combobox`,state:`inputValue`}),[tt,nt]=Cb({controlled:c,default:l,name:`Combobox`,state:`open`}),rt=Yb(he),it=!tt&&Ce!==null?Ce:String($e).trim(),at=We?xe(Ye):``,ot=We&&!z&&it!==``&&at.length===it.length&&pe.contains(at,it),st=ot?``:S??it,ct=Ke&&qe&&ot&&(!me||me.hasValue(Ye,A)),lt=H.useMemo(()=>he?Xb(he):pc,[he]),ut=H.useMemo(()=>{if(b&&!ct)return b;if(!he)return pc;if(rt){let e=he,t=[],n=0;for(let r of e){if(F>-1&&n>=F)break;let e=F>-1?F-n:1/0,i=st===``?r.items.slice(0,e):[];if(st!==``)for(let t of r.items){if(i.length>=e)break;Ze(t,st,be)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(st===``)return F>-1?lt.slice(0,F):lt;let e=[];for(let t of lt){if(F>-1&&e.length>=F)break;Ze(t,st,be)&&e.push(t)}return e},[b,ct,he,rt,st,F,Ze,be,lt]),dt=H.useMemo(()=>{if(ve&&ut===b)return ve.values;let e=Xb(ut);return ge?e.map(e=>ge(e)):e},[ut,b,ve,ge]),ft=ic(()=>{let e=null;return M&&tt&&Ke&&u!==`none`&&(e=Wb(dt,Ye,A,Ue)),new Sm({id:fe,labelId:void 0,selectedValue:Ye,open:tt,items:_e,selectionMode:u,name:He,form:p,disabled:Ve,readOnly:h,required:g,grid:v,virtualized:j,openOnInputClick:C,itemToStringLabel:ye,isItemEqualToValue:A,modal:P,autoHighlight:Je,submitOnItemClick:ee,hasInputValue:Ge,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:M,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemRoot:{props:mc,id:fe,selectionMode:u,disabled:Ve,readOnly:h,isItemEqualToValue:A},positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:u===`none`},{onOpenChangeComplete:fc,setOpen:fc,setInputValue:fc,setSelectedValue:fc,setIndices:fc,handleSelection:fc,forceMount:fc,requestSubmit:fc,listRef:Ee,labelsRef:De,popupRef:Oe,emptyRef:Me,inputRef:ke,startDismissRef:Ae,endDismissRef:je,chipsContainerRef:Pe,clearRef:Fe,valuesRef:ze,pointerDownItemRef:Be,selectionEventRef:Ie},nx)}).current,pt=u===`none`?$e:Ye,mt=H.useMemo(()=>u===`none`?pt:Array.isArray(Ye)?Ye.map(e=>$b(e,k)):$b(Ye,k),[pt,k,u,Ye]),ht=q(d),gt=q(n),_t=ft.useState(`activeIndex`),vt=ft.useState(`selectedIndex`),yt=ft.useState(`positionerElement`),bt=ft.useState(`listElement`),xt=ft.useState(`triggerElement`),St=ft.useState(`inputElement`),Ct=ft.useState(`inputGroupElement`),wt=ft.useState(`inline`),Tt=ft.useState(`inputInsidePopup`),Et=ft.useState(`inputOwnsFormValue`),Dt=We&&!Tt&&$e===at,Ot=Iu(xt),{openMethod:kt,triggerProps:At}=Dx(tt),jt=q(()=>mt);fx(Tt?Ot:ke,fe,pt,jt,!Ve,f);let Mt=q(()=>{he?De.current=dt.map(xe):ft.set(`forceMounted`,!0)}),Nt=q((e,t,n,r)=>{if(t===-1){if(Le.current===kx)return;Le.current=kx}else Le.current={value:e,index:t};ht(e,ru(n,r,{index:t}))}),Pt=q(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),ft.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?Nt(void 0,-1,r,e.event):Nt(ze.current[n],n,r,e.event)}),Ft=q((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ne.current=n.reason===fu,n.reason===`input-change`){tt&&Ce!==null&&we(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&Se(!0),Re.current={hasQuery:e};let n=ft.state.listElement;if(!ft.state.virtualized&&n){let e=Oe.current;for(let t of pl(n.firstElementChild??n)){if(!Xc(t)||(e?!W(e,t):t.getAttribute(`role`)===`dialog`))break;if(E_(t)){t.scrollTop=0;break}}}e&&Je&&ft.state.activeIndex==null&&(tt||wt)&&ft.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&ft.state.inputInsidePopup&&(Re.current={hasQuery:!1,selection:!0});et(t)}}),It=q(e=>{let t=!e&&Tt&&!wt&&$e!==``&&(String($e).trim()===Ce||$e===at);!e&&(t||$e===``||Dt)&&Se(!1),we(null),t&&Ft(``,G(fu))}),[Lt,Rt]=H.useState(!1),zt=q((t,n)=>{if(tt===t)return;n.reason===`escape-key`&&Ke&&dt.length===0&&!Me.current&&n.allowPropagation();let r=n,i=nm(r);if(e.onOpenChange?.(t,r),Re.current?.hasQuery&&n.reason===`input-change`===n.isCanceled&&(Re.current=null),!n.isCanceled&&(t&&Ce!==null&&It(n.reason===du),!t&&z&&(We?(wt||we(it),it===``&&Se(!1)):Ue&&(wt||we(it),Tt&&Pt({activeIndex:null}),(!Tt||wt)&&Ft(``,G(fu,n.event,void 0,{isItemPress:n.reason===lu})))),t||Rt(i()),nt(t),!t&&Tt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(se(!0),ce(!1),le===`onBlur`))){let e=u===`none`?$e:Ye;ue.commit(e)}}),Bt=q((e,t)=>{a?.(e,t),!t.isCanceled&&(Xe(e),(u===`none`&&Oe.current&&N||We&&!ft.state.inputInsidePopup)&&Ft(xe(e),G(t.reason,t.event)))}),Vt=q((e,t)=>{let n=_l(e),r=Ie.current??e;Ie.current=null;let i=G(lu,r),a=gl(n,`a`)?.getAttribute(`href`);if(a)a.startsWith(`#`)&&zt(!1,i);else if(Ue){let e=Array.isArray(Ye)?Ye:[],n=Vb(e,t,A),r=n?Kb(e,t,A):[...e,t];if(Bt(r,i),i.isCanceled||!(ke.current&&ke.current.value.trim()!==``))return;if(ft.state.inputInsidePopup){Ft(``,G(fu,i.event,void 0,{isItemPress:!0}));let e=Re.current;e&&!n&&(e.toggledValue=t)}else zt(!1,i)}else{if(Bt(t,i),i.isCanceled)return;zt(!1,i)}}),Ht=q(()=>{let e=ue.inputRef.current?.form??ft.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Ut=q(()=>{if(gt?.(!1),Se(!1),we(null),Pt(u===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ue&&ke.current&&ke.current.value!==``&&!Ne.current&&Ft(``,G(fu)),We){if(ft.state.inputInsidePopup)ke.current&&ke.current.value!==``&&Ft(``,G(fu));else{let e=xe(Ye);ke.current&&ke.current.value!==e&&Ft(e,G(e===``?fu:iu))}}}),Wt=H.useMemo(()=>wt&&yt?{current:gl(yt,`[role="dialog"]`)}:Oe,[wt,yt]),{mounted:Gt,transitionStatus:Kt,forceUnmount:qt}=Jp({open:tt,ref:Wt,preventUnmountOnClose:Lt,setPreventUnmountOnClose:Rt,onUnmount:Ut});H.useImperativeHandle(e.actionsRef,()=>({unmount:qt,close:()=>zt(!1,G(Su))}),[qt,zt]),U(function(){let e=Te.current!==null&&Ce===null;if(Te.current=Ce,tt&&(!e||!Ke)||(tt||(Be.current=null),u===`none`))return;let t=Ke?dt:ze.current;Pt({selectedIndex:Wb(t,Ye,A,Ue)})},[tt,Ce,Ye,u,Ue,Ke,dt,A,Pt]),U(()=>{he&&(ze.current=dt,Ee.current.length=dt.length)},[he,dt]),U(()=>{!tt&&Re.current?.hasQuery&&(Re.current=null)},[tt]),U(()=>{if(!tt&&wt&&Wt.current){Re.current=null;return}let e=Ke||qe?dt:ze.current,t=Re.current;if(t){let n=tt||wt||ft.state.positionerElement?.hidden===!1;if(t.hasQuery){let t=ke.current;!Je||String($e).trim()===``||wt&&Je!==`always`&&(!t||hl(t.ownerDocument)!==t)?Re.current=null:n&&(e[0]!==void 0||!Ke&&!qe)&&(ft.set(`activeIndex`,0),Re.current=null)}else if(String($e).trim()===``&&(Re.current=null,n)){let e=t.selection;Je===`always`&&!e&&ft.state.selectionMode===`none`&&ft.set(`activeIndex`,0),queueMicrotask(()=>{if(!ft.state.open&&(!ft.state.inline||Wt.current)||ke.current&&ke.current.value.trim()!==``)return;let n=ft.state.selectedValue,r=ft.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:ft.state.selectionMode!==`none`&&n!=null){let e=Ke||qe?dt:ze.current,i=Hb(e,t.toggledValue,ft.state.isItemEqualToValue);ft.set(`activeIndex`,i===-1?Wb(e,n,ft.state.isItemEqualToValue,r):i)}else e?ft.set(`activeIndex`,null):Je===`always`&&ft.set(`activeIndex`,0)})}}if(!tt&&!wt)return;let n=ft.state.activeIndex;if(n==null){if(Je===`always`&&e.length>0){ft.set(`activeIndex`,0);return}Nt(void 0,-1,iu);return}if(n>=e.length){Nt(void 0,-1,iu),ft.set(`activeIndex`,null);return}let r=e[n],i=Le.current.value,a=i!==Ox&&zb(r,i,ft.state.isItemEqualToValue);Le.current.index===n&&a||Nt(r,n,iu)},[_t,Je,Nt,qe,Ke,dt,wt,tt,Wt,ft,$e]),U(()=>{ie(u===`none`?String($e)!==``:Ue?Array.isArray(Ye)&&Ye.length>0:Ye!=null)},[ie,u,$e,Ye,Ue]),H.useEffect(()=>{Ke&&Je&&dt.length===0&&Pt({activeIndex:null})},[Ke,Je,dt.length,Pt]);function Jt(){tt&&it!==``&&it!==String(Qe)&&!Dt&&Se(!0)}function Yt(){tt&&Ce!==null&&It(!1)}let Xt=!1;function Zt(){!Xt&&$e!==at&&(Xt=!0,Ft(at,G(iu)))}function Qt(){u!==`none`&&(te(He),ne(Bb(Ye,re.initialValue,A)),ue.change(Ye),We&&!Ge&&!Tt&&Zt())}function $t(){We&&!Ge&&!Tt&&!z&&Zt()}function en(){u===`none`&&(te(He),ne($e!==re.initialValue),ue.change($e))}Tx(it,Jt),Tx(tt,Yt),Tx(Ye,Qt),Tx(at,$t),Tx(he,$t),Tx($e,en);let tn=Nm({open:wt?!0:tt,onOpenChange:zt,elements:{reference:Tt?xt:St,floating:yt}}),nn=v?`grid`:`listbox`,rn=tt||wt,an=rn?`true`:`false`,on=H.useMemo(()=>{let e=St?.tagName===`INPUT`,t=St==null||e,n=t||rn,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=an,r[`aria-haspopup`]=nn,r[`aria-controls`]=rn?bt?.id:void 0,r[`aria-autocomplete`]=h?`none`:I),{reference:r,floating:{role:`presentation`}}},[St,rn,an,nn,bt?.id,I,h]),sn=Pp(tn,{enabled:!Ve&&C,event:`mousedown-only`,toggle:!1,touchOpenDelay:Tt?0:100,reason:pu}),cn=Bp(tn,{enabled:!Ve&&!wt,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:wt?!0:void 0,outsidePress(e){let t=_l(e);return!W(xt,t)&&!W(Fe.current,t)&&!W(Pe.current,t)&&!W(Ct,t)}}),ln=Xm(tn,{enabled:!Ve,id:fe,listRef:Ee,activeIndex:_t,selectedIndex:vt,virtual:!0,loopFocus:D,allowEscape:D&&!Je,focusItemOnOpen:z||u===`none`&&!Je?!1:`auto`,focusItemOnHover:E,resetOnPointerLeave:!T,orientation:v?`horizontal`:void 0,rtl:de===`rtl`,disabledIndices:pc,grid:v?Tb:void 0,onNavigate(e,t){(t||tt||wt&&e===null)&&Kt!==`ending`&&Pt({activeIndex:e,type:Eb(t),event:t?.nativeEvent})}}),un=H.useMemo(()=>Pf(ln.reference,{onKeyDown(e){v&&ft.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},cn.reference,sn.reference,on.reference),[ln.reference,cn.reference,sn.reference,on.reference,v,ft]),dn=H.useMemo(()=>Pf(Yp,cn.floating),[cn.floating]),fn=H.useMemo(()=>Pf(ln.floating,on.floating),[ln.floating,on.floating]),pn=H.useMemo(()=>{let e=ln.item;return{props:e?{...e,onFocus:void 0}:mc,id:fe,selectionMode:u,disabled:Ve,readOnly:h,isItemEqualToValue:A}},[ln.item,fe,u,Ve,h,A]);ft.useContextCallback(`setOpen`,zt),ft.useContextCallback(`setInputValue`,Ft),ft.useContextCallback(`setSelectedValue`,Bt),ft.useContextCallback(`setIndices`,Pt),ft.useContextCallback(`handleSelection`,Vt),ft.useContextCallback(`forceMount`,Mt),ft.useContextCallback(`requestSubmit`,Ht),ft.useContextCallback(`onOpenChangeComplete`,n),wb(()=>{ft.update({inline:M,popupProps:dn,listProps:fn,inputProps:un,triggerProps:At,itemRoot:pn})});let mn={id:fe,selectedValue:Ye,open:tt,mounted:Gt,transitionStatus:Kt,items:_e,inline:M,popupProps:dn,listProps:fn,inputProps:un,triggerProps:At,itemRoot:pn,openMethod:kt,selectionMode:u,name:He,form:p,disabled:Ve,readOnly:h,required:g,grid:v,virtualized:j,openOnInputClick:C,itemToStringLabel:ye,modal:P,autoHighlight:Je,isItemEqualToValue:A,submitOnItemClick:ee,hasInputValue:Ge};U(()=>{ft.update({...mn,inputOwnsFormValue:u===`none`&&(M||!ft.state.inputInsidePopup)})},[ft,...Object.values(mn)]);let hn=Au(_,ue.inputRef),gn=H.useMemo(()=>({query:it,hasItems:Ke,filteredItems:ut,flatFilteredValues:dt}),[it,Ke,ut,dt]),_n=H.useMemo(()=>Array.isArray(pt)?``:$b(pt,k),[pt,k]),vn=Ue&&Array.isArray(Ye)&&Ye.length>0,yn=Ue||u===`none`&&Et?void 0:He,bn=H.useMemo(()=>!Ue||!Array.isArray(Ye)||!He?null:Ye.map(e=>{let t=$b(e,k);return(0,K.jsx)(`input`,{type:`hidden`,form:p,name:He,value:t,disabled:Ve},t)}),[Ue,Ye,p,He,k,Ve]),xn=(0,K.jsxs)(H.Fragment,{children:[e.children,(0,K.jsx)(`input`,{...ue.getValidationProps(Ve,{onFocus(){Tt?xt?.focus():(ke.current||xt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Ve||h)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=G(iu,e.nativeEvent),i=()=>ze.current.findIndex(e=>$b(e,k).toLowerCase()===n||xe(e).toLowerCase()===n);function a(){if(Ue)return;if(u===`none`){Ft(t,r);return}let e=i();e===-1&&(e=ze.current.findIndex((e,t)=>{let r=De.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:ze.current[e];a!=null&&Bt?.(a,r)}We&&(Mt(),he&&i()===-1&&ft.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:fe&&yn==null?`${fe}-hidden-input`:void 0,form:p,name:yn,autoComplete:L,disabled:Ve,required:g&&!vn,readOnly:h,value:_n,ref:hn,style:yn?Xu:Yu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),bn]});return(0,K.jsx)(Db.Provider,{value:ft,children:(0,K.jsx)(Ob.Provider,{value:tn,children:(0,K.jsx)(Ab.Provider,{value:Ke,children:(0,K.jsx)(kb.Provider,{value:gn,children:(0,K.jsx)(jb.Provider,{value:$e,children:xn})})})})})}function Mx(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,K.jsx)(jx,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function Nx(e,t){let n=hg(e);return U(()=>(t(n),()=>{t(e=>e===n?void 0:e)}),[n,t]),n}function Px(e={}){let{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:a}=e,{controlId:o,setLabelId:s}=gx(),c=Nx(t,q(e=>{s(e),i?.(e)})),l=o??n;function u(e){if(a){a(e,l);return}if(!l)return;let t=Fx(e.currentTarget,l);Xc(t)&&Ix(t)}function d(e){gl(_l(e.nativeEvent),`button,input,select,textarea`)||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),!r&&u(e))}return r?{id:c,htmlFor:l,onMouseDown:d}:{id:c,onClick:d,onPointerDown(e){e.preventDefault()}}}function Fx(e,t){let n=e.getRootNode();for(;Zc(n);){let e=n.getElementById(t);if(e)return e;n=n.host.getRootNode()}return qu(e).getElementById(t)}function Ix(e){e.focus({focusVisible:!0})}function Lx(e){return e==null?void 0:`${e}-label`}function Rx(e,t){return e??t}var zx=`data-popup-side`,Bx=`data-list-empty`,Vx={...Bl,...cx,popupSide:e=>e?{[zx]:e}:null,listEmpty:e=>e?{[Bx]:``}:null};function Hx(e,t,n){let{setFocused:r,focusOwnerRef:i}=dx(),a=q(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return U(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}var Ux=H.createContext(void 0);function Wx(){return H.useContext(Ux)}var Gx=H.createContext(void 0);function Kx(e){let t=H.useContext(Gx);if(t===void 0&&!e)throw Error(gc(21));return t}var qx=H.forwardRef(function(e,t){let n=Mb(),{buttonRef:r,getButtonProps:i}=$_({native:!1}),a=Au(t,r);function o(e){n.context.setOpen(!1,G(uu,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,K.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:Xu})});function Jx(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function Yx(){return Pb().filteredItems.length===0}function Xx(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function Zx(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var Qx=H.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:l,setTouched:u,validationMode:d,validation:f}=dx(),{labelId:p}=gx(),m=Wx(),h=!!Kx(!0),g=Mb(),_=Fb(),v=kg(),y=g.useState(`required`),b=g.useState(`disabled`),x=g.useState(`readOnly`),S=g.useState(`name`),C=g.useState(`form`),w=g.useState(`selectionMode`),T=g.useState(`autoHighlight`),E=g.useState(`inputProps`),D=g.useState(`triggerProps`),O=g.useState(`open`),k=g.useState(`mounted`),A=g.useState(`selectedValue`),j=g.useState(`id`),M=g.useState(`inline`),N=g.useState(`modal`),P=!!T,F=Jx(g),I=l||b||i,L=Yx(),R=Hx(I,g.context.inputRef),ee=h||M,te=!ee||N,ne=hg(a??(ee?void 0:j)),re=h?ox:c,[ie,ae]=H.useState(null),oe=H.useRef(!1),se=H.useRef(null);U(()=>{O||(se.current=null)},[O]);let ce=w===`none`&&!h,le=q(e=>{let t=h||g.state.inline;t&&!g.state.hasInputValue&&g.context.setInputValue(``,G(iu)),g.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ce})}),ue=h?s:f.getValidationProps(I,s);function de(e){g.context.setIndices({activeIndex:null,selectedIndex:null,type:Eb(e),event:e})}let fe={...re,open:O,disabled:I,readOnly:x,popupSide:F,listEmpty:L};function pe(e){if(!m)return;let t,n=m.chipsRef.current.length,[r]=Xx(v);return e.key===r&&(e.currentTarget.selectionStart??0)===0&&A.length>0&&(e.preventDefault(),t=n>0?n-1:void 0),t}let me=qf(`input`,e,{state:fe,ref:[t,g.context.inputRef,le],props:[E,D,{value:ie??_,"aria-readonly":x||void 0,"aria-required":y||void 0,"aria-labelledby":p,disabled:I,readOnly:x,required:w===`none`?y:void 0,form:C,...ce&&S&&{name:S},id:ne,onFocus(){if(R(!0),!M)return;let e=se.current;se.current=null,e!=null&&Object.hasOwn(g.context.valuesRef.current,e)&&g.context.setIndices({activeIndex:e})},onBlur(){u(!0),R(!1);let e=g.state.activeIndex;if(M&&e!==null&&T!==`always`&&(se.current=e,g.context.setIndices({activeIndex:null})),d===`onBlur`){let e=w===`none`?_:A;f.commit(e)}},onCompositionStart(e){jc||(oe.current=!0,ae(e.currentTarget.value))},onCompositionEnd(e){oe.current=!1;let t=e.currentTarget.value;ae(null),g.context.setInputValue(t,G(du,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=oe.current||!r;function a(e){!x&&!I&&e&&i&&(g.context.setOpen(!0,G(du,t)),P||de(t))}if(oe.current){let n=e.currentTarget.value;ae(n),n===``&&!g.state.openOnInputClick&&!g.state.inputInsidePopup&&g.context.setOpen(!1,G(fu,t));let r=n.trim(),i=P&&r!==``;a(r),O&&g.state.activeIndex!==null&&!i&&de(t);return}let o=G(du,t);if(g.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=G(fu,t);s&&!g.state.inputInsidePopup&&(w===`single`&&g.context.setSelectedValue(null,c),g.state.openOnInputClick||g.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),O&&g.state.activeIndex!==null&&!P&&de(t)},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(I||x){x&&e.key===`Enter`&&O&&g.state.activeIndex!==null&&Rc(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=v===`rtl`;if(e.key===`Home`){Rc(e);let n=Fc&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){Rc(e);let i=Fc&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!k&&e.key===`Escape`){let t=w===`multiple`&&Array.isArray(A)?A.length===0:A===null,n=G(hu,e.nativeEvent),r=w===`multiple`?[]:null;g.context.setInputValue(``,n),g.context.setSelectedValue(r,n),t||g.state.inline||n.isPropagationAllowed||e.stopPropagation();return}if(m&&e.key===`Backspace`&&t.value===``&&Array.isArray(A)&&A.length>0){let t=m.chipsRef.current.length,n=t>0?t-1:A.length-1,r=A.filter((e,t)=>t!==n);de(e.nativeEvent),g.context.setSelectedValue(r,G(iu,e.nativeEvent));return}let i=pe(e);if(i!==void 0&&m?.chipsRef.current[i]?.focus(),e.which!==229&&e.key===`Enter`&&O){let t=g.state.activeIndex,n=e.nativeEvent;if(t===null){if(M)return;g.context.setOpen(!1,G(iu,n));return}Rc(e),Zx(g,t,n)}}},ue],stateAttributesMapping:Vx}),he=h?(0,K.jsx)(ux.Provider,{value:lx,children:me}):me;return(0,K.jsxs)(H.Fragment,{children:[O&&te&&(0,K.jsx)(qx,{ref:g.context.startDismissRef}),he]})});function $x(e,t,n,r){if(e.baseUIHandlerPrevented)return;let i=_l(e.nativeEvent),a=Yc(i)?i:null;(a===e.currentTarget||!r?.(a)&&!Jl(a))&&(e.preventDefault(),!n&&(t.context.inputRef.current?.focus(),t.state.openOnInputClick&&t.context.setOpen(!0,G(pu,e.nativeEvent))))}var eS=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{state:o}=dx(),s=Mb(),c=s.useState(`open`),l=s.useState(`disabled`),u=s.useState(`readOnly`),d=s.useState(`hasSelectedValue`),f=s.useState(`selectionMode`),p=Jx(s),m=l,h=Yx(),g=f!==`none`&&!d,_={...o,open:c,disabled:m,readOnly:u,popupSide:p,listEmpty:h,placeholder:g};return qf(`div`,e,{ref:[t,q(e=>{s.set(`inputGroupElement`,e)})],props:[{role:`group`,onMouseDown(e){$x(e,s,m,e=>W(s.context.chipsContainerRef.current,e))}},a],state:_,stateAttributesMapping:Vx})}),tS=5;function nS(e,t){let n=rS(t);return e.clientX>=n.left-tS&&e.clientX<=n.right+tS&&e.clientY>=n.top-tS&&e.clientY<=n.bottom+tS}function rS(e){let t=e.getBoundingClientRect(),n=Kc(e);if(Lc)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var iS=H.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,validationMode:f,validation:p}=dx(),{labelId:m}=gx(),h=Mb(),g=h.useState(`selectionMode`),_=h.useState(`disabled`),v=h.useState(`readOnly`),y=h.useState(`required`),b=h.useState(`positionerElement`),x=h.useState(`listElement`),S=h.useState(`popupId`),C=h.useState(`triggerProps`),w=h.useState(`inputInsidePopup`),T=h.useState(`id`),E=h.useState(`labelId`),D=h.useState(`open`),O=h.useState(`selectedValue`),k=h.useState(`activeIndex`),A=h.useState(`selectedIndex`),j=h.useState(`hasSelectedValue`),M=Nb(),N=Fb(),P=Sc(),F=u||_||a,I=Yx(),L=Jx(h),R=H.useRef(null),ee=Hx(F,R);_x({id:w?o:void 0});let te=w?o??T:o,ne=Rx(m,E),re;D&&w?re=S??vx(T):D&&(re=x?.id);let ie=H.useRef(``);function ae(e){ie.current=e.pointerType}let{reference:oe}=Zm(M,{enabled:!D&&!v&&!_&&g===`single`,listRef:h.context.labelsRef,activeIndex:k,selectedIndex:A,onMatch(e){let t=h.context.valuesRef.current[e];t!==void 0&&h.context.setSelectedValue(t,G(iu))}}),{reference:se}=Pp(M,{enabled:!_,event:`mousedown`}),{buttonRef:ce,getButtonProps:le}=$_({native:i,disabled:F}),ue={...l,readOnly:v,open:D,disabled:F,popupSide:L,listEmpty:I,placeholder:g!==`none`&&!j};return qf(`button`,e,{ref:[t,ce,R,q(e=>{h.set(`triggerElement`,e)})],state:ue,props:[C,se,oe,{id:te,tabIndex:w?0:-1,role:w?`combobox`:void 0,"aria-expanded":D,"aria-haspopup":w?`dialog`:`listbox`,"aria-controls":re,"aria-required":w&&y||void 0,"aria-readonly":w&&v||void 0,"aria-labelledby":ne,onPointerDown:ae,onPointerEnter:ae,onFocus(){ee(!0),!F&&P.start(0,h.context.forceMount)},onBlur(e){if(!W(b,e.relatedTarget)&&(d(!0),ee(!1),f===`onBlur`)){let e=g===`none`?N:O;p.commit(e)}},onMouseDown(e){if(F||(w||M.set(`domReferenceElement`,e.currentTarget),h.context.forceMount(),ie.current!==`touch`&&(h.context.inputRef.current?.focus(),w||e.preventDefault()),D))return;let t=qu(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=_l(e),r=h.state.positionerElement,i=h.state.listElement;W(t,n)||W(r,n)||W(i,n)||nS(e,t)||h.context.setOpen(!1,G(yu,e))}w&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(Rc(e),h.context.setOpen(!0,G(gu,e.nativeEvent)),h.context.inputRef.current?.focus())}},p.getValidationProps(F,c),le],stateAttributesMapping:Vx})}),aS=H.createContext(null);function oS(){return H.useContext(aS)}function sS(e){let{children:t,items:n}=e,r=H.useMemo(()=>({items:n}),[n]);return(0,K.jsx)(aS.Provider,{value:r,children:t})}function cS(e){let{children:t}=e,{filteredItems:n}=Pb(),r=oS(),i=r?r.items:n;return(0,K.jsx)(H.Fragment,{children:i.map(t)})}var lS=H.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function uS(){return H.useContext(lS)}function dS(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=q(i),[,o]=H.useState(0),s=ic(pS).current,c=ic(fS).current,l=H.useRef(0),u=H.useRef(!0),d=H.useRef(null),f=H.useRef(null),p=q(()=>{u.current||(u.current=!0,o(e=>e+1))}),m=q((e,t)=>{c.set(e,t),p()}),h=q(e=>{c.delete(e),p()}),g=q(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!gS(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&_S(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=hS(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=q(()=>{let[e,t]=mS(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});U(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),U(()=>{u.current&&v()}),U(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=q(e=>(s.add(e),()=>{s.delete(e)})),b=H.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,K.jsx)(lS.Provider,{value:b,children:t})}function fS(){return new Map}function pS(){return new Set}function mS(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>_S(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function hS(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function gS(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function _S(e,t){return e.nextElementSibling===t?-1:t.nextElementSibling===e?1:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var vS=H.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=Mb(),l=Nb(),u=!!Kx(!0),{filteredItems:d,hasItems:f}=Pb(),p=c.useState(`selectionMode`),m=c.useState(`grid`),h=c.useState(`readOnly`),g=c.useState(`listProps`),_=c.useState(`virtualized`),v=c.useState(`forceMounted`),y=p===`multiple`,b=d.length===0,x=q(e=>{c.set(`positionerElement`,e)}),S=q(e=>{c.set(`listElement`,e)}),C=H.useMemo(()=>typeof o==`function`?n||=(0,K.jsx)(cS,{children:o}):o,[o]),w={empty:b},T=l.useState(`floatingId`),E=qf(`div`,e,{state:w,ref:[t,S,u?null:x],props:[g,{children:C,tabIndex:-1,id:T,role:m?`grid`:`listbox`,"aria-multiselectable":y?`true`:void 0,"aria-readonly":!m&&h?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;Rc(e),Zx(c,t,e.nativeEvent)}}},s]});if(_)return E;let D=f&&!v?void 0:c.context.labelsRef;return(0,K.jsx)(dS,{elementsRef:c.context.listRef,labelsRef:D,children:E})}),yS=`⁠`;function bS(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function xS(e=!0){let t=Sc(),n=H.useRef(null);return H.useEffect(()=>{if(!e||kc)return;let r=n.current;if(r==null)return;let i=bS(r);if(i==null)return;let a=i.data,o=`${a}${yS}`;return i.nodeValue=o,t.start(200,()=>{i.nodeValue===o&&(i.nodeValue=a)}),()=>{t.clear(),i.nodeValue===o&&(i.nodeValue=a)}},[e,n,t]),n}var SS=H.createContext(void 0);function CS(){let e=H.useContext(SS);if(e===void 0)throw Error(gc(20));return e}var wS=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Mb(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,K.jsx)(SS.Provider,{value:n,children:(0,K.jsx)(mp,{ref:t,...r})}):null}),TS=H.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,K.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),ES={},DS={},OS=``;function kS(e,t){return Qc(e)?e:t}function AS(e,t,n){return/hidden|clip/.test(e.getComputedStyle(kS(t,n)).overflowY)}function jS(e){if(typeof document>`u`)return!1;let t=qu(e);return Kc(t).innerWidth-t.documentElement.clientWidth>0}function MS(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=qu(e),n=t.documentElement,r=t.body,i=kS(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function NS(e){let t=qu(e),n=t.documentElement,r=t.body,i=kS(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function PS(e){let t=qu(e),n=t.documentElement,r=t.body,i=Kc(n),a=0,o=0,s=!1,c=Gu.create();if(Pc&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,ES={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},OS=n.style.scrollBehavior,DS={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=kS(n,r);s=MS(e),s?(n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`):(Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`)}function u(){Object.assign(n.style,ES),Object.assign(r.style,DS),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=OS)}function d(){u(),c.request(l)}l();let f=Ou(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var FS=new class{lockCount=0;restore=null;timeoutLock=xc.create();timeoutUnlock=xc.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=qu(e),n=t.documentElement,r=t.body,i=Kc(n);if(AS(i,n,r)){let t=new i.MutationObserver(()=>{AS(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=kc||!jS(e);this.restore=a?NS(e):PS(e)}};function IS(e=!0,t=null){U(()=>{if(e)return FS.acquire(t)},[e,t])}var LS=20;function RS(e,t,n,r){let[i,a]=H.useState(!1);U(()=>{if(!e||!t||n==null){a(!1);return}let r=qu(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-LS)},[e,t,n]),IS(e&&(!t||i),r)}var zS=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=op,style:g,..._}=e,v=Mb(),y=Nb(),b=CS(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=Yx(),M=Ug({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});RS(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};U(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=q(e=>{v.set(`positionerElement`,e)}),F=qg(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,K.jsxs)(Gx.Provider,{value:M,children:[C&&x&&(0,K.jsx)(TS,{inert:Zg(!S),cutout:O??D??E}),F]})}),BS={...Vl,...Ol},VS=H.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=Mb(),l=Kx(),u=Nb(),d=c.useState(`mounted`),f=c.useState(`open`),p=c.useState(`openMethod`),m=c.useState(`popupProps`),h=c.useState(`transitionStatus`),g=c.useState(`inputInsidePopup`),_=c.useState(`inputElement`),v=c.useState(`modal`),y=c.useState(`id`),b=Yx(),x=s.id??(g?vx(y):void 0);U(()=>(c.set(`popupId`,c.context.popupRef.current?.id||x),()=>{c.set(`popupId`,void 0)}),[c,x]),qp({open:f,ref:c.context.popupRef,onComplete(){f&&c.context.onOpenChangeComplete(!0)}});let S=qf(`div`,e,{state:{open:f,side:l.side,align:l.align,anchorHidden:l.anchorHidden,transitionStatus:h,empty:b},ref:[t,c.context.popupRef],props:[m,{id:x,role:g?`dialog`:`presentation`,onFocus(e){let t=_l(e.nativeEvent);p!==`touch`&&(W(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},Kg(h),s],stateAttributesMapping:BS}),C=a===void 0?g?e=>e===`touch`?c.context.popupRef.current:_:!1:a,w;w=o??(g?void 0:!1);let T=!g||v;return(0,K.jsx)(Np,{context:u,disabled:!d,modal:T,openInteractionType:p,initialFocus:C,returnFocus:w,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,K.jsxs)(H.Fragment,{children:[S,T&&(0,K.jsx)(qx,{ref:c.context.endDismissRef})]})})}),HS=H.createContext(void 0);function US(){let e=H.useContext(HS);if(e===void 0)throw Error(gc(18));return e}var WS=H.forwardRef(function(e,t){let{render:n,className:r,style:i,items:a,...o}=e,s=Mb().useState(`grid`),[c,l]=H.useState(),u=H.useMemo(()=>({labelId:c,setLabelId:l,items:a}),[c,l,a]),d=qf(`div`,e,{ref:t,props:[{role:s?`rowgroup`:`group`,"aria-labelledby":c},o]}),f=(0,K.jsx)(HS.Provider,{value:u,children:d});return a?(0,K.jsx)(sS,{items:a,children:f}):f}),GS=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=US(),c=hg(a);return U(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),qf(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})});function KS(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=uS(),u=H.useRef(-1),[d,f]=H.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=H.useRef(null),h=H.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return U(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var qS=H.createContext(void 0);function JS(){let e=H.useContext(qS);if(!e)throw Error(gc(19));return e}var YS=H.createContext(!1);function XS(){return H.useContext(YS)}function ZS(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=H.useRef(null),m=KS({guess:!0,index:l,textRef:p}),h=Mb(),g=XS(),_=Ib(),{props:v,id:y,selectionMode:b,disabled:x,readOnly:S,isItemEqualToValue:C}=h.useState(`itemRoot`),w=x||u,T=b!==`none`,E=l??i??m.index,D=E!==-1,O=h.useState(`isActive`,E),k=h.useState(`isSelected`,c),A=H.useRef(null),j=y!=null&&D?`${y}-${E}`:void 0,M=k&&T;U(()=>{if(!D||!r&&l==null)return;let e=h.context.listRef.current;return e[E]=A.current,()=>{delete e[E]}},[D,r,E,l,h]),U(()=>{if(!D||_)return;let e=h.context.valuesRef.current;return e[E]=c,()=>{delete e[E]}},[D,_,E,c,h]),U(()=>{if(!D||_)return;let e=h.state.selectedValue,t=h.state.selectedIndex;h.state.selectionMode===`multiple`&&Array.isArray(e)?t=Gb(E,c,h.context.valuesRef.current,e,C,t):zb(c,e,C)&&(t=E),h.set(`selectedIndex`,t)},[D,_,h,E,c,C]);let{getButtonProps:N,buttonRef:P}=$_({disabled:w,focusableWhenDisabled:!0,native:d,composite:!0}),F={disabled:w,selected:M,highlighted:O};function I(e){function t(){h.context.handleSelection(e,c)}h.state.submitOnItemClick?(lp.flushSync(t),h.context.requestSubmit()):t()}let L={id:j,role:g?`gridcell`:`option`,"aria-selected":T?M:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){w||S||I(e.nativeEvent)},onMouseUp(e){let t=h.context.pointerDownItemRef.current===e.currentTarget;h.context.pointerDownItemRef.current=null,!(w||S||e.button!==0||t||!O)&&I(e.nativeEvent)}},R=qf(`div`,t,{ref:[P,n,m.ref,A],state:F,props:[v,L,f,N]}),ee=H.useMemo(()=>({selected:M,textRef:p}),[M,p]);return(0,K.jsx)(qS.Provider,{value:ee,children:R})}function QS(e){let{componentProps:t,forwardedRef:n}=e,r=Mb().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Pb(),a=Hb(i,t.value??null,r);return(0,K.jsx)(ZS,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var $S=H.memo(H.forwardRef(function(e,t){let n=Mb().useState(`virtualized`);return n&&e.index==null?(0,K.jsx)(QS,{componentProps:e,forwardedRef:t}):(0,K.jsx)(ZS,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),eC=H.memo(H.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a,selected:o,...s}=e,c=H.useRef(null),{transitionStatus:l,setMounted:u}=Hp(o),d=qf(`span`,e,{ref:[t,c],state:{selected:o,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:Ol});return qp({batch:!0,enabled:!o,open:o,ref:c,onComplete(){o||u(!1)}}),d})),tC=H.forwardRef(function(e,t){let{selected:n}=JS();return e.keepMounted||n?(0,K.jsx)(eC,{...e,selected:n,ref:t}):null}),nC=H.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=Pb(),c=Mb(),l=xS(),u=s.length===0?a:null;return qf(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})}),rC={field:`_field_7r9q3_7`,label:`_label_7r9q3_16`,control:`_control_7r9q3_28`,group:`_group_7r9q3_29`,value:`_value_7r9q3_74`,input:`_input_7r9q3_87`,hint:`_hint_7r9q3_103`,inputButton:`_inputButton_7r9q3_124`,icon:`_icon_7r9q3_145`,empty:`_empty_7r9q3_155`,toggle:`_toggle_7r9q3_168`,box:`_box_7r9q3_179`,mark:`_mark_7r9q3_211`,switch:`_switch_7r9q3_221`,thumb:`_thumb_7r9q3_256`,visuallyHidden:`_visuallyHidden_7r9q3_303`},iC=e=>e.label,aC=(e,t)=>e.value===t.value,oC=({label:e,options:t,value:n,onChange:r,placeholder:i=``,empty:a,disabled:o=!1})=>{let s=(0,H.useId)();return(0,K.jsxs)(Mx,{autoHighlight:!0,disabled:o,isItemEqualToValue:aC,itemToStringLabel:iC,items:t,onValueChange:e=>{r(e?.value??null)},value:t.find(e=>e.value===n)??null,children:[(0,K.jsxs)(`div`,{className:rC.field,children:[(0,K.jsx)(`label`,{className:rC.label,htmlFor:s,children:e}),(0,K.jsxs)(eS,{className:rC.group,children:[(0,K.jsx)(Qx,{"aria-label":e,className:rC.input,id:s,placeholder:i}),(0,K.jsx)(iS,{"aria-label":`Show ${e} list`,className:rC.inputButton,children:(0,K.jsx)(ly,{})})]})]}),(0,K.jsx)(wS,{children:(0,K.jsx)(zS,{align:`start`,className:a_.positioner,sideOffset:4,children:(0,K.jsxs)(VS,{className:a_.popup,children:[(0,K.jsx)(nC,{className:rC.empty,children:a}),(0,K.jsx)(vS,{"aria-label":e,children:e=>(0,K.jsxs)($S,{className:a_.item,value:e,children:[(0,K.jsx)(`span`,{children:e.label}),(0,K.jsx)(tC,{className:rC.icon,children:(0,K.jsx)(cy,{})})]},e.value)})]})})})]})},sC=({text:e,label:t,resultClass:n})=>{let[r,i]=(0,H.useState)({words:``,count:0}),a=e=>{i(({count:t})=>({words:e,count:t+1}))},o=async()=>{try{await navigator.clipboard.writeText(e),a(`Copied.`)}catch{a(`Copy failed: select the text instead.`)}};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`output`,{className:n,children:(0,K.jsx)(`span`,{children:r.words},r.count)}),(0,K.jsx)(Sb,{label:t,onClick:()=>{o()},children:(0,K.jsx)(hy,{})})]})},cC={field:`_field_10412_10`,body:`_body_10412_32`,caption:`_caption_10412_39`,command:`_command_10412_53`,copy:`_copy_10412_69`,result:`_result_10412_78`},lC=({command:e,label:t,caption:n})=>(0,K.jsxs)(`div`,{className:cC.field,children:[(0,K.jsxs)(`div`,{className:cC.body,children:[n===void 0?null:(0,K.jsx)(`span`,{className:cC.caption,children:n}),(0,K.jsx)(`code`,{className:cC.command,children:e})]}),(0,K.jsx)(`span`,{className:cC.copy,children:(0,K.jsx)(sC,{label:t??`Copy ${e}`,resultClass:cC.result,text:e})})]});function uC({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=H.useState(0),[d,f]=H.useState(0),p=l===0,m=Bp(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=_l(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||W(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return IS(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{(e.select(`open`)||e.select(`mounted`))&&(u(t),f(n))}),U(()=>{!r&&!i&&(u(0),f(0))},[r,i]),U(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),sm(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var dC=H.createContext(void 0);function fC(e){let t=H.useContext(dC);if(!e&&t===void 0)throw Error(gc(27));return t}var pC={...jm,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},mC=class extends Sm{constructor(e,t,n){let r=new lm,i=hC(e,r,t,n);super(i,gC(r),pC)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(tm(this.state,e,t.trigger)))}};function hC(e,t,n,r=!1){return{...Tm(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function gC(e){return{popupRef:H.createRef(),backdropRef:H.createRef(),internalBackdropRef:H.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function _C(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=fC(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Zp((e,t)=>new mC({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);cm(b,x),am(b);let{forceUnmount:w}=om(x,b);H.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,G(Su))}),[w,b]);let T=x||S||u!=null;return(0,K.jsxs)(dC.Provider,{value:b,children:[u&&(0,K.jsx)(Qp,{handle:u,store:b}),T&&(0,K.jsx)(uC,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}function vC(e){return _C(`alert-dialog`,e)}var yC=H.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=fC(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return qf(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Hl,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),bC=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=fC(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=$_({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,G(uu,e.nativeEvent))}return qf(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),xC=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=fC(),c=hg(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),qf(`p`,e,{ref:t,props:[{id:c},o]})}),SC=H.createContext(void 0);function CC(){let e=H.useContext(SC);if(e===void 0)throw Error(gc(26));return e}var wC=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),TC=`--nested-dialogs`,EC=`data-nested-dialog-open`,DC={...Vl,...Ol,nestedDialogOpen(e){return e?{[EC]:``}:null}},OC=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=fC(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);CC(),qp({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Xp(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=qf(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Yp,hidden:!m,onKeyDown(e){wC.has(e.key)&&e.stopPropagation()},style:{[TC]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:DC});return(0,K.jsx)(Np,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),kC=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=fC(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,K.jsx)(SC.Provider,{value:n,children:(0,K.jsxs)(mp,{ref:t,...r,children:[a&&o===!0&&(0,K.jsx)(TS,{ref:i.context.internalBackdropRef,inert:Zg(!s)}),e.children]})}):null}),AC=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=fC(),c=hg(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),qf(`h2`,e,{ref:t,props:[{id:c},o]})}),jC=lc(function(e){return _C(`dialog`,e)}),MC={backdrop:`_backdrop_1kwjw_6`,dialog:`_dialog_1kwjw_25`,title:`_title_1kwjw_79`,description:`_description_1kwjw_90`,actions:`_actions_1kwjw_97`,refusal:`_refusal_1kwjw_111`},NC=()=>!0,PC=({open:e,onOpenChange:t,title:n,description:r,children:i,finalFocus:a=NC,initialFocus:o,size:s=`default`})=>(0,K.jsx)(jC,{onOpenChange:e=>{t(e)},open:e,children:(0,K.jsxs)(kC,{children:[(0,K.jsx)(yC,{className:MC.backdrop}),(0,K.jsxs)(OC,{"aria-modal":`true`,className:MC.dialog,"data-modal":``,"data-size":s,finalFocus:a,initialFocus:o??!0,children:[(0,K.jsx)(AC,{className:MC.title,children:(0,K.jsx)(J,{text:n})}),r===void 0?null:(0,K.jsx)(xC,{className:MC.description,children:(0,K.jsx)(J,{text:r})}),i]})]})}),FC=({children:e})=>(0,K.jsx)(`div`,{className:MC.actions,children:e}),IC=({open:e,onOpenChange:t,title:n,description:r,confirm:i,onConfirm:a,pending:o,variant:s=`danger`,cli:c,finalFocus:l=NC,children:u})=>{let[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),h=(0,H.useRef)(null),g=async()=>{let e=a();if(e===void 0){t(!1);return}f(!0),m(null);let n=await e;f(!1),m(n),n===null&&t(!1)};return(0,K.jsx)(vC,{onOpenChange:e=>{d||(e||m(null),t(e))},open:e,children:(0,K.jsxs)(kC,{children:[(0,K.jsx)(yC,{className:MC.backdrop}),(0,K.jsxs)(OC,{"aria-modal":`true`,className:MC.dialog,"data-modal":``,finalFocus:l,initialFocus:h,children:[(0,K.jsx)(AC,{className:MC.title,children:(0,K.jsx)(J,{text:n})}),(0,K.jsx)(xC,{className:MC.description,children:(0,K.jsx)(J,{text:r})}),u,c===void 0?null:(0,K.jsx)(lC,{command:c}),p===null?null:(0,K.jsx)(`p`,{className:MC.refusal,role:`alert`,children:(0,K.jsx)(J,{text:p})}),(0,K.jsxs)(`div`,{className:MC.actions,children:[(0,K.jsx)(bC,{disabled:d,ref:h,render:(0,K.jsx)(Y,{focusableWhenDisabled:!0,children:`Cancel`})}),(0,K.jsx)(Y,{disabled:d,focusableWhenDisabled:!0,onClick:()=>{g()},variant:s,children:d?o??i:i})]})]})]})})},LC=Symbol.for(`yaml.alias`),RC=Symbol.for(`yaml.document`),zC=Symbol.for(`yaml.map`),BC=Symbol.for(`yaml.pair`),VC=Symbol.for(`yaml.scalar`),HC=Symbol.for(`yaml.seq`),UC=Symbol.for(`yaml.node.type`),WC=e=>!!e&&typeof e==`object`&&e[UC]===LC,GC=e=>!!e&&typeof e==`object`&&e[UC]===RC,KC=e=>!!e&&typeof e==`object`&&e[UC]===zC,qC=e=>!!e&&typeof e==`object`&&e[UC]===BC,JC=e=>!!e&&typeof e==`object`&&e[UC]===VC,YC=e=>!!e&&typeof e==`object`&&e[UC]===HC;function XC(e){if(e&&typeof e==`object`)switch(e[UC]){case zC:case HC:return!0}return!1}function ZC(e){if(e&&typeof e==`object`)switch(e[UC]){case LC:case zC:case VC:case HC:return!0}return!1}var QC=e=>(JC(e)||XC(e))&&!!e.anchor,$C=Symbol(`break visit`),ew=Symbol(`skip children`),tw=Symbol(`remove node`);function nw(e,t){let n=iw(t);GC(e)?rw(null,e.contents,n,Object.freeze([e]))===tw&&(e.contents=null):rw(null,e,n,Object.freeze([]))}nw.BREAK=$C,nw.SKIP=ew,nw.REMOVE=tw;function rw(e,t,n,r){let i=aw(e,t,n,r);if(ZC(i)||qC(i))return ow(e,r,i),rw(e,i,n,r);if(typeof i!=`symbol`){if(XC(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=rw(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===$C)return $C;else i===tw&&(t.items.splice(e,1),--e)}}else if(qC(t)){r=Object.freeze(r.concat(t));let e=rw(`key`,t.key,n,r);if(e===$C)return $C;e===tw&&(t.key=null);let i=rw(`value`,t.value,n,r);if(i===$C)return $C;i===tw&&(t.value=null)}}return i}function iw(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function aw(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(KC(t))return n.Map?.(e,t,r);if(YC(t))return n.Seq?.(e,t,r);if(qC(t))return n.Pair?.(e,t,r);if(JC(t))return n.Scalar?.(e,t,r);if(WC(t))return n.Alias?.(e,t,r)}function ow(e,t,n){let r=t[t.length-1];if(XC(r))r.items[e]=n;else if(qC(r))e===`key`?r.key=n:r.value=n;else if(GC(r))r.contents=n;else{let e=WC(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}function sw(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function cw(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=cw(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=cw(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=cw(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=cw(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function lw(e,t,n){if(Array.isArray(e))return e.map((e,t)=>lw(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!QC(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var uw=class{constructor(e){Object.defineProperty(this,UC,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!GC(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=lw(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?cw(i,{"":o},``,o):o}},dw=class extends uw{constructor(e){super(LC),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],nw(e,{Node:(e,t)=>{(WC(t)||QC(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(lw(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=fw(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(sw(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function fw(e,t,n){if(WC(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(XC(t)){let r=0;for(let i of t.items){let t=fw(e,i,n);t>r&&(r=t)}return r}if(qC(t)){let r=fw(e,t.key,n),i=fw(e,t.value,n);return Math.max(r,i)}return 1}var pw=e=>!e||typeof e!=`function`&&typeof e!=`object`,mw=class extends uw{constructor(e){super(VC),this.value=e}toJSON(e,t){return t?.keep?this.value:lw(this.value,e,t)}toString(){return String(this.value)}};mw.BLOCK_FOLDED=`BLOCK_FOLDED`,mw.BLOCK_LITERAL=`BLOCK_LITERAL`,mw.PLAIN=`PLAIN`,mw.QUOTE_DOUBLE=`QUOTE_DOUBLE`,mw.QUOTE_SINGLE=`QUOTE_SINGLE`;var hw=`tag:yaml.org,2002:`;function gw(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function _w(e,t,n){if(GC(e)&&(e=e.contents),ZC(e))return e;if(qC(e)){let t=n.schema[zC].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new dw(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=hw+t.slice(2));let l=gw(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new mw(e);return c&&(c.node=t),t}l=e instanceof Map?o[zC]:Symbol.iterator in Object(e)?o[HC]:o[zC]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new mw(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function vw(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return _w(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var yw=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,bw=class extends uw{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>ZC(t)||qC(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(yw(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(XC(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,vw(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(XC(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&JC(i)?i.value:i:XC(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!qC(t))return!1;let n=t.value;return n==null||e&&JC(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return XC(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(XC(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,vw(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},xw=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Sw(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Cw=(e,t,n)=>e.endsWith(`
56
+ `)?Sw(n,t):n.includes(`
57
+ `)?`
58
+ `+Sw(n,t):(e.endsWith(` `)?``:` `)+n,ww=`flow`,Tw=`block`,Ew=`quoted`;function Dw(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Ow(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
59
+ `)n===`block`&&(h=Ow(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
60
+ `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
61
+ `&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Ow(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
62
+ `);r=t,i=t+1,a=e[i]}return r}var kw=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Aw=e=>/^(%|---|\.\.\.)/m.test(e);function jw(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
63
+ `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Mw(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Aw(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
64
+
65
+ `;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
66
+ `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Dw(o,a,Ew,kw(t,!1))}function Nw(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
67
+ `)||/[ \t]\n|\n[ \t]/.test(e))return Mw(e,t);let n=t.indent||(Aw(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Dw(r,n,ww,kw(t,!1))}function Pw(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Mw;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Nw:i&&!t?Mw:n?Nw:Mw}return r(e,t)}var Fw;try{Fw=RegExp(`(^|(?<!
68
+ ))
69
+ +(?!
70
+ |$)`,`g`)}catch{Fw=/\n+(?!\n|$)/g}function Iw({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Pw(n,r);let l=r.indent||(r.forceBlockIndent||Aw(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===mw.BLOCK_FOLDED?!1:t===mw.BLOCK_LITERAL||!jw(n,c,l.length);if(!n)return u?`|
71
+ `:`>
72
+ `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
73
+ `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
74
+ `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
75
+ `&&(p=p.slice(0,-1)),p.replace(Fw,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
76
+ `)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
77
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=kw(r,!0);o!==`folded`&&t!==mw.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=Dw(`${v}${e}${p}`,l,Tw,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function Lw(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
78
+ `)||u&&/[[\]{},]/.test(a))return Pw(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
79
+ `)?Pw(a,t):Iw(e,t,n,r);if(!s&&!u&&i!==mw.PLAIN&&a.includes(`
80
+ `))return Iw(e,t,n,r);if(Aw(a)){if(c===``)return t.forceBlockIndent=!0,Iw(e,t,n,r);if(s&&c===l)return Pw(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Pw(a,t)}return s?d:Dw(d,c,ww,kw(t,!1))}function Rw(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==mw.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=mw.QUOTE_DOUBLE);let c=e=>{switch(e){case mw.BLOCK_FOLDED:case mw.BLOCK_LITERAL:return i||a?Pw(o.value,t):Iw(o,t,n,r);case mw.QUOTE_DOUBLE:return Mw(o.value,t);case mw.QUOTE_SINGLE:return Nw(o.value,t);case mw.PLAIN:return Lw(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function zw(e,t){let n=Object.assign({blockQuote:!0,commentString:xw,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function Bw(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(JC(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function Vw(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(JC(e)||XC(e))&&e.anchor;a&&sw(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Hw(e,t,n,r){if(qC(e))return e.toString(t,n,r);if(WC(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=ZC(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=Bw(t.doc.schema.tags,a);let o=Vw(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):JC(a)?Rw(a,t,n,r):a.toString(t,n,r);return o?JC(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function Uw({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=ZC(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(XC(e)||!ZC(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||XC(e)||(JC(e)?e.type===mw.BLOCK_FOLDED||e.type===mw.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Hw(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Cw(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Cw(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Cw(g,n.indent,l(f))));let _,v,y;ZC(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&JC(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&YC(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=Hw(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
81
+ `:``,v){let e=l(v);S+=`\n${Sw(e,n.indent)}`}x===``&&!n.inFlow?S===`
82
+ `&&y&&(S=`
83
+
84
+ `):S+=`\n${n.indent}`}else if(!p&&XC(t)){let e=x[0],r=x.indexOf(`
85
+ `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
86
+ `)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Cw(g,n.indent,l(y)):h&&i&&i(),g}function Ww(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var Gw=`<<`,Kw={identify:e=>e===Gw||typeof e==`symbol`&&e.description===Gw,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new mw(Symbol(Gw)),{addToJSMap:Jw}),stringify:()=>Gw},qw=(e,t)=>(Kw.identify(t)||JC(t)&&(!t.type||t.type===mw.PLAIN)&&Kw.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Kw.tag&&e.default);function Jw(e,t,n){let r=Xw(e,n);if(YC(r))for(let n of r.items)Yw(e,t,n);else if(Array.isArray(r))for(let n of r)Yw(e,t,n);else Yw(e,t,r)}function Yw(e,t,n){let r=Xw(e,n);if(!KC(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function Xw(e,t){return e&&WC(t)?t.resolve(e.doc,e):t}function Zw(e,t,{key:n,value:r}){if(ZC(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(qw(e,n))Jw(e,t,r);else{let i=lw(n,``,e);if(t instanceof Map)t.set(i,lw(r,i,e));else if(t instanceof Set)t.add(i);else{let a=Qw(n,i,e),o=lw(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Qw(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(ZC(e)&&n?.doc){let t=zw(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),Ww(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function $w(e,t,n){return new eT(_w(e,void 0,n),_w(t,void 0,n))}var eT=class e{constructor(e,t=null){Object.defineProperty(this,UC,{value:BC}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return ZC(n)&&(n=n.clone(t)),ZC(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return Zw(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?Uw(this,e,t,n):JSON.stringify(this)}};function tT(e,t,n){return(t.inFlow??e.flow?rT:nT)(e,t,n)}function nT({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(ZC(i))!d&&i.spaceBefore&&f.push(``),iT(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(qC(i)){let e=ZC(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),iT(n,f,e.commentBefore,d))}d=!1;let s=Hw(i,u,()=>o=null,()=>d=!0);o&&(s+=Cw(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
87
+ `}}return e?(p+=`
88
+ `+Sw(l(e),c),s&&s()):d&&o&&o(),p}function rT({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(ZC(i))i.spaceBefore&&d.push(``),iT(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(qC(i)){let e=ZC(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),iT(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=ZC(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Hw(i,c,()=>a=null);l||=d.length>u||o.includes(`
89
+ `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=Cw(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
90
+ `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function iT({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Sw(t(r),e);n.push(i.trimStart())}}function aT(e,t){let n=JC(t)?t.value:t;for(let r of e)if(qC(r)&&(r.key===t||r.key===n||JC(r.key)&&r.key.value===n))return r}var oT=class extends bw{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(zC,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push($w(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=qC(e)?e:!e||typeof e!=`object`||!(`key`in e)?new eT(e,e?.value):new eT(e.key,e.value);let r=aT(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);JC(r.value)&&pw(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=aT(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=aT(this.items,e)?.value;return(!t&&JC(n)?n.value:n)??void 0}has(e){return!!aT(this.items,e)}set(e,t){this.add(new eT(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)Zw(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!qC(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),tT(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},sT={collection:`map`,default:!0,nodeClass:oT,tag:`tag:yaml.org,2002:map`,resolve(e,t){return KC(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>oT.from(e,t,n)},cT=class extends bw{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(HC,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=lT(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=lT(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&JC(r)?r.value:r}has(e){let t=lT(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=lT(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];JC(r)&&pw(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(lw(e,String(r++),t));return n}toString(e,t,n){return e?tT(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(_w(a,void 0,n))}}return i}};function lT(e){let t=JC(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var uT={collection:`seq`,default:!0,nodeClass:cT,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return YC(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>cT.from(e,t,n)};function dT(e){return typeof e==`bigint`||Number.isInteger(e)}var fT=({value:e})=>JSON.stringify(e),pT=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:fT},{identify:e=>e==null,createNode:()=>new mw(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:fT},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:fT},{identify:dT,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>dT(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:fT}];[sT,uT].concat(pT,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function mT(e,t,n){let{replacer:r}=n,i=new cT(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push($w(o,s,n))}return i}var hT=class e extends cT{constructor(){super(),this.add=oT.prototype.add.bind(this),this.delete=oT.prototype.delete.bind(this),this.get=oT.prototype.get.bind(this),this.has=oT.prototype.has.bind(this),this.set=oT.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(qC(e)?(r=lw(e.key,``,t),i=lw(e.value,r,t)):r=lw(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=mT(e,t,n),i=new this;return i.items=r.items,i}};hT.tag=`tag:yaml.org,2002:omap`;var gT=class e extends oT{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=qC(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new eT(e.key,null):new eT(e,null),aT(this.items,t.key)||this.items.push(t)}get(e,t){let n=aT(this.items,e);return!t&&qC(n)?JC(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=aT(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new eT(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push($w(e,null,n));return i}};gT.tag=`tag:yaml.org,2002:set`;var _T=Symbol(`break visit`),vT=Symbol(`skip children`),yT=Symbol(`remove item`);function bT(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),xT(Object.freeze([]),e,t)}bT.BREAK=_T,bT.SKIP=vT,bT.REMOVE=yT,bT.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},bT.parentCollection=(e,t)=>{let n=bT.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function xT(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=xT(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===_T)return _T;else r===yT&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}var ST=e=>e,CT=ST({id:`aws`,label:`AWS CLI`,program:`aws`,options:{profile:B().optional(),region:B().optional()},args:({profile:e,region:t})=>[...e===void 0?[]:[`--profile`,e],...t===void 0?[]:[`--region`,t]],signedOut:({stderr:e})=>/Unable to locate credentials|ExpiredToken|InvalidClientTokenId|Token has expired|aws sso login|SSO session .* expired/iu.test(e),doctor:async(e,t)=>{if(!(await e(`aws`,[`--version`])).ok)return{name:`aws`,status:`skip`,detail:`optional, not installed (needed only for tool.aws nodes)`};let n=t.AWS_PROFILE,r=n===void 0?``:` (profile ${n})`;return(await e(`aws`,[`sts`,`get-caller-identity`,`--output`,`json`])).ok?{name:`aws`,status:`ok`,detail:`signed in${r}`}:{name:`aws`,status:`warn`,detail:`no valid credentials${r}`,hint:"Run `aws sso login` (or set AWS_PROFILE) yourself to use tool.aws nodes."}}}),wT=e=>{try{return JSON.parse(e)}catch{return}},TT=(e,t)=>typeof e==`object`&&e&&Object.hasOwn(e,t)?Reflect.get(e,t):void 0,ET=e=>e.trim().split(`
91
+ `)[0]??``,DT=(e,t,n,r)=>({id:e,...r,doctor:async i=>{let a=`${t} (${e} driver)`,o=await i(t,[`--version`]),s=r.proven?``:`, unproven: not yet proven on a real session`;return o.ok?{name:a,status:r.proven?`ok`:`skip`,detail:`${ET(o.stdout)}${s}; sign in with \`${n}\` if a session asks`}:{name:a,status:`skip`,detail:`${t} CLI not found${s}`,...r.proven?{hint:`Install ${t} to use the ${e} driver.`}:{}}}});DT(`open-code`,`opencode`,`opencode auth login`,{label:"the `opencode` CLI",proven:!0,onePerCheckout:!1,capabilities:{questions:!0,permissionPrompt:!1,price:!0,midTurnMessages:!1,reportSchema:!1,turnLimit:!0,mcpServers:!0,subagents:!1}}),DT(`command-code`,`cmd`,`cmd login`,{label:"the `cmd` CLI of Command Code",proven:!0,onePerCheckout:!0,capabilities:{questions:!0,permissionPrompt:!1,price:!1,midTurnMessages:!1,reportSchema:!1,turnLimit:!0,mcpServers:!1,subagents:!1}});var OT=[`claude-code`,`open-code`,`command-code`],kT={sdk:`claude-code`,cli:`claude-code`},AT=[ST({id:`gh`,label:`GitHub CLI`,program:`gh`,options:{},args:()=>[],signedOut:({exitCode:e,stderr:t})=>e===4||/\bgh auth login\b/u.test(t),doctor:async e=>{if(!(await e(`gh`,[`--version`])).ok)return{name:`gh`,status:`skip`,detail:`optional, not installed (needed only for tool.gh nodes)`};let t=TT(TT(wT((await e(`gh`,[`auth`,`status`,`--json`,`hosts`])).stdout),`hosts`),`github.com`),n=(Array.isArray(t)?t:[]).find(e=>TT(e,`active`)===!0),r=TT(n,`login`);return TT(n,`state`)!==`success`||typeof r!=`string`?{name:`gh`,status:`warn`,detail:`not logged in to github.com`,hint:"Run `gh auth login` yourself to use tool.gh nodes."}:{name:`gh`,status:`ok`,detail:`logged in as ${r}`}}}),CT,ST({id:`git`,label:`Git`,program:`git`,options:{},args:()=>[],allow:[`add`,`commit`],observe:{fields:[`staged`,`diff`,`head`],read:async e=>{let t=await e([`diff`,`--cached`,`--stat`]),n=await e([`diff`,`--cached`]),r=await e([`rev-parse`,`--verify`,`--quiet`,`HEAD`]);return{staged:t.ok?t.stdout.trimEnd():``,diff:n.ok?n.stdout:``,head:r.ok?r.stdout.trim():``}}},doctor:async e=>{let t=await e(`git`,[`config`,`user.name`]),n=await e(`git`,[`config`,`user.email`]);return t.stdout.trim()===``||n.stdout.trim()===``?{name:`git identity`,status:`warn`,detail:`user.name or user.email is not set (needed only to commit with tool.git)`,hint:"Set them yourself (`git config --global user.name …`) before a tool.git node commits."}:{name:`git identity`,status:`ok`,detail:`user.name and user.email are set`}}}),ST({id:`shell`,label:`Any program`,program:null,options:{},args:()=>[]})],jT=`tool.`,MT={maxParallel:is().int().positive().optional().describe(`Most items running at once. Default: limits.concurrency.`),onFailure:ks([`finish`,`stop`]).optional().describe("When an item fails: `finish` runs every item (default), `stop` starts no more.")},NT={forEach:ys([V({items:ms(us()).min(1).describe(`The list, written here. Each entry is one item.`),...MT}),V({from:B().describe(`Where the list comes from: one path, e.g. {{nodes.plan.output.tasks}}.`),maxItems:is().int().positive().describe(`Most items allowed. A longer list asks whether to stop, run this many, or run all.`),...MT})]).optional().describe("Run this node once per item of a list, with no model turn to fan out or gather. Items are `<id>.0`, `<id>.1`, ….")},PT={lock:B().regex(/\S/u,`a lock needs a name`).describe("The lock this node holds, e.g. `branch:{{inputs.branch}}`. Held from the first node that names it to the last, or the run's end; one run at a time holds it, the others wait. One name per node.").optional()},FT=B().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),IT=ys([ms(ys([B(),is(),cs()])).min(1),ks([`string`,`number`,`integer`,`boolean`])]),LT="`list` takes a map of each item's fields, e.g. `list: { title: string }` (`list: {}` for items of any shape)",RT=V({list:Ds(B(),IT).describe(`The fields each item has, e.g. { title: string }; { } for no shape.`)}).describe(`A list of items, such as a plan's tasks.`),zT=Ds(B(),ys([IT,RT])),BT={env:Ds(FT,B()).optional().describe(`Environment variables for the program. Values are templates, and may read the user's own variables as {{env.NAME}}.`),plainEnv:ms(FT).optional().describe(`Variables read as {{env.NAME}} that are not secret, such as a region: their values are not masked in what programs print.`),output:V({format:js(`json`).describe(`The program's result is JSON, read as output.json: the file at $ORK_OUTPUT if it wrote one, otherwise its stdout.`),schema:zT.optional().describe(`The fields of that JSON a later node relies on, e.g. { state: [OPEN, CLOSED] }. A value outside these fails the node.`)}).optional().describe(`Structured output from the program.`)},VT=B().regex(/^[a-z][a-z0-9_-]*$/u,`node ids are lowercase: letters, digits, '-' and '_'`),HT=e=>{let t=typeof e==`string`&&Object.hasOwn(kT,e)?kT[e]:void 0;return t===void 0?void 0:`driver \`${String(e)}\` was retired; use \`${t}\``},UT=ks(OT,{error:e=>HT(e.input)}),WT=B().min(1),GT=ks([`low`,`medium`,`high`,`xhigh`,`max`]).describe(`Reasoning effort. Default: Claude Code's for the model.`),KT=ks([`worktree`,`continue`,`shared`,`readonly`]),qT=`must be a number above 0`,JT=`must be a whole number above 0`,YT=is(qT).positive(qT),XT=is(JT).int(JT).positive(JT),ZT=V({dayUsd:YT.optional().describe(`Most to spend in a calendar day.`),dayTokens:XT.optional().describe(`Most tokens (input, output, cache-write) to use in a calendar day.`),weekUsd:YT.optional().describe(`Most to spend in a calendar week, from Monday.`),monthUsd:YT.optional().describe(`Most to spend in a calendar month.`)}),QT={s:1e3,m:6e4,h:36e5},$T=e=>{let t=/^(\d+)([smh])$/u.exec(e??``);if(t===null)return;let[,n=`0`,r=`s`]=t;return Number(n)*(QT[r]??1e3)},eE=2**31-1,tE=B().regex(/^\d+[smh]$/u,`use e.g. 30s, 15m, 2h`).refine(e=>($T(e)??0)<=eE,`the longest this can be is 596h`),nE=tE.refine(e=>!/^0+[smh]$/u.test(e),`a timeout must be longer than zero`),rE=e=>tE.refine(t=>($T(t)??0)>=($T(e)??0),`look no more often than every ${e}`),iE=V({every:rE(`5s`).describe(`How long to wait between looks, e.g. 30s. At least 5s.`),until:B().min(1).describe(`Stop looking when this holds. It reads what an edge's when: does.`),timeout:nE.describe(`How long to go on looking, e.g. 2h; then the node fails. Time between looks doesn't count against limits.timeout.`),misses:is().int().positive().optional().describe(`How many failed looks in a row end the wait, such as a network error. Default: 3.`)}).refine(({every:e,timeout:t})=>($T(t)??0)>($T(e)??0),`watch.timeout must be longer than watch.every`),aE=V({caveman:cs().optional().describe(`Terse voice in chat, reports and messages. Default: on.`),ponytail:ys([cs(),ks([`lite`,`full`,`ultra`])]).optional().describe("Smallest complete change. `true` is `full`. Default: `full`.")}),oE=is().int().positive(),sE=ms(B().min(1)).optional().describe("MCP servers from the project's `.mcp.json` this node's sessions load, beside Ork's own. Default: none."),cE=V({allow:ms(B()).optional(),deny:ms(B()).optional(),only:ms(B()).optional().describe(`The only built-in tools the session has; Ork's tools stay.`)}),lE=B().regex(/^[a-z][a-z0-9_-]*$/u,`agent names are lowercase: letters, digits, '-' and '_'`),uE={parent:VT.optional().describe(`Owner of this node in the ownership tree.`),label:B().optional(),description:B().optional()},dE={notify:ms(V({to:VT.describe("The `agent.leader` or `agent.worker` to write to."),when:B().optional().describe(`Send only when this holds. It reads what an edge's when: does, plus ok and error. Default: every finish.`),body:B().optional().describe(`The message, a template. Default: Ork's one line on the result.`)})).optional().describe(`Messages to send when this node finishes, with no model turn. Each starts no session.`)},fE=V({type:js(`mcp.call`),...uE,server:B().describe("The server's name in the project's `.mcp.json`."),tool:B().describe(`The tool to call on it.`),arguments:Ds(B(),us()).optional().describe(`The tool's arguments. Strings are templates; one that is only {{ … }} keeps its value's type.`),output:V({schema:zT.optional().describe(`The fields of the tool's JSON result a later node relies on, e.g. { state: [open, closed] }. A value outside these fails the node.`)}).optional().describe(`What the tool's result says.`),env:BT.env,plainEnv:BT.plainEnv,timeout:nE.optional().describe(`How long the call may take, e.g. 5m; then the node fails. With watch:, how long one look may take.`),watch:iE.optional().describe(`Call the tool again and again until a condition holds, with no model turn.`),...dE,...PT,...NT}),pE={command:B().optional().describe(`Program and arguments (no shell), or script: instead. Supports templates.`),script:B().optional().describe(`The text of a short program, instead of command. It takes no templates: values arrive through env:, as $NAME, so a value cannot become code.`),interpreter:B().optional().describe("What runs `script:`: a program and arguments. Default: `sh -eu`.")},mE=cs().optional().describe(`Skip the command when the same check already passed on identical files (a hash of the working tree, the command, Node's version); a pass is recorded. Default: false.`),hE=V({...pE,...BT,timeout:nE.optional().describe(`How long the program may run, e.g. 5m; then it is killed and the step fails.`)}),gE=hE.extend({attempts:is().int().min(0).max(5).optional().describe(`How many times a failed check resumes the session to fix it before the node fails. Default: 1.`),once:mE}).describe(`A program that must pass before the node's report is accepted. It runs in the node's checkout.`),_E={before:hE.optional().describe(`A program to run in the node's checkout before its session starts: if it fails, the node fails and no model turn is spent. Its prompt can read {{before.stdout}}, {{before.json.*}}.`),verify:gE.optional()},vE={...uE,...pE,allow:ms(B()).optional().describe("Allowed subcommand prefixes, e.g. `pr view`, `pr merge`."),cwd:B().optional(),timeout:nE.optional().describe(`How long the command may run, e.g. 5m; then it is killed and the node fails. With watch:, how long one look may take.`),watch:iE.optional().describe(`Run the command again and again until a condition holds, with no model turn.`),once:mE,...BT,...dE,...PT,...NT},yE=e=>V({type:js(e),...vE}),bE=e=>{let t=yE(`${jT}${e.id}`);return e.program===null?t.extend(e.options):t.omit({script:!0,interpreter:!0}).extend({command:B().describe(`Arguments for the CLI (no shell). Supports templates.`),...e.options})},xE=AT.map(e=>bE(e)),SE=us().refine(e=>typeof e!=`object`||!e||!(`list`in e),{message:LT}),CE=`expected low, medium, high, xhigh or max, or {{item.<field>}}`,wE=ys([GT,B().regex(/\{\{.*\}\}/su,{error:CE})],{error:CE}).describe(`Reasoning effort, or {{item.<field>}} on a forEach node. Default: Claude Code's for the model.`),TE={model:WT.optional(),effort:wE.optional(),driver:UT.optional(),skills:ms(B()).optional().describe(`Node-layer skills (highest precedence).`),context:ms(B()).optional().describe(`Node-layer context files.`),isolation:KT.optional(),budgetUsd:YT.optional(),budgetTokens:XT.optional(),maxTurns:oE.optional(),timeout:nE.optional().describe(`How long the node may work, e.g. 30m; time waiting on the user does not count.`),practices:aE.optional(),tools:cE.optional(),session:ks([`fresh`,`resume`]).optional().describe(`When the node runs again (a loop, another delegation): resume its session, or start a fresh one with the new input. Default: resume for a leader, fresh for a worker.`),output:V({schema:Ds(B(),ys([RT,SE])).optional().describe(`Extra structured fields the node must report, e.g. { verdict: [approve, escalate] }.`),gather:ms(B().min(1)).min(1).optional().describe(`List fields kept across rounds: each round's entries are added to the earlier rounds' instead of replacing them, e.g. [decisions].`)}).optional()},EE={...uE,agent:lE.optional().describe(`The agent that fills this node; its settings apply where the node sets none, and the prompt is its task.`),prompt:B().optional().describe(`Task brief. Supports {{inputs.*}} and {{nodes.<id>.output.*}} templates.`),instructions:B().optional().describe(`Node-layer instructions appended to the system prompt.`),...TE},DE=V({type:js(`agent.leader`),...EE,mcp:sE,...dE,..._E,maxWorkers:is().int().nonnegative().optional().describe(`Cap on dynamically spawned workers.`),questions:ks([`owner`,`user`]).optional().describe("Who a child's ask_user goes to first: `owner` asks a fork of this leader's session, which answers when what it was given settles it or passes it on; `user` (the default) asks the person.")}),OE=V({type:js(`agent.worker`),...EE,mcp:sE,...dE,...PT,...NT,..._E}),kE=V({type:js(`agent.subagent`),...EE,parent:VT.describe(`The Claude node whose session hosts this sub-agent.`),description:B().describe(`When the parent should use this sub-agent.`)}),AE=V({type:js(`control.split`),...uE}),jE=V({type:js(`control.join`),...uE,mode:ks([`all`,`any`,`n`]).optional().describe(`Default: all.`),n:is().int().positive().optional()}),ME=V({type:js(`control.router`),...uE,mode:ks([`first`,`all`]).optional().describe(`Follow the first matching edge (default), or every match.`)}),NE=ys([B(),V({id:B(),label:B().optional(),description:B().optional()})]),PE=V({type:js(`human.gate`),...uE,...dE,question:B(),document:B().optional(),options:ms(NE).min(2),recommended:B().optional(),timeout:tE.optional(),default:B().optional().describe(`Option chosen when the timeout expires.`)}),FE=V({type:js(`workflow.call`),...uE,...dE,...NT,workflow:B().describe(`The workflow's name, as in its project's workflows folder.`),project:B().optional().describe(`A registered project's id. Default: this project.`),node:VT.optional().describe(`A leader or worker of the called workflow to talk to and wait on; the call then keeps one run as a conversation.`),inputs:Ds(B(),B()).optional().describe(`The called workflow's inputs. Supports templates.`),wait:ks([`run`,`node`,`none`]).optional().describe("When this node finishes: the run has ended (default without `node`), the node has reported (default with `node`), or as soon as the run has started."),ref:B().optional().describe(`What the called run's worktrees start from, e.g. {{nodes.build.output.branch}}.`),timeout:nE.optional().describe(`How long the call may take, e.g. 30m; then the called run is stopped and the node fails.`),maxMessages:is().int().positive().optional().describe(`Ask the user whether to go on after this many messages.`)}),IE=xs(`type`,[DE,OE,kE,...xE,AE,jE,ME,PE,FE,fE]);V(TE);var LE=V({description:B().optional().describe(`When to use this agent; tools show it when choosing one.`),instructions:B().optional().describe(`The agent's role, appended to the system prompt of its nodes.`),...TE}),RE=V({driver:UT.optional(),model:WT.optional(),effort:GT.optional(),isolation:KT.optional(),budgetUsd:YT.optional(),budgetTokens:XT.optional(),maxTurns:oE.optional(),timeout:nE.optional().describe(`For tool and Claude nodes that set none; a gate's own timeout is separate.`),practices:aE.optional(),mcp:sE,before:_E.before}),zE=V({git:V({commit:ks([`auto`,`never`]).optional().describe(`Default: auto, Ork commits a node's work on its branch. never: Ork runs no git commit; worktrees are detached and work stays uncommitted.`),merge:ks([`auto`,`patch`,`never`]).optional().describe(`How a passing child's work reaches its owner. auto: a --no-ff merge (needs commits). patch: its changes are applied, uncommitted. never: left in its own worktree. Default: auto, or patch under commit: never.`),base:B().min(1).optional().describe(`The commit worktrees without an owner start from, e.g. origin/main. Default: HEAD. Ork never fetches.`),branch:B().min(1).optional().describe(`Branch name template over {run}, {node}, {clone} and {inputs.<name>}. Default: ork/{run}/{node}.`),worktrees:B().min(1).optional().describe(`Worktree folder template, relative to the clone, beside it. Default: ../{clone}-worktrees/ork-{run}-{node}.`)}).optional(),permissions:cE.optional().describe(`Tool rules every Claude node gets on top of its own, e.g. deny: ['Bash(git push *)'].`),links:ks([`on`,`off`]).optional().describe(`Default: on, the user can link a running node to a node of another run. off: its nodes get no message tools unless they have someone to write to, and cannot be linked.`)}),BE=ks([`low`,`normal`]),VE=V({store:ks([`store`,`file`,`github`]).describe(`store: Ork's local store, never committed (the default). file: appended to a markdown file in the run's worktree, committed with the change. github: an issue through your own gh, falling back to store when gh isn't signed in.`),file:B().min(1).optional().describe(`For store: file, the markdown file, relative to the project root. Default: .ork/follow-ups.md.`),label:B().min(1).optional().describe(`For store: github, the issues' label. Default: ork-follow-up.`)});V({schemaVersion:js(1),...zE.shape,defaults:RE.optional().describe(`Defaults for every workflow in the project; a workflow's own win.`),quotas:ZT.optional().describe(`Most this project may spend on this machine. The user's own caps apply too.`),calls:V({accept:ms(B()).describe(`The registered projects whose workflows may call this one's.`)}).optional().describe(`Default: any registered project may call this one's workflows.`),context:ms(B()).optional().describe(`Context files every node reads, relative to the project root; they come before the workflow's.`),experimental:ms(B()).optional().describe(`Experimental features this project turns on.`),heavy:ms(B().min(1)).optional().describe(`The project's full-suite commands, as Bash permission patterns without Bash(…), e.g. pnpm check. A node with verify: may not run them in its session; vitest run does not cover vitest run <files>.`),priority:BE.optional().describe(`Default: low, sessions and tool commands start at a lower OS priority. normal: as the ork process.`),followUps:VE.optional().describe(`Where follow-ups (work a change leaves for later) are kept. Default: Ork's local store.`)}),V({schemaVersion:js(1),quotas:ZT.optional().describe(`Most to spend across every project on this machine.`)});var HE=xs(`type`,[fE,...xE]),UE=V({every:rE(`1m`).describe(`How long to wait between looks, e.g. 5m. At least 1m.`),check:HE.optional().describe(`What to look at; it reports { "events": [{ "key": "...", "inputs": { ... } }] }. Without one, the trigger starts a run every time.`),run:B().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u,`the name of a workflow in this project, not a path or a flag`).describe(`The workflow to start, by its name in this project.`),inputs:Ds(B(),B()).optional().describe(`Inputs every run gets. They win over what a check reports, and aren't marked untrusted.`),maxRunsPerDay:is().int().positive().optional().describe(`Most runs to start in a calendar day. Default: 10.`),concurrency:is().int().positive().optional().describe(`How many of its runs may be going at once. A new key waits for the next look. Default: 1.`)});V({schemaVersion:js(1),triggers:Ds(VT,UE)}),gs({events:ms(gs({key:B().min(1),inputs:Ds(B(),ys([B(),is(),cs()])).optional()}))});var WE=ys([VT,ms(VT).min(1)]),GE=ys([B(),V({from:WE,to:WE,when:B().optional(),maxRounds:is().int().positive().optional()})]),KE=V({between:Ts([VT,VT])}),qE=V({type:ks([`string`,`number`,`boolean`]).optional().describe(`Default: string.`),required:cs().optional(),default:ys([B(),is(),cs()]).optional(),description:B().optional()}),JE=V({instructions:ks([`inherit`,`ignore`]).optional().describe(`Default: inherit.`),skills:ys([ks([`inherit`,`ignore`]),V({allow:ms(B())})]).optional().describe(`Default: inherit.`)}),YE=V({schemaVersion:js(1),name:B().regex(/^[a-z0-9][a-z0-9._-]*$/u,`workflow names are lowercase slugs`),description:B().optional(),inputs:Ds(B(),qE).optional(),layers:V({skills:ms(B()).optional(),context:ms(B()).optional(),project:JE.optional()}).optional(),defaults:RE.optional(),rules:zE.optional().describe(`Rules for what Ork does on its own (git, permissions); they win over the project's .ork/project.yaml.`),agents:Ds(lE,LE).optional().describe(`Agents defined in this workflow; they win over the project's and the user's of the same name.`),limits:V({budgetUsd:YT.optional().describe(`Hard cap for the whole run.`),budgetTokens:XT.optional().describe(`Hard cap for the whole run in tokens (input, output, cache-write).`),concurrency:is().int().positive().optional().describe(`Max sessions running at once.`),timeout:nE.optional().describe(`How long the whole run may work, e.g. 2h; time waiting on the user does not count.`)}).optional(),nodes:Ds(VT,IE).refine(e=>Object.keys(e).length>0,`a workflow needs nodes`),edges:ms(GE).optional(),messages:ms(KE).optional(),outputs:Ds(B(),B()).optional().describe(`What a workflow.call of this workflow can read, as templates over its nodes, rendered when the run ends.`)});IE.options.map(e=>e.shape.type.value);var XE=e=>e.file===void 0?e.message:`${e.file}:${e.line??1}:${e.column??1}: ${e.message}`;Object.keys(YE.shape),Object.keys(LE.shape),new Map(IE.options.map(e=>[e.shape.type.value,Object.keys(e.shape)]));var ZE=(e,t)=>{let n=e.indexOf(`.`);if(n<=0)return{model:e};let r=e.slice(0,n);return t.includes(r)?{driver:r,model:e.slice(n+1)}:{model:e}},QE=ms(ys([B(),is().int().min(0)])).min(1),$E={when:B().optional(),maxRounds:is().int().positive().optional()},eD={whenWas:B().optional()};xs(`op`,[V({op:js(`set`),path:QE,value:us()}),V({op:js(`delete`),path:QE}),V({op:js(`addNode`),id:B(),node:Ds(B(),us())}),V({op:js(`removeNode`),id:B()}),V({op:js(`renameNode`),from:B(),to:B()}),V({op:js(`connect`),from:B(),to:B(),...$E}),V({op:js(`disconnect`),from:B(),to:B(),...eD}),V({op:js(`setEdge`),from:B(),to:B(),...$E,...eD})]);var tD=()=>B().min(1).optional(),nD=tD,rD={runs:{status:tD(),workflow:tD(),project:tD(),since:nD(),until:nD()},feedback:{status:tD(),kind:tD(),severity:tD(),workflow:tD(),run:tD()},"follow-ups":{status:tD(),for:tD(),kind:tD(),due:tD(),project:tD()},decisions:{workflow:tD(),run:tD(),project:tD()},worktrees:{run:tD(),project:tD()},usage:{workflow:tD(),project:tD(),since:nD(),until:nD()}},iD=e=>rD[e],aD={runs:Object.keys(rD.runs),feedback:Object.keys(rD.feedback),"follow-ups":Object.keys(rD[`follow-ups`]),decisions:Object.keys(rD.decisions),worktrees:Object.keys(rD.worktrees),usage:Object.keys(rD.usage)},oD=V({limit:nc().int().positive().optional(),...rD.runs}),sD=V(rD.usage),cD=V(rD.decisions),lD={listFields:{method:`GET`,path:`/api/list-fields`}},uD=V({text:B().min(1),node:B().min(1).optional(),kind:B().min(1).optional(),severity:B().min(1).optional(),rating:B().min(1).optional()}),dD=V({status:ks([`dismissed`,`new`])}),fD=V({lesson:cs(),text:B().min(1).optional(),workflow:B().min(1).optional()}),pD=ks({"claude-code":`claude-code`,"open-code":`open-code`,"command-code":`command-code`}),mD=pD.options,hD=V({driver:pD.optional()}),gD=V({hideNames:cs()}),_D=V({hideNames:cs(),digest:B().min(1)}),vD=V(iD(`feedback`)),yD={note:{method:`POST`,path:`/api/runs/:id/notes`,body:uD},feedbackItems:{method:`GET`,path:`/api/feedback`,query:vD},feedbackItem:{method:`GET`,path:`/api/feedback/:id`},feedbackStatus:{method:`POST`,path:`/api/feedback/:id/status`,body:dD},accept:{method:`POST`,path:`/api/feedback/:id/accept`,body:fD},apply:{method:`POST`,path:`/api/feedback/:id/apply`,body:hD},publishPreview:{method:`POST`,path:`/api/feedback/:id/publish/preview`,body:gD},publish:{method:`POST`,path:`/api/feedback/:id/publish`,body:_D},split:{method:`POST`,path:`/api/feedback/:id/split`}},bD=V(iD(`follow-ups`)),xD=V({action:ks([`done`,`drop`,`reopen`,`due`])}),SD=V({confirm:js(!0),digest:B().min(1)}),CD={followUps:{method:`GET`,path:`/api/projects/:id/follow-ups`,query:bD},followUp:{method:`GET`,path:`/api/projects/:id/follow-ups/:followUp`},followUpChange:{method:`POST`,path:`/api/projects/:id/follow-ups/:followUp`,body:xD},followUpPost:{method:`POST`,path:`/api/projects/:id/follow-ups/:followUp/post`,body:SD}},wD={...yD,...CD},TD=V({name:B().min(1)}),ED=V({edits:ms($s()).min(1)}),DD=V({text:B(),baseHash:B().nullable()}),OD=V({force:cs().optional()}),kD={builderSchema:{method:`GET`,path:`/api/workflow-schema`},builderCatalog:{method:`GET`,path:`/api/projects/:id/catalog`},builderDrafts:{method:`GET`,path:`/api/projects/:id/builder`},builderView:{method:`GET`,path:`/api/projects/:id/builder/:name`},builderCreate:{method:`POST`,path:`/api/projects/:id/builder`,body:TD},builderEdit:{method:`POST`,path:`/api/projects/:id/builder/:name/edits`,body:ED},builderRestore:{method:`POST`,path:`/api/projects/:id/builder/:name/text`,body:DD},builderDiscard:{method:`POST`,path:`/api/projects/:id/builder/:name/discard`},builderSave:{method:`POST`,path:`/api/projects/:id/builder/:name/save`,body:OD}},AD={runContext:{method:`GET`,path:`/api/runs/:id/nodes/:node/context`},builderContext:{method:`GET`,path:`/api/projects/:id/builder/:name/nodes/:node/context`}},jD=V({a:B().min(3),b:B().min(3),maxMessages:is().int().positive().optional()}),MD=V({a:B().min(3),b:B().min(3)}),ND={links:{method:`GET`,path:`/api/links`,query:V({run:B().min(1).optional()})},link:{method:`POST`,path:`/api/links`,body:jD},unlink:{method:`POST`,path:`/api/links/end`,body:MD}},PD={version:{method:`GET`,path:`/api/version`},upgradePlan:{method:`POST`,path:`/api/upgrade/plan`},upgrade:{method:`POST`,path:`/api/upgrade`,body:V({planId:B().min(1)})},restart:{method:`POST`,path:`/api/restart`}},FD=B().min(1),ID=V(iD(`worktrees`)),LD=V({project:FD,key:B().min(1),deleteBranch:cs()}),RD=LD.extend({force:cs(),digest:B().min(1)}),zD=V({project:FD.optional(),branches:cs()}),BD=zD.extend({digest:B().min(1)}),VD={worktrees:{method:`GET`,path:`/api/worktrees`,query:ID},worktreeRemovePlan:{method:`POST`,path:`/api/worktrees/remove/plan`,body:LD},worktreeRemove:{method:`POST`,path:`/api/worktrees/remove`,body:RD},worktreesCleanPlan:{method:`POST`,path:`/api/worktrees/clean/plan`,body:zD},worktreesClean:{method:`POST`,path:`/api/worktrees/clean`,body:BD}},HD=nc().int().positive(),UD=V({after:nc().int().nonnegative().optional(),node:B().min(1).optional(),limit:HD.optional(),last:HD.optional()}),WD=V({choose:B().min(1),note:B().optional()}),GD={inputs:Ds(B(),B()).optional(),driver:pD.optional(),inPlace:cs().optional(),allowDirty:cs().optional()},KD=V({project:B().min(1),workflow:B().min(1),...GD,machineClaude:cs().optional()}),qD=V(GD),JD=V({node:B().min(1),body:B().min(1)}),YD=V({node:B().min(1).optional()}),XD={health:{method:`GET`,path:`/api/health`},signIn:{method:`POST`,path:`/api/sign-in`},...kD,...AD,...wD,...VD,...lD,...PD,projects:{method:`GET`,path:`/api/projects`},workflows:{method:`GET`,path:`/api/projects/:id/workflows`},runs:{method:`GET`,path:`/api/runs`,query:oD},run:{method:`GET`,path:`/api/runs/:id`},tree:{method:`GET`,path:`/api/runs/:id/tree`},graph:{method:`GET`,path:`/api/runs/:id/graph`},events:{method:`GET`,path:`/api/runs/:id/events`,query:UD},decisions:{method:`GET`,path:`/api/decisions`,query:cD},decision:{method:`GET`,path:`/api/decisions/:id`},answer:{method:`POST`,path:`/api/decisions/:id`,body:WD},start:{method:`POST`,path:`/api/runs`,body:KD},resume:{method:`POST`,path:`/api/runs/:id/resume`,body:qD},stop:{method:`POST`,path:`/api/runs/:id/stop`,body:YD},pause:{method:`POST`,path:`/api/runs/:id/pause`,body:YD},continue:{method:`POST`,path:`/api/runs/:id/continue`,body:YD},message:{method:`POST`,path:`/api/runs/:id/messages`,body:JD},usage:{method:`GET`,path:`/api/usage`,query:sD},triggers:{method:`GET`,path:`/api/triggers`},...ND},ZD={run:`/api/runs/:id/stream`,overview:`/api/stream`,upgrade:`/api/upgrade/stream`},QD=(e,t)=>e.replaceAll(/:(\w+)/gu,(e,n)=>encodeURIComponent(t[n]??``)),$D=e=>typeof e==`object`&&e?Object.entries(e).flatMap(([e,t])=>typeof t==`string`||typeof t==`number`?[[e,String(t)]]:[]):[],eO=e=>{let t=new URLSearchParams;for(let[n,r]of $D(e))t.set(n,r);let n=t.toString();return n===``?``:`?${n}`},tO=(e,t)=>typeof e==`object`&&e&&`error`in e&&typeof e.error==`string`?e.error:`The server answered ${String(t)}.`,nO=(e={})=>{let t=(t,n)=>(e.fetch??globalThis.fetch)(t,n);return{call:async(n,...[r])=>{let i=XD[n],a=r??{},o=Object.fromEntries($D(a.params)),s=`${e.base??``}${QD(i.path,o)}${eO(a.query)}`,c={accept:`application/json`};e.token!==void 0&&(c.authorization=`Bearer ${e.token}`);let l={method:i.method,headers:c};i.method===`POST`&&(c[`content-type`]=`application/json`,l.body=JSON.stringify(a.body??{}));let u;try{u=await t(s,l)}catch(e){return{ok:!1,status:0,error:`No answer: ${e instanceof Error?e.message:String(e)}`}}let d=await u.json().catch(()=>null);return u.ok?{ok:!0,status:u.status,data:d}:{ok:!1,status:u.status,error:tO(d,u.status)}}}},rO=e=>typeof e==`string`?`'${e.replaceAll(`\\`,`\\\\`).replaceAll(`'`,`\\'`)}'`:String(e??`''`),iO={is:`==`,isnt:`!=`,above:`>`,atLeast:`>=`,below:`<`,atMost:`<=`},aO={anyIs:`any`,allAre:`all`,contains:`contains`},oO=({field:e,test:t,value:n})=>{if(t===`isTrue`)return e;if(t===`isFalse`)return`!${e}`;let r=aO[t];return r===void 0?`${e} ${String(iO[t])} ${rO(n)}`:`${r}(${e}, ${rO(n)})`},sO=e=>{switch(e.mode){case`succeeds`:return;case`fails`:return`!ok`;case`otherwise`:return`true`;case`hand`:return e.text;case`test`:return e.rows.map(oO).join(e.join===`any`?` || `:` && `);default:return}},cO={is:`isnt`,isnt:`is`,above:`atMost`,atMost:`above`,below:`atLeast`,atLeast:`below`,isTrue:`isFalse`,isFalse:`isTrue`},lO=e=>{if(e.mode!==`succeeds`&&e.mode!==`otherwise`){if(e.mode===`fails`)return`ok`;if(e.mode===`test`&&e.rows.length===1){let[t]=e.rows,n=t===void 0?void 0:cO[t.test];if(t!==void 0&&n!==void 0)return oO({...t,test:n})}return`!(${String(sO(e))})`}},uO=2e3,dO=({title:e,children:t,cli:n,focusable:r=!1})=>(0,K.jsxs)(`div`,{className:r_.empty,children:[(0,K.jsx)(`p`,{className:r_.emptyTitle,"data-empty-title":r?``:void 0,tabIndex:r?-1:void 0,children:e}),(0,K.jsx)(`div`,{className:r_.emptyBody,children:t}),n===void 0?null:(0,K.jsx)(`div`,{className:r_.emptyCommand,children:(0,K.jsx)(lC,{command:n})})]});function fO(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var pO=`data-checked`,mO=`data-unchecked`;function hO(e){return{checked(t){return e.indeterminate?{}:t?{[pO]:``}:{[mO]:``}},...cx}}var gO=H.createContext({disabled:!1});function _O(){return H.useContext(gO)}function vO(e,t,n,r=!0,i,a){let[o,s]=H.useState(),c=hg(i?`${i}-label`:void 0),l=!!a?.trim(),u=e??(l?void 0:t)??o;return U(()=>{let i=e||t||l||!r?void 0:yO(n.current,c);o!==i&&s(i)}),u}function yO(e,t){let n=bO(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function bO(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var xO=H.createContext(void 0);function SO(){return H.useContext(xO)}var CO=H.createContext(void 0);function wO(){let e=H.useContext(CO);if(e===void 0)throw Error(gc(14));return e}var TO=`data-parent`,EO=H.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:m=!1,render:h,required:g=!1,uncheckedValue:_,value:v,nativeButton:y=!1,style:b,...x}=e,{clearErrors:S}=mx(),{disabled:C,name:w,setDirty:T,setFilled:E,setTouched:D,state:O,validationMode:k,validityData:A,validation:j}=dx(),M=_O(),{labelId:N,registerControlId:P,getDescriptionProps:F}=gx(),I=SO(),L=I?.allValues===void 0?void 0:I.parent,R=L!==void 0,ee=C||M.disabled||I?.disabled||o,te=w??d,ne=v??te,re=hg(),ie=I?.registerControlId!==P,ae=_x({id:c||void 0,enabled:ie}),oe=y?ae:re,se={};R&&(p?se=L.getParentProps():ne!==void 0&&(se=L.getChildProps(ne)));let{checked:ce=n,indeterminate:le=l,onCheckedChange:ue,...de}=se,fe=I?.value,pe=H.useRef(null),me=Hx(ee,pe),{getButtonProps:he,buttonRef:ge}=$_({disabled:ee,native:y}),_e=I?.validation??j,[ve,ye]=Cb({controlled:ne!==void 0&&fe!==void 0&&!p?fe.includes(ne):ce,default:i,name:`Checkbox`,state:`checked`}),be=R?!!ce:ve,xe=R&&le||l;fx(pe,re,ve,void 0,!I&&!ee,d);let z=L?.registerChildId,Se=H.useRef(null),Ce=_e.registerInput,we=I?ne:void 0,Te=H.useCallback(e=>Ce(e,{controlRef:pe,value:we}),[Ce,we]),Ee=Au(u,Se,p?void 0:Te),De=vO(a,N,Se,!y,ae,x[`aria-label`]);U(()=>{Se.current&&(Se.current.indeterminate=xe),I||E(ve)},[ve,xe,I,E]),Tx(ve,()=>{I||(S(te),T(ve!==A.initialValue),_e.change(ve))});let Oe=Pf({checked:ve,disabled:ee,form:s,name:p?void 0:te,id:y?void 0:ae,required:g,ref:Ee,style:te?Xu:Yu,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(m){e.preventDefault();return}let t=e.currentTarget.checked,n=G(iu,e.nativeEvent);if(f?.(t,n),!n.isCanceled&&(ue?.(t,n),!n.isCanceled&&(ye(t),ne!==void 0&&I!==void 0&&!p&&!R))){let e=t?[...I.value,ne]:I.value.filter(e=>e!==ne);I.setValue(e,n)}},onClick(e){e.stopPropagation()},onFocus(){pe.current?.focus()}},v===void 0?mc:{value:(I?ve&&v:v)||``},F,e=>_e.getValidationProps(ee,e));H.useEffect(()=>{if(!L||ne===void 0)return;let e=L.disabledStatesRef.current;return e.set(ne,ee),()=>{e.delete(ne)}},[L,ee,ne]);let ke=H.useMemo(()=>({...O,checked:be,disabled:ee,readOnly:m,required:g,indeterminate:xe}),[O,be,ee,m,g,xe]),Ae=hO(ke),je=qf(`span`,e,{state:ke,ref:[ge,pe,t],props:[{id:oe,role:`checkbox`,"aria-checked":xe?`mixed`:be,"aria-readonly":m||void 0,"aria-required":g||void 0,"aria-labelledby":De,[TO]:p?``:void 0,onFocus(){me(!0)},onBlur(){let e=Se.current;e&&(D(!0),me(!1),k===`onBlur`&&_e.commit(I?fe:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Se.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),Kc(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||fO(t)?.click()})},onClick(e){if(m||ee)return;e.preventDefault();let t=Se.current;t&&Q_(t,e)}},x,de,he,F,e=>_e.getValidationProps(ee,e)],stateAttributesMapping:Ae}),Me=je.props.id;return U(()=>{if(z&&!p&&ne!==void 0&&Me!==void 0)return z(ne,Me)},[z,p,ne,Me]),(0,K.jsxs)(CO.Provider,{value:ke,children:[je,!ve&&!I&&te&&!p&&_!==void 0&&(0,K.jsx)(`input`,{type:`hidden`,form:s,name:te,value:_,disabled:ee}),(0,K.jsx)(`input`,{...Oe,suppressHydrationWarning:!0})]})}),DO=H.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=wO(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=Hp(c),f=H.useRef(null),p={...s,transitionStatus:u};qp({batch:!0,enabled:!c,open:c,ref:f,onComplete(){c||d(!1)}});let m={...hO(s),...Ol},h=a||l,g=qf(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null}),OO=H.createContext(void 0);function kO(){let e=H.useContext(OO);if(e===void 0)throw Error(gc(63));return e}var AO=`data-checked`,jO=`data-unchecked`,MO={...cx,checked(e){return e?{[AO]:``}:{[jO]:``}}},NO=H.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=mx(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,validationMode:E,disabled:D,name:O,validation:k}=dx(),{labelId:A}=gx(),j=D||m,M=O??l,N=H.useRef(null),P=Au(N,c,k.inputRef),F=H.useRef(null),I=Hx(j,F),L=hg(),R=_x({id:s}),ee=u?void 0:R,[te,ne]=Cb({controlled:n,default:!!i,name:`Switch`,state:`checked`});fx(F,L,te,void 0,!j,l),U(()=>{T(te)},[te,T]),Tx(te,()=>{b(M),C(te!==w.initialValue),k.change(te)});let{getButtonProps:re,buttonRef:ie}=$_({disabled:j,native:u}),ae=vO(a,A,N,!u,ee,y[`aria-label`]),oe={id:u?R:L,role:`switch`,"aria-checked":te,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":ae,onFocus(){I(!0)},onBlur(){let e=N.current;e&&!j&&(S(!0),I(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){if(f||j)return;e.preventDefault();let t=N.current;t&&Q_(t,e)}},se={...k.getValidationProps(j),checked:te,disabled:j,form:o,id:ee,name:M,required:p,style:M?Xu:Yu,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:P,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=G(iu,e.nativeEvent);d?.(t,n),!n.isCanceled&&ne(t)},onClick(e){e.stopPropagation()},onFocus(){F.current?.focus()},..._===void 0?mc:{value:_}},ce=H.useMemo(()=>({...x,checked:te,disabled:j,readOnly:f,required:p}),[x,te,j,f,p]),le=qf(`span`,e,{state:ce,ref:[t,F,ie],props:[oe,y,re,e=>k.getValidationProps(j,e)],stateAttributesMapping:MO});return(0,K.jsxs)(OO.Provider,{value:ce,children:[le,!te&&M&&g!==void 0&&(0,K.jsx)(`input`,{type:`hidden`,form:o,name:M,value:g,disabled:j}),(0,K.jsx)(`input`,{...se,suppressHydrationWarning:!0})]})}),PO=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return qf(`span`,e,{state:kO(),ref:t,stateAttributesMapping:MO,props:a})}),FO=({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i})=>(0,K.jsxs)(`label`,{className:rC.toggle,children:[(0,K.jsx)(EO,{"aria-describedby":i,checked:t,className:rC.box,disabled:r,onCheckedChange:e=>{n(e)},children:(0,K.jsx)(DO,{className:rC.mark,children:(0,K.jsx)(cy,{})})}),e]}),IO=({label:e,checked:t,onChange:n,disabled:r=!1})=>(0,K.jsxs)(`label`,{className:rC.toggle,children:[(0,K.jsx)(NO,{checked:t,className:rC.switch,disabled:r,onCheckedChange:e=>{n(e)},children:(0,K.jsx)(PO,{className:rC.thumb})}),e]});function LO(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var RO=H.createContext(void 0),zO=H.createContext(void 0);function BO(){let e=H.useContext(RO);if(e===void 0)throw Error(gc(60));return e}function VO(){let e=H.useContext(zO);if(e===void 0)throw Error(gc(61));return e}var HO={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,multiple:e=>e.multiple,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,highlightItemOnHover:e=>e.highlightItemOnHover,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:$b(t,r)!==``},hasNullItemLabel:(e,t)=>t?Zb(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>zb(t,e,n)):zb(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,itemRoot:e=>e.itemRoot,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function UO(e,t){return Math.max(0,e-t)}function WO(e,t){if(t<=0)return 0;let n=T_(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function GO(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=Rb,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=mx(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=dx(),F=_x({id:t}),I=M||d,L=j??c,[R,ee]=Cb({controlled:n,default:y?r??pc:r,name:`Select`,state:`value`}),[te,ne]=Cb({controlled:a,default:o,name:`Select`,state:`open`}),re=H.useRef([]),ie=H.useRef([]),ae=H.useRef(null),oe=H.useRef(null),se=H.useRef(0),ce=H.useRef(null),le=H.useRef([]),ue=H.useRef(!1),de=H.useRef(null),fe=H.useRef(null),pe=H.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),me=H.useRef(!1),he=H.useRef(R),{openMethod:ge,triggerProps:_e}=Dx(te),ve=ic(()=>new Sm({id:F,labelId:void 0,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:te,mounted:te,transitionStatus:void 0,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:mc,triggerProps:mc,itemRoot:{props:mc,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:fc,setOpen:fc,handleScrollArrowVisibility:fc,onOpenChangeComplete:fc,listRef:re,popupRef:ae,scrollHandlerRef:oe,scrollArrowsMountedCountRef:se,valueRef:ce,valuesRef:le,labelsRef:ie,typingRef:ue,selectionRef:pe,firstItemTextRef:de,selectedItemTextRef:fe,alignItemWithTriggerActiveRef:me,initialValueRef:he},HO)).current,[ye,be]=H.useState(!1),{mounted:xe,transitionStatus:z,forceUnmount:Se}=Jp({open:te,ref:ae,preventUnmountOnClose:ye,setPreventUnmountOnClose:be,onUnmount(){ve.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)}}),Ce=ve.useState(`activeIndex`),we=ve.useState(`selectedIndex`),Te=ve.useState(`triggerElement`),Ee=ve.useState(`positionerElement`),De=Qg(ge),Oe=ge??De,ke=H.useMemo(()=>y?``:$b(R,x),[y,R,x]),Ae=H.useMemo(()=>y&&Array.isArray(R)?R.map(e=>$b(e,x)):$b(R,x),[y,R,x]);fx(Iu(Te),F,R,q(()=>Ae),!I,c);let je=y?Array.isArray(R)&&R.length>0:R!=null&&ke!==``;U(()=>{A(je)},[je,A]),U(function(){let e=Wb(le.current,R,S,y);e===null&&(fe.current=null),!te&&ve.set(`selectedIndex`,e)},[y,te,R,S,ve]),Tx(R,()=>{T(L),E(Bb(R,k.initialValue,S)),N.change(R)});let Me=q((e,t)=>{let n=t,r=nm(n);s?.(e,n),!t.isCanceled&&(e||be(r()),ne(e),e||t.reason!==`focus-out`&&t.reason!==`outside-press`||(D(!0),O(!1),P===`onBlur`&&N.commit(R)))});H.useImperativeHandle(h,()=>({unmount:Se,close:()=>{ve.state.open&&Me(!1,G(Su))}}),[Se,Me,ve]);let Ne=q((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),Pe=q(e=>{let t=UO(e.scrollHeight,e.clientHeight),n=WO(e.scrollTop,t),r=n>0,i=n<t;ve.set(`scrollUpArrowVisible`,r),ve.set(`scrollDownArrowVisible`,i)}),Fe=Nm({open:te,onOpenChange:Me,elements:{reference:Te,floating:Ee}}),Ie=Pp(Fe,{enabled:!I,event:`mousedown`}),Le=Bp(Fe),Re=Xm(Fe,{enabled:!I,listRef:re,activeIndex:Ce,selectedIndex:we,disabledIndices:pc,onNavigate(e){(e!==null||te)&&ve.set(`activeIndex`,e)},focusItemOnHover:C}),ze=Zm(Fe,{enabled:!I&&(te||!f&&!y),listRef:ie,activeIndex:Ce,selectedIndex:we,disabledIndices:e=>LO(re.current[e]),onMatch(e){te?ve.set(`activeIndex`,e):Ne(le.current[e],G(iu))},onTyping(e){ue.current=e}}),Be=H.useMemo(()=>Pf(ze.reference,Re.reference,Le.reference,Ie.reference,_e),[Ie.reference,ze.reference,Re.reference,Le.reference,_e]),Ve=H.useMemo(()=>Pf(Yp,ze.floating,Re.floating,Le.floating),[ze.floating,Re.floating,Le.floating]),He=Re.item??mc,Ue=H.useMemo(()=>({props:He,multiple:y,disabled:I,readOnly:f,isItemEqualToValue:S}),[He,y,I,f,S]);ve.useContextCallback(`setValue`,Ne),ve.useContextCallback(`setOpen`,Me),ve.useContextCallback(`handleScrollArrowVisibility`,Pe),ve.useContextCallback(`onOpenChangeComplete`,_),wb(()=>{ve.update({popupProps:Ve,triggerProps:Be,itemRoot:Ue})}),ve.useSyncedValues({id:F,modal:m,multiple:y,disabled:I,readOnly:f,required:p,highlightItemOnHover:C,value:R,open:te,mounted:xe,transitionStatus:z,popupProps:Ve,triggerProps:Be,itemRoot:Ue,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Oe});let We=Au(g,N.inputRef),Ge=y?void 0:L,Ke=H.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=$b(e,x);return(0,K.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,K.jsxs)(RO.Provider,{value:ve,children:[(0,K.jsx)(zO.Provider,{value:Fe,children:w}),(0,K.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){ve.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=G(iu,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=le.current.findIndex(t=>$b(t,x).toLowerCase()===e||Qb(t,b).toLowerCase()===e);r===-1&&(r=le.current.findIndex((t,n)=>{let r=ie.current[n];return r!=null&&r.toLowerCase()===e}));let i=le.current[r];i!=null&&Ne(i,n)}ve.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Ge==null?`${F}-hidden-input`:void 0,form:l,name:Ge,autoComplete:u,value:ke,disabled:I,required:p&&!(y&&je),readOnly:f,ref:We,style:L?Xu:Yu,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ke]})}var KO=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=a;delete o.id;let s=dx(),c=BO(),l=c.useState(`triggerElement`),u=c.useState(`id`),d=Px({id:Lx(u),fallbackControlId:l?.id??u,setLabelId(e){let t=typeof e==`function`?e(c.state.labelId):e;c.set(`labelId`,t)}});return qf(`div`,e,{ref:t,state:s.state,props:[d,a],stateAttributesMapping:cx})}),qO=`data-popup-side`,JO=400,YO={...Bl,...cx,popupSide:e=>e?{[qO]:e}:null,value:()=>null},XO=H.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,validationMode:u,validation:d,state:f,disabled:p}=dx(),{labelId:m}=gx(),h=BO(),g=h.useState(`readOnly`),_=h.useState(`required`),v=h.useState(`disabled`),y=p||v||a,b=h.useState(`open`),x=h.useState(`mounted`),S=h.useState(`value`),C=h.useState(`triggerProps`),w=h.useState(`positionerElement`),T=h.useState(`listElement`),E=h.useState(`popupSide`),D=h.useState(`id`),O=h.useState(`labelId`),k=h.useState(`hasSelectedValue`),A=x&&w?E:null,j=i??D,M=Rx(m,O);_x({id:i});let N=Iu(w),P=H.useRef(null),F=Hx(y,P),{getButtonProps:I,buttonRef:L}=$_({disabled:y,native:o}),R=h.useStateSetter(`triggerElement`),ee=Sc(),te=Sc(),ne=Sc();H.useEffect(()=>{if(b)return ne.start(JO,()=>{h.context.selectionRef.current.allowUnselectedMouseUp=!0,h.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ne.clear()};h.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},te.clear()},[b,h,te,ne]);let re=Pf(C,{id:j,role:`combobox`,"aria-expanded":b,"aria-haspopup":`listbox`,"aria-controls":b?T?.id??Zl(w)?.id:void 0,"aria-labelledby":M,"aria-readonly":g||void 0,"aria-required":_||void 0,tabIndex:y?-1:0,onFocus(e){F(!0),b&&h.context.alignItemWithTriggerActiveRef.current&&h.context.setOpen(!1,G(iu,e.nativeEvent)),ee.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){W(w,e.relatedTarget)||(l(!0),F(!1),u===`onBlur`&&d.commit(S))},onMouseDown(e){if(b)return;let t=qu(e.currentTarget);function n(e){if(!P.current)return;let t=e.target;W(P.current,t)||W(N.current,t)||nS(e,P.current)||h.context.setOpen(!1,G(yu,e))}te.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),ie=d.getValidationProps(y,re);ie.role=`combobox`;let ae={...f,open:b,disabled:y,value:S,readOnly:g,popupSide:A,placeholder:!k};return qf(`button`,e,{ref:[t,P,L,R],state:ae,stateAttributesMapping:YO,props:ie})}),ZO={value:()=>null},QO=H.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=BO(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?tx(l,u,d):ex(l,u,d)),qf(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:ZO})}),$O=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return qf(`span`,e,{state:{open:BO().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:zl})}),ek=H.forwardRef(function(e,t){let n=BO(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,K.jsx)(mp,{ref:t,...e}):null}),tk=H.createContext(void 0);function nk(){let e=H.useContext(tk);if(!e)throw Error(gc(59));return e}function rk(e,t){e&&Object.assign(e.style,t)}var ik={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},ak={position:`fixed`},ok=H.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=op,style:_,...v}=e,y=BO(),b=VO(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=H.useRef(null),j=H.useRef(null),[M,N]=H.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),H.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),RS((P||C)&&x,T===`touch`,E,D);let F=Ug({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?ak:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};U(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let ee=qg(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),te=H.useRef(0),ne=q(e=>{if(y.context.valuesRef.current.length===0)return;let t=te.current;te.current=e.size;let n=G(iu);if(t!==0&&!y.state.multiple&&w!==null&&Hb(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&Hb(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>Hb(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};rk(E,e),rk(y.context.popupRef.current,e)}}),re=H.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,K.jsx)(dS,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:ne,children:(0,K.jsxs)(tk.Provider,{value:re,children:[S&&C&&(0,K.jsx)(TS,{inert:Zg(!x),cutout:D}),ee]})})}),sk=`base-ui-disable-scrollbar`,ck={className:sk,getElement(e){return(0,K.jsx)(`style`,{nonce:e,href:sk,precedence:`base-ui:low`,children:`.${sk}{scrollbar-width:none}.${sk}::-webkit-scrollbar{display:none}`})}},lk=H.createContext(void 0);function uk(e){let t=H.useContext(lk);if(t===void 0&&!e)throw Error(gc(69));return t}var dk=`--transform-origin`,fk={...Vl,...Ol},pk=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=BO(),c=s.useState(`multiple`),l=s.useState(`readOnly`),u=s.useState(`highlightItemOnHover`),d=VO(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=nk(),_=uk(!0)!=null,v=kg(),{nonce:y,disableStyleElements:b}=k(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),A=s.useState(`listElement`),j=H.useRef(!1),M=H.useRef(!1),N=H.useRef({}),P=Ku(),F=q(e=>{if(!O||!s.context.popupRef.current||!M.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(j.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=gk(O),i=_k(O.getBoundingClientRect().height,`y`,r),a=qu(O),o=Kc(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=mk(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=hk(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=T_(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(j.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=T_(g,0,hk(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(j.current=!0),s.context.handleScrollArrowVisibility(e)});H.useImperativeHandle(s.context.scrollHandlerRef,()=>F,[F]),qp({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let I={open:S,transitionStatus:E,side:f,align:p};U(()=>{O&&s.context.popupRef.current&&!Object.keys(N.current).length&&(N.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),U(()=>{S||m||(M.current=!1,j.current=!1,rk(O,N.current))},[S,m,O]),U(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(M.current=!0,e.style.removeProperty(dk),!m){P.request(()=>s.context.handleScrollArrowVisibility(A||e));return}let t=bk(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=Kc(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=qu(D),c=gk(D),l=vk(D.getBoundingClientRect(),c),d=vk(O.getBoundingClientRect(),c),f=l.height,p=A||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=mk(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,k=0;if(t&&n){let e=vk(n.getBoundingClientRect(),c);T=vk(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;k=T.top-d.top+T.height/2-r}let M=w+k+y+h,P=Math.min(S,M),F=S-_-y,I=M-P,L=C-5;O.style.left=`${T_(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=hk(p),ee=I>=R-1;ee&&(P=Math.min(S,d.height)-(I-R));let te=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),ne=(r.visualViewport?.scale??1)!==1&&Pc;if(te||ne){rk(O,N.current),g(!1);return}let re=Math.max(b,P);if(ee){let e=Math.max(0,S-M);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=hk(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=T_(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(dk,`50% ${i}%`)}(re===S||P>=x)&&(j.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,P,A,u,v,h]),H.useEffect(()=>{if(!m||!O||!S)return;let e=Kc(O);function t(e){s.context.setOpen(!1,G(Cu,e))}return Ou(e,`resize`,t)},[s,m,O,S]);let L={...A?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&wC.has(e.key)&&e.stopPropagation()},onScroll(e){A||F(e.currentTarget)},...m&&{style:A?{height:`100%`}:ik},className:!A&&m?ck.className:void 0},R=qf(`div`,e,{ref:[t,s.context.popupRef],state:I,stateAttributesMapping:fk,props:[T,L,Kg(E),o]});return(0,K.jsxs)(H.Fragment,{children:[!b&&ck.getElement(y),(0,K.jsx)(Np,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:R})]})});function mk(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function hk(e){return UO(e.scrollHeight,e.clientHeight)}function gk(e){return Hh.getScale(e)}function _k(e,t,n){return e/n[t]}function vk(e,t){return wd({x:_k(e.x,`x`,t),y:_k(e.y,`y`,t),width:_k(e.width,`x`,t),height:_k(e.height,`y`,t)})}var yk=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function bk(e){let{style:t}=e,n={};for(let[e,r]of yk)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of yk){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var xk=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=BO(),s=o.useState(`multiple`),c=o.useState(`readOnly`),{alignItemWithTriggerActive:l}=nk(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:ik},className:u&&d!==`touch`?ck.className:void 0};return qf(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),Sk=H.createContext(void 0);function Ck(){let e=H.useContext(Sk);if(!e)throw Error(gc(57));return e}var wk=H.memo(H.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=H.useRef(null),d=KS({guess:!0,label:o,textRef:u}),f=BO(),{props:p,multiple:m,disabled:h,readOnly:g,isItemEqualToValue:_}=f.useState(`itemRoot`),v=h||s,y=f.useState(`isActive`,d.index),b=f.useState(`open`),x=f.useState(`isSelected`,a),S=f.useState(`isSelectedByFocus`,d.index),C=d.index,w=H.useRef(null);U(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),U(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=Gb(C,a,f.context.valuesRef.current,e,_,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&zb(a,e,_),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,_,f,a]);let T=H.useRef(`mouse`),E=H.useRef(!1),{getButtonProps:D,buttonRef:O}=$_({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:v,selected:x,highlighted:y};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=x?Kb(n,a,_):[...n,a];f.context.setValue(r,G(lu,e))}else f.context.setValue(a,G(lu,e)),f.context.setOpen(!1,G(lu,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":x,tabIndex:b&&y?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Bc(e.nativeEvent)&&(n!==void 0||y),i=t&&!r&&!E.current;E.current=!1,!(v||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),v||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&x,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!x;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=qf(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=H.useMemo(()=>({selected:x,index:C,textRef:u,selectedByFocus:S}),[x,C,u,S]);return(0,K.jsx)(Sk.Provider,{value:P,children:N})})),Tk=H.forwardRef(function(e,t){let{selected:n}=Ck();return e.keepMounted||n?(0,K.jsx)(eC,{...e,selected:n,ref:t}):null}),Ek=H.memo(H.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=Ck(),a=BO(),{render:o,className:s,style:c,...l}=e;return qf(`div`,e,{ref:[H.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),Dk=({children:e})=>(0,K.jsx)(`span`,{className:rC.visuallyHidden,children:e}),Ok=({label:e,unseen:t,options:n,value:r,onChange:i,describedBy:a,invalid:o=!1})=>(0,K.jsxs)(GO,{items:n,onValueChange:e=>{e!==null&&i(e)},value:r,children:[(0,K.jsxs)(`div`,{className:rC.field,children:[(0,K.jsxs)(KO,{className:rC.label,children:[e,t===void 0?null:(0,K.jsx)(Dk,{children:t})]}),(0,K.jsxs)(XO,{"aria-describedby":a,"aria-invalid":o?!0:void 0,className:rC.control,"data-invalid":o?``:void 0,children:[(0,K.jsx)(QO,{className:rC.value}),(0,K.jsx)($O,{className:rC.icon,children:(0,K.jsx)(ly,{})})]})]}),(0,K.jsx)(ek,{children:(0,K.jsx)(ok,{align:`start`,alignItemWithTrigger:!1,className:a_.positioner,sideOffset:4,children:(0,K.jsx)(pk,{className:a_.popup,children:(0,K.jsx)(xk,{"aria-label":e,children:n.map(e=>(0,K.jsxs)(wk,{className:a_.item,value:e.value,children:[(0,K.jsx)(Ek,{children:e.label}),(0,K.jsx)(Tk,{className:rC.icon,children:(0,K.jsx)(cy,{})})]},e.value))})})})})]}),kk=H.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:y,validationMode:b,validation:x}=dx(),{clearErrors:S,elementRef:C,submitCountRef:w}=mx(),T=h||s,E=m??a,D={...p,disabled:T},{labelId:O}=gx(),k=_x({id:i}),A=o!==void 0,j=o==null?void 0:String(o),M=q(()=>x.inputRef.current?.value);fx(x.inputRef,k,j,M,!T,a),U(()=>{let e=j??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[j,l,x.inputRef,y]),Tx(j,()=>{j!==void 0&&(S(E),_(j!==(v.initialValue??``)),x.change(j))});let N=H.useRef(null),P=Hx(T,N),F=Sc();return qf(`input`,e,{ref:[t,N],state:D,props:[{id:k,disabled:T,name:E,ref:x.inputRef,"aria-labelledby":O,autoFocus:u,...A?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=G(iu,e.nativeEvent);c?.(t,n),!A&&(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(S(E),x.change(t)))},onFocus(){P(!0)},onBlur(e){if(g(!0),P(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),A&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===C.current&&!e.defaultPrevented){let t=e.currentTarget,n=w.current;F.start(0,()=>{w.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(T,e)],stateAttributesMapping:cx})}),Ak=H.forwardRef(function(e,t){return(0,K.jsx)(kk,{ref:t,...e})}),jk=({label:e,unseen:t,value:n,onChange:r,onCommit:i,multiline:a=!1,rows:o=4,description:s,required:c=!1,type:l=`text`})=>{let u=(0,H.useId)(),d=`${u}-description`;return(0,K.jsxs)(`div`,{className:rC.field,children:[(0,K.jsxs)(`label`,{className:rC.label,htmlFor:u,children:[e,t===void 0?null:(0,K.jsx)(Dk,{children:t}),c?` (required)`:``]}),(0,K.jsx)(`div`,{className:rC.group,children:(0,K.jsx)(Ak,{"aria-describedby":s===void 0?void 0:d,className:rC.input,id:u,onBlur:i,onKeyDown:e=>{e.key===`Enter`&&!a&&i?.()},onValueChange:e=>{r(e)},render:a?(0,K.jsx)(`textarea`,{rows:o}):void 0,required:c,type:a?void 0:l,value:n})}),s===void 0?null:(0,K.jsx)(`p`,{className:rC.hint,id:d,children:(0,K.jsx)(J,{text:s})})]})},Mk={panel:`_panel_dga7q_7`,tools:`_tools_dga7q_19`,filter:`_filter_dga7q_36`,main:`_main_dga7q_43`,list:`_list_dga7q_55`,row:`_row_dga7q_68`,rowTop:`_rowTop_dga7q_105`,rowMeta:`_rowMeta_dga7q_106`,workflow:`_workflow_dga7q_138`,note:`_note_dga7q_145`,form:`_form_dga7q_154`,group:`_group_dga7q_162`,legend:`_legend_dga7q_174`,reason:`_reason_dga7q_193`,error:`_error_dga7q_194`,triggers:`_triggers_dga7q_226`,triggersTitle:`_triggersTitle_dga7q_244`,triggerList:`_triggerList_dga7q_261`,triggerName:`_triggerName_dga7q_272`,triggerLine:`_triggerLine_dga7q_280`,triggerCommand:`_triggerCommand_dga7q_289`,yolo:`_yolo_dga7q_297`},Nk=[{value:``,label:`The workflow's, else the one ready`},...mD.map(e=>({value:e,label:e}))],Pk=({workflow:e,values:t,onChange:n})=>(0,K.jsx)(K.Fragment,{children:Object.entries(e.inputs).map(([e,r])=>r.type===`boolean`?(0,K.jsx)(FO,{checked:t[e]===`true`,label:e,onChange:t=>{n(e,String(t))}},e):(0,K.jsx)(jk,{description:r.description,label:e,onChange:t=>{n(e,t)},required:r.required===!0,type:r.type===`number`?`number`:`text`,value:t[e]??``},e))}),Fk=({value:e,onChange:t})=>(0,K.jsx)(Ok,{label:`Driver`,onChange:e=>{let n=Nk.find(t=>t.value===e);n!==void 0&&t(n.value)},options:Nk,value:e}),Ik=({flags:e,onChange:t})=>(0,K.jsxs)(`fieldset`,{className:Mk.group,children:[(0,K.jsx)(`legend`,{className:Mk.legend,children:`Flags`}),(0,K.jsx)(Fk,{onChange:e=>{t({driver:e})},value:e.driver}),(0,K.jsx)(FO,{checked:e.inPlace,label:`--in-place: run worktree nodes in this checkout`,onChange:e=>{t({inPlace:e})}}),(0,K.jsx)(FO,{checked:e.allowDirty,label:`--allow-dirty: run with uncommitted instructions or skills`,onChange:e=>{t({allowDirty:e})}}),(0,K.jsx)(Rk,{checked:e.machineClaude,onChange:e=>{t({machineClaude:e})}})]}),Lk=`Your MCP servers and Claude's memory`,Rk=({checked:e,onChange:t})=>{let n=(0,H.useId)();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(FO,{checked:e,describedBy:n,label:`Use this machine's Claude setup`,onChange:t}),(0,K.jsx)(`p`,{className:rC.hint,id:n,children:Lk})]})},zk=()=>(0,K.jsx)(dO,{cli:`ork init`,title:`No projects yet.`,children:`Run this in a repository:`}),Bk=({error:e})=>(0,K.jsx)(`p`,{className:Mk.error,role:`alert`,children:(0,K.jsx)(J,{text:e})}),Vk={driver:``,inPlace:!1,allowDirty:!1,machineClaude:!1},Hk=({default:e,type:t})=>e===void 0?t===`boolean`?`false`:``:String(e),Uk=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Hk(t)])),Wk=(e,t,n)=>e===null?null:t.status===`failed`?`Cannot read the workflows of ${e}: ${t.error??`unknown error`}`:t.status===`ready`&&n===0?`${e} has no workflows. Add one to its .ork/workflows folder.`:null,Gk=(e,t,n)=>e===null?`Choose a project first`:t?`Reading workflows…`:n===0?`No workflows here`:`Type to find a workflow`,Kk=(e,t,n)=>{if(e===null)return`Pick a project.`;if(t===null)return`Pick a workflow.`;if(t.error!==void 0)return`This workflow does not parse: ${t.error}`;for(let[e,r]of Object.entries(t.inputs)){let t=n[e]??``;if(r.required===!0&&t===``)return`Fill in ${e}.`;if(r.type===`number`&&t!==``&&!Number.isFinite(Number(t)))return`${e} must be a number.`}return null},qk=(e,t)=>Object.fromEntries(Object.entries(e).flatMap(([e,n])=>{let r=t[e]??``;return r===``||r===Hk(n)?[]:[[e,r]]})),Jk=/^[\w./:=@%+,-]+$/u,Yk=e=>Jk.test(e)?e:`'${e.replaceAll(`'`,String.raw`'\''`)}'`,Xk=(e,t,n)=>[`ork run`,Yk(e.name),`--detach`,...Object.entries(qk(e.inputs,t)).map(([e,t])=>`--input ${Yk(`${e}=${t}`)}`),...n.driver===``?[]:[`--driver ${n.driver}`],...n.inPlace?[`--in-place`]:[],...n.allowDirty?[`--allow-dirty`]:[],...n.machineClaude?[`--machine-claude`]:[]].join(` `),Zk=[],Qk=e=>{let t=sb(),n=yb(t.workflows.state);(0,H.useEffect)(()=>{e!==null&&t.workflows.load(e)},[t,e]);let r=n.status!==`idle`&&n.arg===e,i=r&&n.status===`ready`?n.data:Zk;return{list:i,reading:!r||n.status===`loading`,problem:Wk(e,r?n:{status:`idle`},i.length)}},$k=(e,t)=>[...document.querySelectorAll(`[${e}]`)].find(n=>n.getAttribute(e)===t)??null,eA=e=>$k(`data-run-heading`,e)??$k(`data-run-row`,e)??document.querySelector(`[data-run-workflow]`)??!0,tA=()=>{let e=(0,H.useRef)(null);return{onStarted:t=>{e.current=t},finalFocus:()=>{let t=e.current;return e.current=null,t===null||eA(t)}}},nA=(e,t)=>{let n=sb(),r=yb(n.projects.state),i=(0,H.useMemo)(()=>r.status===`ready`?r.data:[],[r]),[a]=(0,H.useState)(()=>n.runPreset.getValue()),[o,s]=(0,H.useState)(a?.project??null),[c,l]=(0,H.useState)(a?.workflow??null),[u,d]=(0,H.useState)({}),[f,p]=(0,H.useState)(Vk),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(!1),v=o??(i.length===1?i[0]?.id??null:null),{list:y,reading:b,problem:x}=Qk(v),S=c??(y.length===1?y[0]?.name:null),C=y.find(({name:e})=>e===S)??null,w=(0,H.useMemo)(()=>({...Uk(C?.inputs??{}),...u}),[C,u]),T=x??Kk(v,C,w);return(0,H.useEffect)(()=>{n.projects.load()},[n]),{projectsRead:r,projects:i,project:v,workflows:y,readingWorkflows:b,workflow:C,values:w,flags:f,blocked:T,refusal:m,starting:g,start:async()=>{if(T!==null||g||v===null||C===null)return;_(!0),h(null);let r=await n.startRun({project:v,workflow:C.name,inputs:qk(C.inputs,w),...f.driver===``?{}:{driver:f.driver},...f.inPlace?{inPlace:!0}:{},...f.allowDirty?{allowDirty:!0}:{},...f.machineClaude?{machineClaude:!0}:{}});_(!1),r.ok?(n.arriveAt(r.data.runId),nb.add({title:`Run ${r.data.runId} started`}),t(r.data.runId),e()):h(r.error)},setFlags:p,chooseProject:e=>{s(e),l(null),d({})},chooseWorkflow:e=>{l(e),d({})},setInput:(e,t)=>{d(n=>({...n,[e]:t}))}}},rA=({onDone:e,onStarted:t})=>{let n=nA(e,t),{projectsRead:r,projects:i,project:a,workflows:o,workflow:s}=n,{readingWorkflows:c}=n,{values:l,flags:u,blocked:d,refusal:f,starting:p}=n,m=(0,K.jsx)(FC,{children:(0,K.jsx)(Y,{onClick:e,variant:`ghost`,children:`Close`})});return r.status===`failed`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Bk,{error:`Cannot read the projects: ${r.error}`}),m]}):r.status===`ready`&&i.length===0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zk,{}),m]}):(0,K.jsxs)(`form`,{className:Mk.form,onSubmit:e=>{e.preventDefault(),n.start()},children:[(0,K.jsx)(oC,{empty:`No project matches.`,label:`Project`,onChange:n.chooseProject,options:i.map(({id:e})=>({value:e,label:e})),placeholder:`Type to find a project`,value:a}),(0,K.jsx)(oC,{disabled:a===null||o.length===0,empty:`No workflow matches.`,label:`Workflow`,onChange:n.chooseWorkflow,options:o.map(({name:e})=>({value:e,label:e})),placeholder:Gk(a,c,o.length),value:s?.name??null}),s===null?null:(0,K.jsx)(Pk,{onChange:n.setInput,values:l,workflow:s}),(0,K.jsx)(Ik,{flags:u,onChange:e=>{n.setFlags(t=>({...t,...e}))}}),s===null?null:(0,K.jsx)(lC,{command:Xk(s,l,u)}),(0,K.jsx)(`output`,{className:Mk.reason,children:d}),f===null?null:(0,K.jsx)(Bk,{error:f}),(0,K.jsxs)(FC,{children:[(0,K.jsx)(Y,{onClick:e,type:`button`,variant:`ghost`,children:`Cancel`}),(0,K.jsx)(Y,{disabled:d!==null||p,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:p?`Starting…`:`Start run`})]})]})},iA=()=>{let{runDialog:e,runPreset:t}=sb(),n=yb(e),{finalFocus:r,onStarted:i}=tA();return(0,K.jsx)(PC,{description:`Starts in the background, from the project's root.`,finalFocus:r,onOpenChange:n=>{n||t.setValue(null),e.setValue(n)},open:n,title:`Run workflow`,children:(0,K.jsx)(rA,{onDone:()=>{t.setValue(null),e.setValue(!1)},onStarted:i})})},aA=e=>/mac|iphone|ipad/iu.test(e),oA=(e,t,n)=>{let r=t.mod===!0;return e.code===t.code&&e.altKey===(t.alt===!0)&&e.shiftKey===(t.shift===!0)&&e.metaKey===(r&&n)&&e.ctrlKey===(t.ctrl===!0||r&&!n)},sA=(e,t)=>{let n=e.glyph??e.key;return[...e.ctrl===!0?[t?`⌃`:`Ctrl`]:[],...e.mod===!0?[t?`⌘`:`Ctrl`]:[],...e.alt===!0?[t?`⌥`:`Alt`]:[],...e.shift===!0?[t?`⇧`:`Shift`]:[],n]},cA=(e,t)=>[...e.ctrl===!0?[`Control`]:[],...e.mod===!0?[t?`Meta`:`Control`]:[],...e.alt===!0?[`Alt`]:[],...e.shift===!0?[`Shift`]:[],e.key].join(`+`),lA=(e,t,n)=>({code:e,key:t,...n===void 0?{}:{glyph:n},alt:!0,shift:!0}),uA={left:[`ArrowLeft`,`←`],right:[`ArrowRight`,`→`],up:[`ArrowUp`,`↑`],down:[`ArrowDown`,`↓`]},dA={palette:{code:`KeyK`,key:`K`,mod:!0},minimize:lA(`KeyM`,`M`),maximize:lA(`KeyX`,`X`),float:lA(`KeyF`,`F`),close:lA(`KeyW`,`W`),nextGroup:lA(`BracketRight`,`]`),previousGroup:lA(`BracketLeft`,`[`),goTo:e=>lA(`Digit${String(e)}`,String(e)),resize:e=>{let[t,n]=uA[e];return lA(t,t,n)},move:e=>{let[t,n]=uA[e];return{...lA(t,t,n),ctrl:!0}}},fA=9,pA=e=>e<=fA?dA.goTo(e):void 0,mA=()=>aA(navigator.platform),hA=()=>document.querySelector(`[data-modal]`)!==null,gA=(e,t)=>{(0,H.useEffect)(()=>{let n=mA(),r=r=>{let i=e.palette.getValue();if(!i&&hA())return;if(oA(r,dA.palette,n)){r.preventDefault(),e.palette.setValue(!i);return}if(i)return;let a=t.find(({shortcut:e})=>e!==void 0&&oA(r,e,n));a!==void 0&&(r.preventDefault(),a.disabled===void 0?a.run():e.announce(a.disabled))};return window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`keydown`,r)}},[e,t])},_A={shell:`_shell_aupfr_7`,bar:`_bar_aupfr_15`,name:`_name_aupfr_34`,logoOnDark:`_logoOnDark_aupfr_44`,logoOnLight:`_logoOnLight_aupfr_45`,spacer:`_spacer_aupfr_60`,status:`_status_aupfr_64`,middle:`_middle_aupfr_80`,dockArea:`_dockArea_aupfr_90`,rail:`_rail_aupfr_95`,stack:`_stack_aupfr_117`,stacked:`_stacked_aupfr_130`,stackedHeading:`_stackedHeading_aupfr_149`,stackedButton:`_stackedButton_aupfr_158`,stackedBody:`_stackedBody_aupfr_184`,visuallyHidden:`_visuallyHidden_aupfr_196`,count:`_count_aupfr_209`},vA=({workspace:e})=>{let{notifications:t}=sb(),n=vb(t.view,e=>e.unread);return(0,K.jsxs)(Sb,{label:n===0?`Notifications`:`Notifications, ${String(n)} unread`,onClick:()=>{e.goTo(`notifications`)},children:[(0,K.jsx)(Oy,{}),n===0?null:(0,K.jsx)(`span`,{className:_A.count,children:n>99?`99+`:n})]})},yA=H.createContext(void 0);function bA(e){let t=H.useContext(yA);if(t===void 0&&!e)throw Error(gc(33));return t}var xA=H.createContext(void 0);function SA(e){let t=H.useContext(xA);if(t===void 0&&!e)throw Error(gc(36));return t}var CA=H.createContext(void 0);function wA(e=!0){let t=H.useContext(CA);if(t===void 0&&!e)throw Error(gc(25));return t}var TA=H.createContext(null);function EA(e=`root`){let t=H.useContext(TA),n=H.useContext(xA);return t===null||n===void 0?null:(e===`submenu-trigger`?n.virtualFocus||n.parentVirtualFocus:n.virtualFocus)?t:null}var DA={visible:!0,ref:null};function OA(){return DA}function kA(e,t,n=`root`){let r=EA(n),i=((n===`submenu-trigger`?r?.useSubmenuTrigger:r?.useItem)??OA)({label:e.label,children:e.children,render:e.render}),a=Au(t,i.ref);return{visible:i.visible,ref:a,props:i.props}}function AA(e){e.preventDefault()}function jA(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,l=SA(),u=wA(!0),d=c.type===`submenu-trigger`,f=d?l.parentVirtualFocus:l.virtualFocus,p=(d&&l.parent.type===`menu`?l.parent.store:l.store).useState(`webkitAriaSelected`,n),{events:m}=a.useState(`floatingTreeRoot`),h=a.useState(`open`),g=u!==void 0,_=!f&&h&&n?0:-1;return H.useMemo(()=>({id:r,role:`menuitem`,tabIndex:_,"aria-selected":p,onMouseDown:f?AA:void 0,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&m.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&m.emit(`close`,{domEvent:e.nativeEvent,reason:lu})},onMouseUp(e){if(u){let t=u.initialCursorPointRef.current;if(u.initialCursorPointRef.current=null,g&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||g&&!Mc&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!g||e.button===2)&&c.type===`regular-item`&&Q_(s.current,e,{detail:1,pointerType:`mouse`})}}),[t,_,r,m,i,a.context.allowMouseUpTriggerRef,o,s,u,g,c.type,p,f])}var MA={type:`regular-item`};function NA(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=H.useRef(null),{getButtonProps:d,buttonRef:f}=$_({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=jA({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=H.useCallback(e=>Pf(p,{onMouseEnter(e){c.type===`submenu-trigger`&&c.setActive(e.nativeEvent)}},e,d),[p,d,c]),h=Au(u,f);return H.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var PA=H.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,{store:d}=SA(),f=KS({guess:!0,label:a}),p=hg(i),m=d.useState(`disabled`),h=d.useState(`isActive`,f.index),g=d.useState(`floatingNodeId`),_=d.useState(`itemProps`),v=s||m,{getItemProps:y,itemRef:b}=NA({closeOnClick:c,disabled:v,highlighted:h,id:p,store:d,nativeButton:o,nodeId:g,itemMetadata:MA});return qf(`div`,e,{state:{disabled:v,highlighted:h},props:[_,u,y],ref:[b,t,f.ref]})}),FA=H.forwardRef(function(e,t){let n=kA(e,t);return n.visible?(0,K.jsx)(PA,{...e,ref:n.ref}):null}),IA=H.createContext(void 0);function LA(){return H.useContext(IA)}function RA(e,t){let n=Zf(e.render);if(H.isValidElement(n)){let e=n.props;if(Object.hasOwn(e,`id`))return e.id??``}return e.id??t}function zA(e,t,n){let r=RA(e,t),i=r===t?void 0:r;return[r,H.useCallback(e=>n?.(e?i:void 0),[i,n])]}function BA(e,t,n){let r=Zf(e.render),i=H.isValidElement(r)?r.props:void 0,a=e[`aria-label`]??i?.[`aria-label`],o=e[`aria-labelledby`]??i?.[`aria-labelledby`];return o==null&&!a&&(o=t?t.id||void 0:n||void 0),o}var VA=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,id:o,initialFocus:s,...c}=e,{store:l,defaultFloatingId:u,setRenderedFloatingId:d,virtualFocus:f,orientation:p}=SA(),m=LA(),{side:h,align:g}=bA(),_=uk(!0)!=null,v=l.useState(`open`),y=l.useState(`transitionStatus`),b=l.useState(`popupProps`),x=l.useState(`mounted`),S=l.useState(`instantType`),C=l.useState(`activeTriggerElement`),w=l.useState(`parent`),T=l.useState(`lastOpenChangeReason`),E=l.useState(`rootId`),D=l.useState(`floatingRootContext`),O=l.useState(`floatingTreeRoot`),k=l.useState(`closeDelay`),A=l.useState(`hoverEnabled`),j=l.useState(`disabled`),M=l.useState(`openMethod`),N=l.useState(`activeTriggerId`),P=l.useState(`listElement`),[F,I]=zA(e,u,d),L=BA(e,C,N),R=w.type===`menu`?m:void 0,ee=w.type===`context-menu`,te=s??w.type!==`menu`;s===void 0&&P&&w.type!==`menu`&&(te=()=>l.state.activeIndex===null&&P),qp({open:v,ref:l.context.popupRef,onComplete(){v&&l.context.onOpenChangeComplete?.(!0)}}),H.useEffect(()=>{function e(e){l.setOpen(!1,G(e.reason,e.domEvent))}return O.events.on(`close`,e),()=>{O.events.off(`close`,e)}},[O.events,l]),Vm(D,{enabled:A&&!j&&!ee&&w.type!==`menubar`,closeDelay:k});let ne=l.useStateSetter(`popupElement`),{parentVirtualFocusRef:re,handleFocus:ie}=(H.useContext(TA)?.useParentHandoff??UA)(l,w,v,f),ae=qf(`div`,e,{state:{transitionStatus:y,side:h,align:g,open:v,nested:w.type===`menu`,instant:S},ref:[t,l.context.popupRef,ne,I],stateAttributesMapping:Hl,props:[b,{id:F,...P?{role:`presentation`}:{role:`menu`,"aria-orientation":p===`horizontal`?`horizontal`:void 0,"aria-labelledby":L},onKeyDown(e){R?.onPopupKeyDown?.(e),_&&wC.has(e.key)&&e.stopPropagation()},onFocus:ie},Kg(y),c,{"data-rootownerid":E}]}),oe=w.type===void 0||ee;(C||w.type===`menubar`&&T!==`outside-press`)&&(oe=!0);let se=R?.getReturnElement??re;return(0,K.jsx)(Np,{context:D,openInteractionType:M,modal:ee,disabled:!x,returnFocus:a??se??oe,explicitReturnFocus:a===void 0&&se?!1:void 0,initialFocus:te,restoreFocus:!0,getInsideElements:w.type===void 0?()=>[l.context.beforeTriggerFocusGuardRef.current]:void 0,externalTree:w.type===`menubar`?void 0:O,previousFocusableElement:C,nextFocusableElement:w.type===void 0?l.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:ae})}),HA={parentVirtualFocusRef:void 0,handleFocus:void 0};function UA(){return HA}var WA=H.forwardRef(function(e,t){let n=EA()?.Popup??VA;return(0,K.jsx)(n,{...e,ref:t})}),GA=H.createContext(void 0);function KA(){let e=H.useContext(GA);if(e===void 0)throw Error(gc(32));return e}var qA=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=SA();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,K.jsx)(GA.Provider,{value:n,children:(0,K.jsx)(mp,{ref:t,...r,portalOwnerRole:o})})});function JA(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=H.useRef(null),o=H.useRef(null),s=Kp(r);U(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),U(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var YA=H.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=op,style:g,..._}=e,{store:v,virtualFocus:y,syncHighlightedItem:b}=SA(),x=KA(),S=wA(!0),C=v.useState(`parent`),w=v.useState(`floatingRootContext`),T=v.useState(`floatingTreeRoot`),E=v.useState(`mounted`),D=v.useState(`open`),O=v.useState(`modal`),k=v.useState(`openMethod`),A=v.useState(`activeTriggerElement`),j=v.useState(`transitionStatus`),M=v.useState(`positionerElement`),N=v.useState(`instantType`),P=v.useState(`adaptiveOrigin`),F=v.useState(`lastOpenChangeReason`),I=v.useState(`floatingNodeId`),L=v.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=n,te=c,ne=l,re=s,ie=h;C.type===`context-menu`&&(ee=n??C.context?.anchor,re??=`start`,!o&&re!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ae=o,oe=re;C.type===`menu`?(ae??=`inline-end`,oe??=`start`,ie=e.collisionAvoidance??sp):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,oe??=`start`);let se=C.type===`context-menu`,ce=Ug({anchor:ee,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:te,align:oe,alignOffset:ne,arrowPadding:se?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:I,keepMounted:x,disableAnchorTracking:m,collisionAvoidance:ie,shift:se?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P,lazyFlip:y?`placement`:!1});H.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&v.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,G(bu)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[v,T.events,I]),H.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,G(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,v]);let le=Sc();H.useEffect(()=>{D||le.clear()},[D,le]),H.useEffect(()=>{function e(e){if(D&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&A&&A!==e.target){let e=v.select(`closeDelay`);e>0?le.isStarted()||le.start(e,()=>{v.setOpen(!1,G(bu))}):v.setOpen(!1,G(bu))}else le.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,v,le]),H.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:v.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,v,I,L]),JA({store:v,domReference:R,positionerElement:M,open:D});let ue={open:D,side:ce.side,align:ce.align,anchorHidden:ce.anchorHidden,nested:C.type===`menu`,instant:N},de=C.type===`menubar`&&C.context.modal;RS(D&&(de||O&&F!==`trigger-hover`),k===`touch`,M,A);let fe=qg(e,ue,{styles:ce.positionerStyles,transitionStatus:j,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),pe=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),me=null;return C.type===`menubar`?me=C.context.contentElement:C.type===void 0&&(me=A),(0,K.jsxs)(yA.Provider,{value:ce,children:[pe&&(0,K.jsx)(TS,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Zg(!D),cutout:me}),(0,K.jsx)(Sp,{id:I,children:(0,K.jsx)(dS,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,onMapChange:b,children:fe})})]})}),XA=H.createContext(null);function ZA(e){let t=H.useContext(XA);if(t===null&&!e)throw Error(gc(5));return t}var QA={...jm,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,keyboardOpen:e=>e.keyboardOpen,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,listElement:e=>e.listElement,triggerControlsId:(e,t)=>{let n=jm.triggerPopupId(e,t);return n?e.listElement?.id||n:void 0},filterTriggerProps:e=>e.filterTriggerProps,inputProps:e=>e.inputProps,webkitAriaSelected:(e,t)=>Pc&&e.inputFocused&&t?!0:void 0,highlightedItemId:e=>e.highlightedItem?.id||void 0,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType===`trigger-change`&&!jm.open(e)?void 0:e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},$A=class extends Sm{constructor(e,t,n=!1){let r=new lm,i=tj(r,t,n,e);super(i,ej(r),QA),this.observe(`parent`,e=>{e.type===`menu`?this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef:e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef)})}subscribeToParentMenu(){let e=this.state.parent;if(e.type!==`menu`)return;let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);return e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}setActiveIndex(e,t,n){if(this.state.activeIndex!==e){let r=(e===null?void 0:this.context.itemDomElements.current[e])===this.context.reportedItem;this.context.highlightReason=r?`none`:t,this.context.highlightEvent=r?void 0:n}this.set(`activeIndex`,e)}highlightItem(e,t,n){let r=this.context.itemDomElements.current.indexOf(e);r>-1&&this.setActiveIndex(r,t,n)}};function ej(e){return{positionerRef:H.createRef(),popupRef:H.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},highlightReason:`none`,highlightEvent:void 0,reportedItem:void 0,allowMouseUpTriggerRef:{current:!1},virtualFocusRef:void 0,triggerFocusTargetRef:H.createRef(),beforeTriggerFocusGuardRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function tj(e,t,n=!1,r){return{...Tm(e,t,n),disabled:!1,modal:!0,openMethod:null,keyboardOpen:!1,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,listElement:null,filterTriggerProps:mc,inputProps:mc,inputFocused:!1,highlightedItem:void 0,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new gp,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:mc,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var nj=H.createContext(null);function rj(e,t){return(e===`trigger-press`||e===`item-press`)&&t?.detail===0}function ij(e,t){return e===`list-navigation`||rj(e,t)}var aj=lc(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,onItemHighlighted:a,defaultOpen:o=!1,disabled:s=!1,modal:c,loopFocus:l=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0,isSubmenu:_=!1,virtualFocus:v=!1,virtualFocusRef:y,allowEscape:b=!0,resetOnPointerLeave:x=!0}=e,S=wA(!0),C=SA(!0),w=ZA(!0),T=C?.store,E=C?.virtualFocus??!1,D=H.useMemo(()=>_&&T?{type:`menu`,store:T}:w?{type:`menubar`,context:w}:S&&!T?{type:`context-menu`,context:S}:{type:void 0},[S,T,w,_]),O=hg(),k=hg(),[A,j]=H.useState(void 0),M=(A??k)||void 0,N=yp(),P=D.type===`menu`?D.store:void 0,F=(n??o)&&P?.state.transitionStatus===`starting`,I=ic(()=>F?P?.state.instantType:void 0).current,L=ic(()=>{let e=new $A({open:o,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:D,disabled:s,highlightItemOnHover:g,modal:D.type===void 0?c:void 0,rootId:O,instantType:I},M,N!=null);return e.context.virtualFocusRef=y,e}).current;L.useControlledProp(`openProp`,n),L.useControlledProp(`triggerIdProp`,m),L.useContextCallback(`onOpenChangeComplete`,i);let R=L.useState(`floatingTreeRoot`),ee=xp(R),te=L.useState(`open`),ne=L.useState(`activeTriggerElement`),re=L.useState(`positionerElement`),ie=L.useState(`hoverEnabled`),ae=L.useState(`disabled`),oe=L.useState(`lastOpenChangeReason`),se=L.useState(`parent`),ce=L.useState(`activeIndex`),le=L.useState(`keyboardOpen`),ue=L.useState(`payload`),de=L.useState(`floatingParentNodeId`),fe=H.useRef(null),pe=H.useRef(se.type!==`context-menu`),me=Sc(),he=H.useRef(!0),ge=Sc(),_e=de!=null,{openMethod:ve,triggerProps:ye}=Dx(te);L.useSyncedValues({disabled:s,highlightItemOnHover:g,modal:se.type===void 0?c:void 0,openMethod:ve,rootId:O}),am(L);let{forceUnmount:be,transitionStatus:xe}=om(te,L,()=>{L.set(`allowMouseEnter`,!1)},F),z=Kp(L.context.popupRef);H.useEffect(()=>{if(I===void 0)return;let e=()=>{L.state.instantType===I&&L.set(`instantType`,void 0)};if(!te){e();return}if(xe!==void 0)return;if(L.context.popupRef.current==null){e();return}let t=new AbortController;return z(e,t.signal),()=>{t.abort()}},[I,te,xe,z,L]),U(()=>{S&&!C?L.update({parent:{type:`context-menu`,context:S},floatingNodeId:ee,floatingParentNodeId:N}):(C||!L.select(`activeTriggerElement`))&&L.update({floatingNodeId:ee,floatingParentNodeId:N})},[S,C,ee,N,ne,L]),H.useEffect(()=>{te||(fe.current=null),se.type===`context-menu`&&(te?me.start(500,()=>{pe.current=!0}):(me.clear(),pe.current=!1))},[me,te,se.type]),U(()=>{!te&&!ie&&L.set(`hoverEnabled`,!0)},[te,ie,L]);let Se=q((e,t)=>{let n=t.reason;if(!e&&!L.select(`open`)||te===e&&t.trigger===ne&&oe===n)return;let i=nm(t);if(!e&&t.trigger==null&&(t.trigger=ne??void 0),r?.(e,t),t.isCanceled)return;L.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&n!==`item-press`&&a?.type===`click`&&a.pointerType===`touch`&&!he.current)return;e&&n===`trigger-focus`?(he.current=!1,ge.start(300,()=>{he.current=!0})):(he.current=!0,ge.clear());let o=!e&&(n===`escape-key`||n==null);fe.current=t.event;let s=tm(L.state,e,t.trigger,i());s.openChangeReason=n,s.keyboardOpen=e&&ij(n,a),s.instantType=se.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:rj(n,a)?`click`:o?`dismiss`:void 0,L.update(s)}),Ce=Vp({popupStore:L,floatingRootContext:L.state.floatingRootContext,floatingId:M,nested:N!=null,onOpenChange:Se}),we=Ce.context.events;U(()=>{let e=({open:e,eventDetails:t})=>Se(e,t);return we.on(`setOpen`,e),()=>{we?.off(`setOpen`,e)}},[we,Se]),U(()=>L.subscribeToParentMenu(),[L]);let Te=H.useCallback(()=>{L.setOpen(!1,G(Su))},[L]);H.useImperativeHandle(d,()=>({unmount:be,close:Te}),[be,Te]);let Ee;se.type===`context-menu`&&(Ee=se.context),H.useImperativeHandle(Ee?.positionerRef,()=>re,[re]),H.useImperativeHandle(Ee?.actionsRef,()=>({setOpen:Se}),[Se]);let De=Bp(Ce,{enabled:!ae,bubbles:{escapeKey:f&&se.type===`menu`},outsidePress(){return se.type!==`context-menu`||fe.current?.type===`contextmenu`||pe.current},externalTree:_e?R:void 0}),Oe=kg(),ke=Xm(Ce,{enabled:!ae,listRef:L.context.itemDomElements,activeIndex:ce,virtual:v,nested:se.type===`menubar`||!v&&se.type!==void 0,parentOrientation:se.type===`menubar`?se.context.orientation:void 0,loopFocus:l,focusItemOnOpen:v?le:void 0,allowEscape:v&&l&&b,orientation:u,triggerOrientation:v?`vertical`:u,rtl:Oe===`rtl`,disabledIndices:pc,onNavigate(e,t){L.setActiveIndex(e,Eb(t),t?.nativeEvent)},openOnArrowKeyDown:se.type!==`context-menu`&&!(v&&_),externalTree:!v&&_e?R:void 0,nestedReturnFocusRef:P?.context.virtualFocusRef,focusItemOnHover:g,resetOnPointerLeave:x}),Ae=H.useCallback(e=>{L.context.typingRef.current=e},[L]),je=Zm(Ce,{enabled:!ae&&!v,listRef:L.context.itemLabels,elementsRef:L.context.itemDomElements,activeIndex:ce,resetMs:500,onMatch:(e,t)=>{te&&e!==ce&&L.setActiveIndex(e,_u,t.nativeEvent)},onTyping:Ae}),Me=q(a),Ne=H.useRef(-1),Pe=q(()=>{let e=L.state.activeIndex,t=e===null?void 0:L.context.itemDomElements.current[e]??void 0;if(t?.isConnected===!1)return;let n=t===void 0?-1:e;if(Ne.current===n&&L.context.reportedItem===t)return;Ne.current=n,L.context.reportedItem=t,v&&L.set(`highlightedItem`,t);let{highlightReason:r,highlightEvent:i}=L.context;L.context.highlightReason=iu,L.context.highlightEvent=void 0,a&&Me(t,ru(r,i,{label:t===void 0?void 0:L.context.itemLabels.current[n]??void 0}))});U(()=>{Pe()},[ce,Pe]);let Fe=H.useMemo(()=>{if(!v)return ke.reference;if(!ke.trigger)return mc;let{onFocus:e,...t}=ke.trigger;return t},[v,ke.reference,ke.trigger]);L.useSyncedValue(`inputProps`,v?ke.reference??mc:mc);let Ie=H.useMemo(()=>{let e=Pf(je.reference,Fe,De.reference,{onMouseMove(){L.set(`allowMouseEnter`,!0)}},ye);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=te,e},[L,je.reference,Fe,De.reference,ye,te]),Le=H.useMemo(()=>{let e=Pf(ke.trigger,De.trigger,ye);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[ke.trigger,De.trigger,ye]);ic(()=>(L.update({inactiveTriggerProps:Le}),null)),sm(L,{floatingRootContext:Ce,activeTriggerProps:Ie,inactiveTriggerProps:Le,popupProps:H.useMemo(()=>Pf(Yp,{onMouseMove(){L.set(`allowMouseEnter`,!0),se.type===`menu`&&L.set(`hoverEnabled`,!1)},onClick(){L.select(`hoverEnabled`)&&L.set(`hoverEnabled`,!1)},onKeyDown(e){let t=L.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},je.floating,ke.floating,De.floating),[se.type,L,je.floating,ke.floating,De.floating]),itemProps:ke.item??mc});let Re=H.useMemo(()=>({store:L,parent:D,orientation:u,loopFocus:l,allowEscape:b,defaultFloatingId:k,setRenderedFloatingId:j,virtualFocus:v,parentVirtualFocus:E,syncHighlightedItem:Pe}),[L,D,u,l,b,k,v,E,Pe]),ze=typeof t==`function`?t({payload:ue}):t,Be=(0,K.jsxs)(xA.Provider,{value:Re,children:[p&&(0,K.jsx)(Qp,{handle:p,store:L}),ze]});return(se.type===void 0||se.type===`context-menu`)&&(Be=(0,K.jsx)(Cp,{externalTree:R,children:Be})),Be});function oj(e){let t=H.useContext(nj);if(t===null)return(0,K.jsx)(aj,{...e});let n=t.Root;return(0,K.jsx)(nj.Provider,{value:null,children:(0,K.jsx)(n,{...t.options,...e})})}function sj(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=X_(),{ref:i,index:a}=KS(e),o=n===a,s=H.useRef(null),c=Au(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function cj(e){let{render:t,className:n,style:r,state:i=mc,props:a=pc,refs:o=pc,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=sj({metadata:s});return qf(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function lj(e){if(Xc(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!cl(e))return lj(dl(e))}function uj(e,t){function n(n,r,i){let a=n.currentTarget;lp.flushSync(()=>{e.setOpen(!1,G(mu,n.nativeEvent,a))}),ef(a.isConnected?a:t.current,r,i)?.focus()}function r(t){n(t,-1,e.select(`positionerElement`))}function i(t){let r=e.select(`positionerElement`);r&&tf(t,r)?e.context.beforeContentFocusGuardRef.current?.focus():n(t,1,r)}return{handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function dj(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=H.useRef(!1);return H.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,qu(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:mc,[t,n,r])}var fj=uc(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=SA(!0),h=Mm(d)??m?.store;if(!h)throw Error(gc(85));let g=hg(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerControlsId`,g),x=H.useRef(null),S=mj(),C=X_(!0),w=bp(),T=H.useMemo(()=>w??new gp,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=im(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:xp(T),floatingParentNodeId:yp(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=$_({disabled:A,native:o});H.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=H.useRef(null),P=Sc(),F=q(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;W(N.current,t)||W(h.select(`positionerElement`),t)||t===N.current||t!=null&&lj(t)===h.select(`rootId`)||nS(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:yu})});H.useEffect(()=>{let e=qu(N.current);if(y&&h.select(`lastOpenChangeReason`)===`trigger-hover`)return e.addEventListener(`mouseup`,F,{once:!0}),()=>{e.removeEventListener(`mouseup`,F)}},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=Um(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:ah({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=pj(y,h.select(`lastOpenChangeReason`)),ee=Pp(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),te=Fm(v,{enabled:!A&&I}),ne=dj({open:y,enabled:O,mouseDownAction:`open`}),re=H.useMemo(()=>Pf(te.reference,ee.reference),[te.reference,ee.reference]),ie=h.useState(`triggerProps`,D),ae=h.useState(`filterTriggerProps`),{handlePreFocusGuardFocus:oe,handleFocusTargetFocus:se}=uj(h,x),ce={disabled:A,open:y},le=[N,t,M,E,x],ue=[re,L??mc,ie,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),qu(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},ae,O?{role:`menuitem`}:{},ne,p,j],de=qf(`button`,e,{enabled:!O,stateAttributesMapping:Bl,state:ce,ref:le,props:ue});return O?(0,K.jsx)(cj,{tag:`button`,render:n,className:r,style:i,state:ce,refs:le,props:ue,stateAttributesMapping:Bl}):y?(0,K.jsxs)(H.Fragment,{children:[(0,K.jsx)(Zu,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:oe},`${g}-pre-focus-guard`),(0,K.jsx)(H.Fragment,{children:de},g),(0,K.jsx)(Zu,{ref:h.context.triggerFocusTargetRef,onFocus:se},`${g}-post-focus-guard`)]}):(0,K.jsx)(H.Fragment,{children:de},g)});function pj(e,t){let n=Sc(),[r,i]=H.useState(!1);return U(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function mj(){let e=ZA(!0);return H.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var hj=H.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return qf(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),gj=(e,t)=>e===`separator`?`separator-${String(t)}`:e.label,_j=({entry:e})=>e===`separator`?(0,K.jsx)(hj,{className:a_.separator}):(0,K.jsxs)(FA,{className:a_.item,"data-variant":e.danger===!0?`danger`:`default`,disabled:e.disabled??!1,onClick:e.onSelect,children:[(0,K.jsx)(`span`,{children:e.label}),e.detail===void 0?null:(0,K.jsx)(`span`,{className:a_.itemDetail,children:e.detail}),e.hint===void 0?null:(0,K.jsx)(`kbd`,{children:e.hint})]}),vj=({trigger:e,entries:t})=>(0,K.jsxs)(oj,{children:[(0,K.jsx)(fj,{render:e}),(0,K.jsx)(qA,{children:(0,K.jsx)(YA,{align:`start`,className:a_.positioner,sideOffset:4,children:(0,K.jsx)(WA,{className:a_.popup,children:t.map((e,t)=>(0,K.jsx)(_j,{entry:e},gj(e,t)))})})})]}),yj=(e,{label:t})=>t===void 0?e:`${e} if ${t}`,bj={flow:e=>({from:[`leads to`,yj(e.to,e)],to:[`after`,yj(e.from,e)]}),back:e=>({from:[`goes back to`,yj(e.to,e)],to:[`comes back from`,yj(e.from,e)]}),owner:e=>({from:[`owns`,e.to],to:[`owned by`,e.from]}),message:e=>({from:[`can message`,e.to],to:[`can message`,e.from]})},xj=e=>{let t=new Map,n=(e,[n,r])=>{let i=t.get(e)??new Map;i.set(n,[...i.get(n)??[],r]),t.set(e,i)};for(let t of e){let{from:e,to:r}=bj[t.kind](t);n(t.from,e),n(t.to,r)}return new Map([...t].map(([e,t])=>[e,[...t].map(([e,t])=>`${e} ${t.join(`, `)}`).join(`; `)]))},Sj=12,Cj=(e,t,n)=>{let r=Math.abs(t.x-e.x)+Math.abs(t.y-e.y),i=r===0?0:n/r;return{x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}},wj=({x:e,y:t})=>`${String(e)} ${String(t)}`,Tj=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),Ej=e=>{let[t,...n]=e;if(t===void 0)return``;let r=[`M ${wj(t)}`];for(let[i,a]of n.entries()){let o=e[i]??t,s=n[i+1];if(s===void 0)r.push(`L ${wj(a)}`);else{let e=Math.min(Sj,Tj(o,a)/2,Tj(a,s)/2);r.push(`L ${wj(Cj(a,o,e))}`,`Q ${wj(a)} ${wj(Cj(a,s,e))}`)}}return r.join(` `)},Dj=({shape:e,points:t})=>{let[n,r,i,a]=t;return e===`curve`&&n!==void 0&&r!==void 0&&i!==void 0&&a!==void 0?`M ${wj(n)} C ${wj(r)} ${wj(i)} ${wj(a)}`:Ej(t)},Oj=(e,t)=>Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t)),kj=(e,t=28)=>{let n=[];for(let r of e.split(` `).flatMap(e=>Oj(e,t))){let e=n.at(-1);e!==void 0&&e.length+1+r.length<=t?n[n.length-1]=`${e} ${r}`:n.push(r)}return n},Aj=e=>e*14+2,jj=e=>{let t=e===void 0?[]:kj(e,21);return Math.ceil(90/4+Aj(t.length)/2+Mj)},Mj=6,Nj=6.6;Math.floor(144/Nj);var Pj={graph:`_graph_j4vty_7`,canvas:`_canvas_j4vty_15`,hint:`_hint_j4vty_45`,layer:`_layer_j4vty_58`,edges:`_edges_j4vty_67`,edgeLine:`_edgeLine_j4vty_82`,edgeHead:`_edgeHead_j4vty_95`,packet:`_packet_j4vty_136`,edgeLabel:`_edgeLabel_j4vty_160`,edgeLabelBack:`_edgeLabelBack_j4vty_174`,card:`_card_j4vty_180`,cardHead:`_cardHead_j4vty_264`,cardIcon:`_cardIcon_j4vty_273`,cardId:`_cardId_j4vty_284`,cardCost:`_cardCost_j4vty_295`,cardLabel:`_cardLabel_j4vty_306`,controls:`_controls_j4vty_320`,keyList:`_keyList_j4vty_345`,keyRow:`_keyRow_j4vty_356`,keyNames:`_keyNames_j4vty_360`,keyDoes:`_keyDoes_j4vty_369`},Fj=6,Ij=(e,t)=>{if(!(t===void 0||e!==`flow`&&e!==`owner`))return t.status===`running`?`flowing`:t.status===`queued`||t.status===`skipped`?`pending`:`taken`},Lj=e=>e.reduce((t,n,r)=>{let i=e[r-1];return i===void 0?t:t+Math.hypot(n.x-i.x,n.y-i.y)},0),Rj=({path:e,length:t})=>{let n=6/t;return(0,K.jsx)(`path`,{className:Pj.packet,d:e,"data-packet":``,pathLength:2,strokeDasharray:`${String(n)} ${String(1-n)}`})},zj=e=>{let t=e.at(-1),n=e.at(-2);if(t===void 0||n===void 0)return``;let r=Math.sign(t.x-n.x),i=Math.sign(t.y-n.y),a={x:t.x-r*Fj,y:t.y-i*Fj},o={x:-i*(Fj/2),y:Fj/2*r};return[t,{x:a.x+o.x,y:a.y+o.y},{x:a.x-o.x,y:a.y-o.y}].map(({x:e,y:t})=>`${String(e)},${String(t)}`).join(` `)},Bj=({label:e,at:t,limit:n})=>{let r=kj(e,n),i=Math.max(...r.map(e=>e.length))*Nj+8,a=Aj(r.length),o=t.y-(r.length-1)*14/2;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`rect`,{className:Pj.edgeLabelBack,height:a,rx:2,width:i,x:t.x-i/2,y:t.y-a/2}),(0,K.jsx)(`text`,{className:Pj.edgeLabel,children:r.map((e,n)=>(0,K.jsx)(`tspan`,{x:t.x,y:o+n*14,children:e},`${String(n)}:${e}`))})]})},Vj=(0,H.memo)(({edges:e,facts:t,quiet:n,width:r,height:i})=>(0,K.jsx)(`svg`,{"aria-hidden":`true`,className:Pj.edges,"data-quiet":n?``:void 0,focusable:`false`,height:i,width:r,children:e.map(e=>{let n=Ij(e.kind,t?.get(e.to)),r=Dj(e);return(0,K.jsxs)(`g`,{"data-kind":e.kind,"data-state":n,children:[(0,K.jsx)(`path`,{className:Pj.edgeLine,d:r}),e.kind===`message`?null:(0,K.jsx)(`polygon`,{className:Pj.edgeHead,points:zj(e.points)}),n===`flowing`?(0,K.jsx)(Rj,{length:Lj(e.points),path:r}):null,e.label===void 0||e.labelAt===void 0?null:(0,K.jsx)(Bj,{at:e.labelAt,label:e.label,limit:e.labelLimit})]},`${e.from}\n${e.to}\n${e.kind}`)})}));Vj.displayName=`EdgePaths`;var Hj=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Uj=(e,t,n)=>{let r=Hj(t),i=Hj(n);return e===`left`?i.x<r.x:e===`right`?i.x>r.x:e===`up`?i.y<r.y:i.y>r.y},Wj=(e,t,n)=>{let r=Hj(t),i=e===`left`||e===`right`,a=e=>{let t=Hj(e);return Math.abs(i?t.x-r.x:t.y-r.y)+Math.abs(i?t.y-r.y:t.x-r.x)*2};return n.toSorted((e,t)=>a(e)-a(t))[0]},Gj=(e,t,n)=>{let r=e.nodes.find(e=>e.id===t);if(r===void 0)return;let i=new Set(e.edges.flatMap(e=>e.from===t?[e.to]:e.to===t?[e.from]:[])),a=e.nodes.filter(e=>e.id!==t),o=a.filter(e=>i.has(e.id)&&Uj(n,r,e));return(Wj(n,r,n===`left`||n===`right`?[]:a.filter(e=>e.x===r.x&&Uj(n,r,e)))??Wj(n,r,o))?.id},Kj=5,qj=e=>e.flatMap((e,t)=>e.split(``).flatMap((e,n)=>e===`#`?[`M${String(n)} ${String(t)}h1v1h-1z`]:[])).join(``),Jj=e=>()=>(0,K.jsx)(`svg`,{"aria-hidden":`true`,fill:`currentColor`,focusable:`false`,height:`1em`,shapeRendering:`crispEdges`,viewBox:`0 0 ${String(Kj)} ${String(Kj)}`,width:`1em`,children:(0,K.jsx)(`path`,{d:qj(e)})}),Yj=Jj([`.....`,`.###.`,`.###.`,`.###.`,`.....`]),Xj=Jj([`....#`,`...#.`,`#.#..`,`.#...`,`.....`]),Zj=Jj([`..#..`,`.#.#.`,`#...#`,`.#.#.`,`..#..`]),Qj=Jj([`.#.#.`,`.#.#.`,`.#.#.`,`.#.#.`,`.#.#.`]),$j=Jj([`#...#`,`.#.#.`,`..#..`,`.#.#.`,`#...#`]),eM=Jj([`#.#.#`,`.....`,`#...#`,`.....`,`#.#.#`]),tM=Jj([`.....`,`.....`,`#####`,`.....`,`.....`]),nM=Jj([`#####`,`#...#`,`#...#`,`#...#`,`#####`]),rM=Jj([`..#..`,`..#..`,`#####`,`..#..`,`..#..`]),iM=Jj([`#....`,`.#...`,`..#..`,`.#...`,`#....`]),aM=Jj([`..#..`,`.###.`,`#.#.#`,`..#..`,`..#..`]),oM={badge:`_badge_derh1_8`,word:`_word_derh1_38`,icon:`_icon_derh1_50`,blink:`_blink_derh1_1`},sM={running:{Icon:Yj,word:`running`,tone:`running`},succeeded:{Icon:Xj,word:`succeeded`,tone:`succeeded`},waiting:{Icon:Zj,word:`waiting on you`,tone:`waiting`},paused:{Icon:Qj,word:`paused`,tone:`paused`},failed:{Icon:$j,word:`failed`,tone:`failed`},crashed:{Icon:$j,word:`crashed`,tone:`failed`},queued:{Icon:eM,word:`queued`,tone:`queued`},skipped:{Icon:tM,word:`skipped`,tone:`skipped`},interrupted:{Icon:nM,word:`interrupted`,tone:`interrupted`},budget_exhausted:{Icon:nM,word:`budget exhausted`,tone:`interrupted`},quota_exhausted:{Icon:nM,word:`quota spent`,tone:`interrupted`},timed_out:{Icon:nM,word:`timed out`,tone:`interrupted`}},cM=e=>sM[e].word,lM=e=>sM[e].tone,uM=({look:e,pill:t})=>{let{Icon:n,word:r,tone:i}=e;return(0,K.jsxs)(`span`,{className:oM.badge,"data-look":t?`pill`:`bare`,"data-tone":i,children:[(0,K.jsx)(`span`,{className:oM.icon,children:(0,K.jsx)(n,{})}),(0,K.jsx)(`span`,{className:oM.word,children:r})]})},dM=({status:e,word:t,pill:n=!1})=>{let r=sM[e];return(0,K.jsx)(uM,{look:{...r,word:t??r.word},pill:n})},fM={new:{Icon:rM,word:`new`,tone:`waiting`},triaged:{Icon:eM,word:`triaged`,tone:`queued`},accepted:{Icon:iM,word:`accepted`,tone:`queued`},resolved:{Icon:Xj,word:`resolved`,tone:`succeeded`},published:{Icon:aM,word:`published`,tone:`succeeded`},dismissed:{Icon:tM,word:`dismissed`,tone:`skipped`}},pM=({status:e,pill:t=!1})=>(0,K.jsx)(uM,{look:fM[e],pill:t}),mM={merged:{Icon:Xj,word:`merged`,tone:`succeeded`},unmerged:{Icon:iM,word:`not merged`,tone:`queued`},detached:{Icon:tM,word:`detached`,tone:`skipped`}},hM=({state:e})=>(0,K.jsx)(uM,{look:mM[e],pill:!1}),gM={due:{Icon:Zj,word:`due`,tone:`waiting`},waiting:{Icon:eM,word:`waiting`,tone:`queued`},done:{Icon:Xj,word:`done`,tone:`succeeded`},dropped:{Icon:tM,word:`dropped`,tone:`skipped`}},_M=({status:e,sent:t=!1,pill:n=!1})=>(0,K.jsx)(uM,{look:{...gM[e],...t&&e===`done`?{word:`sent`}:{}},pill:n}),vM={"agent.leader":`leader`,"agent.worker":`worker`,"agent.subagent":`sub-agent`,"control.split":`split`,"control.join":`join`,"control.router":`router`,"human.gate":`gate`,"workflow.call":`workflow call`,"mcp.call":`MCP call`},yM=e=>vM[e]??(e.startsWith(`tool.`)?`${e.slice(5)} tool`:e),bM=5e-5,xM=(e,t=[e])=>{if(!Number.isFinite(e))return`–`;let n=Math.abs(e);if(n!==0&&n<bM)return e>0?`<$0.0001`:`$0.00`;let r=t.some(e=>{let t=Math.abs(Number(e.toFixed(4)));return t!==0&&t<10});return`${e<0?`-`:``}$${n.toFixed(r?4:2)}`},SM=e=>{if(e<1e3)return String(e);let t=Math.round(e/100)/10;return t<1e3?`${t.toFixed(1)}k`:`${(Math.round(e/1e5)/10).toFixed(1)}M`},CM=e=>SM(e).replace(/\.0(?=[kM]$)/u,``),wM=(e,t)=>t?`≥ ${e}`:e,TM=e=>String(e).padStart(2,`0`),EM=e=>{let t=Math.max(Math.floor(e/1e3),0),n=Math.floor(t/60),r=`${TM(n%60)}:${TM(t%60)}`;return n<60?`${String(n)}:${TM(t%60)}`:`${String(Math.floor(n/60))}:${r}`},DM=(e,t,n)=>[e,...n.description===void 0||n.description===``?[]:[n.description],n.word??cM(n.status),...n.progress===void 0?[]:[n.progress],...n.costUsd===void 0?[]:[xM(n.costUsd)],...n.tokens===void 0?[]:[`${SM(n.tokens)} tokens`],...n.model===void 0?[]:[n.model],...n.unpriced===!0?[`no price`]:[],yM(t)].join(`, `),OM={tokens:`_tokens_xg8q2_6`},kM={tabIndex:0},AM=`At least this much. Some sessions ran on a driver that reports no price, so their dollars are not counted. Tokens count every session.`,jM=`No price for this driver. Counted tokens are shown.`,MM=({text:e,partial:t,focusable:n=!1})=>t?(0,K.jsx)(l_,{label:AM,children:(0,K.jsxs)(`span`,{...n?kM:{},children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`≥ ${e}`}),(0,K.jsx)(Dk,{children:`at least ${e}, partial`})]})}):e,NM=({count:e,unit:t=`tokens`})=>(0,K.jsx)(`span`,{className:OM.tokens,children:`${SM(e)} ${t}`}),PM=({count:e})=>(0,K.jsx)(l_,{label:jM,children:(0,K.jsx)(`span`,{children:(0,K.jsx)(NM,{count:e,unit:`tok`})})}),FM=`Input, output and cache-write tokens, as budgetTokens counts them. Cache reads are not counted.`,IM=`Everything sent to the model: input, cache-read and cache-write tokens. From cache is the share of it read from the cache.`,LM=()=>(0,K.jsx)(l_,{label:IM,children:(0,K.jsx)(`span`,{...kM,children:`Prompt tokens`})}),RM=()=>(0,K.jsx)(l_,{label:FM,children:(0,K.jsx)(`span`,{...kM,children:`Tokens counted`})}),zM=new Map([[`agent.leader`,(0,K.jsx)(Ry,{},`leader`)],[`agent.worker`,(0,K.jsx)(zy,{},`worker`)],[`agent.subagent`,(0,K.jsx)(By,{},`subagent`)],[`control.split`,(0,K.jsx)(Vy,{},`split`)],[`control.join`,(0,K.jsx)(Hy,{},`join`)],[`control.router`,(0,K.jsx)(Uy,{},`router`)],[`human.gate`,(0,K.jsx)(Wy,{},`gate`)],[`workflow.call`,(0,K.jsx)(Gy,{},`call`)],[`mcp.call`,(0,K.jsx)(Gy,{},`mcp`)],[`tool.gh`,(0,K.jsx)(Ky,{},`gh`)],[`tool.aws`,(0,K.jsx)(qy,{},`aws`)],[`tool.git`,(0,K.jsx)(Jy,{},`git`)]]),BM=({type:e})=>zM.get(e)??(0,K.jsx)(_y,{}),VM=(0,H.memo)(({node:e,facts:t,connections:n,selected:r,holding:i=!1,dimmed:a,tabbable:o,bind:s,onSelect:c,onFocused:l,onKey:u,onMenu:d,onHover:f})=>{let{id:p,type:m,x:h,y:g,width:_,height:v}=e,y=t.description??``,b=(0,K.jsxs)(`button`,{...c_(t.cli,n),"aria-current":r?`true`:void 0,"aria-label":DM(p,m,t),className:Pj.card,"data-graph-node":``,"data-dim":a?``:void 0,"data-holding":i?``:void 0,"data-selected":r?``:void 0,"data-tone":lM(t.status),onMouseEnter:()=>f?.(p),onMouseLeave:()=>f?.(null),onClick:()=>{c(p)},onContextMenu:d===void 0?void 0:e=>{e.preventDefault(),d(p)},onFocus:()=>{l(p)},onKeyDown:e=>{u(p,e)},ref:e=>{s(p,e)},style:{height:v,transform:`translate(${h}px, ${g}px)`,width:_},tabIndex:o?0:-1,type:`button`,children:[(0,K.jsxs)(`span`,{className:Pj.cardHead,children:[(0,K.jsx)(`span`,{className:Pj.cardIcon,children:(0,K.jsx)(BM,{type:m})}),(0,K.jsx)(`span`,{className:Pj.cardId,children:p}),t.unpriced===!0&&t.tokens!==void 0?(0,K.jsx)(`span`,{className:Pj.cardCost,children:(0,K.jsx)(NM,{count:t.tokens,unit:`tok`})}):null,t.unpriced!==!0&&t.costUsd!==void 0?(0,K.jsx)(`span`,{className:Pj.cardCost,children:xM(t.costUsd)}):null]}),y===``?null:(0,K.jsx)(`span`,{className:Pj.cardLabel,children:y}),(0,K.jsx)(dM,{status:t.status,word:t.word??t.progress})]});if(t.cli===void 0&&y===``)return b;let x=t.progress===void 0?void 0:`${t.word??cM(t.status)} · ${t.progress}`;return(0,K.jsx)(l_,{cli:t.cli,label:y===``?x:[y,t.word??cM(t.status),t.progress].filter(e=>e!==void 0).join(` · `),children:b})});VM.displayName=`NodeCard`;var HM=(e,t)=>{let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},UM=(e,t)=>{let n=e=>{e.preventDefault(),e instanceof WheelEvent&&t(e)};return e.addEventListener(`wheel`,n,{passive:!1}),()=>{e.removeEventListener(`wheel`,n)}},WM=(e,t)=>{let n=e.current?.getBoundingClientRect(),r=t.current?.getBoundingClientRect();return n===void 0||r===void 0?void 0:{x:n.x-r.x,y:n.y-r.y,width:n.width,height:n.height}},GM=.2,KM=e=>Math.min(2,Math.max(GM,e)),qM=(e,t)=>{if(e.width<=0||e.height<=0)return{x:0,y:0,k:1};let n=KM(Math.min(1,t.width/e.width,t.height/e.height));return{x:(t.width-e.width*n)/2,y:(t.height-e.height*n)/2,k:n}},JM=(e,t,n)=>{let r=KM(e.k*t),i=r/e.k;return{k:r,x:n.x-(n.x-e.x)*i,y:n.y-(n.y-e.y)*i}},YM=(e,t,n)=>({...e,x:e.x+t,y:e.y+n}),XM=(e,t,n,r)=>{let i={x:t.x*e.k+e.x,y:t.y*e.k+e.y,width:t.width*e.k,height:t.height*e.k};if(!$M(i,n))return e;let a=n.y-r-(i.y+i.height);return i.y+a>=r?YM(e,0,a):YM(e,n.x-r-(i.x+i.width),0)},ZM=(e,t,n,r,i=24)=>{let a=(e,t,n)=>{let r=e+t;return t+i*2>=n?(n-t)/2-e:e<i?i-e:r>n-i?n-i-r:0},o=a(t.x*e.k+e.x,t.width*e.k,n.width),s=a(t.y*e.k+e.y,t.height*e.k,n.height),c=o===0&&s===0?e:YM(e,o,s);return r===void 0?c:XM(c,t,r,i)},QM=(e,t,n=160)=>({x:(-n-e.x)/e.k,y:(-n-e.y)/e.k,width:(t.width+n*2)/e.k,height:(t.height+n*2)/e.k}),$M=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,eN=16,tN=12,nN=e=>{let t=eN*e;for(;t<tN;)t*=2;return t},rN=e=>{let t=e.map(e=>e.x),n=e.map(e=>e.y),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,width:Math.max(...t)-r,height:Math.max(...n)-i}},iN=.01,aN=e=>({nodes:new Set(e.nodes.map(e=>e.id)),edges:new Set(e.edges.keys())}),oN=()=>{},sN=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),cN=e=>{let t=(0,H.useRef)(null),n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useRef)({x:0,y:0,k:1}),a=(0,H.useRef)(!1),o=(0,H.useRef)(0),s=(0,H.useRef)(new Map),[c,l]=(0,H.useState)(()=>aN(e)),u=(0,H.useRef)(``),[d,f]=(0,H.useState)(e);e!==d&&(f(e),l(aN(e)));let p=(0,H.useMemo)(()=>e.edges.map(e=>rN(e.points)),[e]),m=(0,H.useCallback)(()=>{let e=t.current?.getBoundingClientRect();return{width:e?.width??0,height:e?.height??0}},[]),h=(0,H.useCallback)(()=>{o.current=0;let{x:r,y:a,k:s}=i.current,c=n.current;c!==null&&(c.style.transform=`translate(${String(r)}px, ${String(a)}px) scale(${String(s)})`);let d=t.current;if(d!==null){let e=`${String(nN(s))}px`;d.style.backgroundSize=`${e} ${e}`,d.style.backgroundPosition=`${String(r)}px ${String(a)}px`,d.style.setProperty(`--graph-zoom`,String(s))}let f=m();if(f.width===0||f.height===0)return;let h=QM(i.current,f),g=e.nodes.filter(e=>$M(h,e)).map(e=>e.id),_=[...p.keys()].filter(e=>{let t=p[e];return t!==void 0&&$M(h,t)}),v=`${g.join(`
92
+ `)}\n\n${_.join(`,`)}`;v!==u.current&&(u.current=v,l({nodes:new Set(g),edges:new Set(_)}))},[p,e,m]),g=(0,H.useCallback)(()=>{o.current===0&&(o.current=requestAnimationFrame(h))},[h]),_=(0,H.useCallback)(()=>{a.current=!1,i.current=qM(e,m()),g()},[e,g,m]),v=(0,H.useCallback)(e=>{a.current=!0,i.current=e,g()},[g]),y=(0,H.useCallback)(e=>{let{width:t,height:n}=m();v(JM(i.current,e,{x:t/2,y:n/2}))},[v,m]),b=(0,H.useCallback)((e,t)=>{v(YM(i.current,e,t))},[v]),x=(0,H.useCallback)(e=>{let n=m();if(n.width===0||n.height===0)return;let a=ZM(i.current,e,n,WM(r,t));a!==i.current&&v(a)},[v,m]);return(0,H.useEffect)(()=>{u.current=``,a.current?g():_()},[_,g]),(0,H.useEffect)(()=>{let e=t.current;return e===null?oN:HM(e,()=>{a.current?g():_()})},[_,g]),(0,H.useEffect)(()=>()=>{cancelAnimationFrame(o.current),o.current=0},[]),(0,H.useEffect)(()=>{let e=t.current;return e===null?oN:UM(e,t=>{if(t.ctrlKey||t.metaKey){let n=e.getBoundingClientRect();v(JM(i.current,Math.exp(-t.deltaY*iN),{x:t.clientX-n.left,y:t.clientY-n.top}))}else v(YM(i.current,-t.deltaX,-t.deltaY))})},[v]),{canvasRef:t,layerRef:n,controlsRef:r,shown:c,fit:_,zoom:y,pan:b,show:x,pointer:(0,H.useMemo)(()=>{let e=e=>{let t=e.currentTarget.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}},t=e=>{s.current.delete(e.pointerId)};return{onPointerDown:t=>{t.target instanceof Element&&t.target.closest(`button`)!==null||(t.currentTarget.setPointerCapture?.(t.pointerId),s.current.set(t.pointerId,e(t)))},onPointerMove:t=>{let n=s.current.get(t.pointerId);if(n===void 0)return;let r=e(t),a=[...s.current].find(([e])=>e!==t.pointerId)?.[1];if(a===void 0)v(YM(i.current,r.x-n.x,r.y-n.y));else{let e=sN(n,a);e>0&&v(JM(i.current,sN(r,a)/e,a))}s.current.set(t.pointerId,r)},onPointerUp:t,onPointerCancel:t}},[v])}},lN=H.createContext(void 0);function uN(e){let t=H.useContext(lN);if(t===void 0&&!e)throw Error(gc(47));return t}var dN={...jm,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!jm.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&jm.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>jm.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},fN=class extends Sm{constructor(e,t,n){let r=new lm;super(pN(e,r,t,n),mN(r),dN)}setOpen=(e,t)=>{let n=t.reason===ou,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=nm(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=tm(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),lp.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function pN(e,t,n,r=!1){let i={...Tm(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function mN(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:H.createRef(),beforeTriggerFocusGuardRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),stickIfOpenTimeout:new xc,stickIfOpen:!0,triggerElements:e}}var hN=lc(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=_N(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),cm(u,d),am(u);let{forceUnmount:m}=om(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),H.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),H.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,G(Su))}),[m,u]);let h=d||f||s!=null;return(0,K.jsxs)(lN.Provider,{value:u,children:[s&&(0,K.jsx)(Qp,{handle:s,store:u}),h&&(0,K.jsx)(vN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function gN(e){return uN(!0)?(0,K.jsx)(hN,{props:e}):(0,K.jsx)(Cp,{children:(0,K.jsx)(hN,{props:e})})}function _N(e,t){let n=Zp((e,n)=>new fN(t,e,n));return H.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function vN({store:e,modal:t}){let n=Bp(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return sm(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var yN=uc(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=uN(!0),h=Mm(s)??m;if(!h)throw Error(gc(74));let g=hg(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=H.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=im(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=Um(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:ah(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=Pp(v,{stickIfOpen:q(()=>h.context.stickIfOpen)}),k=Ex(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),A=h.useState(`triggerProps`,C),{getButtonProps:j,buttonRef:M}=$_({disabled:a,native:o}),N={open(e){return w?Bl.open(e):zl.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:F}=uj(h,x),I=qf(`button`,e,{state:{disabled:a,open:y},ref:[M,t,S,x],props:[O.reference,D,A,k,{[tp]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,j],stateAttributesMapping:N}),L=(0,K.jsx)(H.Fragment,{children:I},g);return E?(0,K.jsxs)(H.Fragment,{children:[(0,K.jsx)(Zu,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),L,(0,K.jsx)(Zu,{ref:h.context.triggerFocusTargetRef,onFocus:F})]}):L}),bN=H.createContext(void 0);function xN(){let e=H.useContext(bN);if(e===void 0)throw Error(gc(45));return e}var SN=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return uN().useState(`mounted`)||n?(0,K.jsx)(bN.Provider,{value:n,children:(0,K.jsx)(mp,{ref:t,...r})}):null}),CN=H.createContext(void 0);function wN(){let e=H.useContext(CN);if(!e)throw Error(gc(46));return e}var TN=H.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=sp,..._}=e,v=uN(),y=xN(),b=xp(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=Ug({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:v.useState(`adaptiveOrigin`)});JA({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let M=E===!0&&w!==`trigger-hover`;RS(C&&M,D===`touch`,O,T);let N=v.useStateSetter(`positionerElement`),P=qg(e,{open:C,side:j.side,align:j.align,anchorHidden:j.anchorHidden,instant:k},{styles:j.positionerStyles,transitionStatus:A,props:_,refs:[t,N],hidden:!S,inert:!C});return(0,K.jsxs)(CN.Provider,{value:j,children:[S&&M&&(0,K.jsx)(TS,{inert:Zg(!C),cutout:T}),(0,K.jsx)(Sp,{id:b,children:P})]})}),EN=H.createContext(void 0);function DN(){let[e,t]=H.useState(0),n=q(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:H.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var ON=H.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=uN(),l=wN(),u=uk(!0)!=null,{context:d,hasClosePart:f}=DN(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);qp({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Vm(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Xp(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=qf(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Yp,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&wC.has(e.key)&&e.stopPropagation()}},Kg(g),s],stateAttributesMapping:Hl});return(0,K.jsx)(Np,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:Xc(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,K.jsx)(EN.Provider,{value:d,children:M})})}),kN=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=uN(),s=hg(a.id);return o.useSyncedValueWithCleanup(`titleElementId`,s),qf(`h2`,e,{ref:t,props:[{id:s},a]})}),AN=({trigger:e,title:t,children:n})=>(0,K.jsxs)(gN,{children:[(0,K.jsx)(yN,{render:e}),(0,K.jsx)(SN,{children:(0,K.jsx)(TN,{className:a_.positioner,sideOffset:4,children:(0,K.jsxs)(ON,{className:a_.panel,children:[(0,K.jsx)(kN,{className:a_.title,children:t}),n]})})})]}),jN=1.25,MN=[{keys:[[`←`],[`→`],[`↑`],[`↓`]],does:`Move the view; on a node, follow its edges`},{keys:[[`Enter`],[`Space`]],does:`Select the node`},{keys:[[`Shift`,`F10`]],does:`The node's controls`},{keys:[[`Escape`]],does:`Back to the view`},{keys:[[`+`],[`-`]],does:`Zoom in or out`},{keys:[[`0`]],does:`Fit the graph`}],NN=()=>(0,K.jsx)(AN,{title:`Keys on the graph`,trigger:(0,K.jsx)(Sb,{label:`Keys on the graph`,children:(0,K.jsx)(Qy,{})}),children:(0,K.jsx)(`dl`,{className:Pj.keyList,children:MN.map(({keys:e,does:t})=>(0,K.jsxs)(`div`,{className:Pj.keyRow,children:[(0,K.jsx)(`dt`,{className:Pj.keyNames,children:e.map(e=>(0,K.jsx)(i_,{keys:e},e.join(`+`)))}),(0,K.jsx)(`dd`,{className:Pj.keyDoes,children:t})]},t))})}),PN=({controlsRef:e,zoom:t,fit:n,pan:r})=>(0,K.jsxs)(`div`,{className:Pj.controls,ref:e,children:[(0,K.jsx)(Sb,{keys:[`+`],label:`Zoom in`,onClick:()=>{t(jN)},children:(0,K.jsx)(Yy,{})}),(0,K.jsx)(Sb,{keys:[`-`],label:`Zoom out`,onClick:()=>{t(1/jN)},children:(0,K.jsx)(Xy,{})}),(0,K.jsx)(Sb,{keys:[`0`],label:`Fit the graph`,onClick:n,children:(0,K.jsx)(Zy,{})}),(0,K.jsx)(Sb,{keys:[`←`],label:`Pan left`,onClick:()=>{r(48,0)},children:(0,K.jsx)(dy,{})}),(0,K.jsx)(Sb,{keys:[`→`],label:`Pan right`,onClick:()=>{r(-48,0)},children:(0,K.jsx)(fy,{})}),(0,K.jsx)(Sb,{keys:[`↑`],label:`Pan up`,onClick:()=>{r(0,48)},children:(0,K.jsx)(py,{})}),(0,K.jsx)(Sb,{keys:[`↓`],label:`Pan down`,onClick:()=>{r(0,-48)},children:(0,K.jsx)(my,{})}),(0,K.jsx)(NN,{})]}),FN={status:`queued`},IN={ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`up`,ArrowDown:`down`},LN=()=>{},RN=(0,H.memo)(({layout:e,label:t,facts:n,selected:r,holding:i,onSelect:a=LN,onNodeMenu:o,live:s=!1,hovered:c=null,onHover:l})=>{let u=(0,H.useId)(),{canvasRef:d,layerRef:f,controlsRef:p,shown:m,fit:h,zoom:g,pan:_,show:v,pointer:y}=cN(e),[b,x]=(0,H.useState)(r),[S,C]=(0,H.useState)(r);r!==S&&(C(r),r!==void 0&&x(r));let w=(0,H.useRef)(new Map),T=(0,H.useRef)(null),E=(0,H.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e]),D=(0,H.useMemo)(()=>xj(e.edges),[e]),O=E.has(b??``)?b:e.nodes[0]?.id,k=i??r,A=(0,H.useRef)(k);(0,H.useEffect)(()=>{if(k===A.current)return;A.current=k;let e=E.get(k??``);e!==void 0&&v(e)},[E,k,v]),(0,H.useEffect)(()=>{let e=T.current;if(e===null)return;let t=w.current.get(e);t!==void 0&&(T.current=null,t.focus({preventScroll:!0}))});let j=(0,H.useCallback)((e,t)=>{t===null?w.current.delete(e):w.current.set(e,t)},[]),M=(0,H.useCallback)(e=>{x(e);let t=E.get(e);t!==void 0&&v(t)},[E,v]),N=(0,H.useCallback)((t,n)=>{let r=IN[n.key];if(r!==void 0){n.preventDefault(),n.stopPropagation();let i=Gj(e,t,r);if(i===void 0)return;let a=E.get(i);a!==void 0&&v(a),T.current=i,x(i)}else n.key===`Escape`?d.current?.focus({preventScroll:!0}):(n.key===`ContextMenu`||n.key===`F10`&&n.shiftKey)&&o!==void 0&&(n.preventDefault(),o(t))},[E,d,e,o,v]),P=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target===e.currentTarget,n={"+":()=>{g(jN)},"=":()=>{g(jN)},"-":()=>{g(1/jN)},0:h,...t?{ArrowLeft:()=>{_(48,0)},ArrowRight:()=>{_(-48,0)},ArrowUp:()=>{_(0,48)},ArrowDown:()=>{_(0,-48)}}:{}}[e.key];n!==void 0&&(e.preventDefault(),n())},F=e.nodes.filter(e=>m.nodes.has(e.id)||e.id===O),I=(0,H.useMemo)(()=>e.edges.filter((e,t)=>m.edges.has(t)),[e,m]);return(0,K.jsxs)(`div`,{className:Pj.graph,children:[(0,K.jsxs)(`div`,{...y,"aria-describedby":u,"aria-label":t,"aria-roledescription":`graph`,className:Pj.canvas,onKeyDown:P,ref:d,role:`application`,tabIndex:0,children:[(0,K.jsx)(`p`,{className:Pj.hint,id:u,children:`Arrow keys move the view; on a node, they move along its edges, Enter selects it, Shift+F10 asks for its controls, and Escape goes back to the view. Plus and minus zoom, and 0 fits the graph.`}),(0,K.jsxs)(`div`,{className:Pj.layer,ref:f,children:[(0,K.jsx)(Vj,{edges:I,facts:s?n:void 0,height:e.height,quiet:c!==null,width:e.width}),F.map(e=>(0,K.jsx)(VM,{bind:j,connections:D.get(e.id),dimmed:c!==null&&c!==e.id,facts:n?.get(e.id)??FN,holding:e.id===i,node:e,onFocused:M,onHover:l,onKey:N,onMenu:o,onSelect:a,selected:e.id===r,tabbable:e.id===O},e.id))]})]}),(0,K.jsx)(PN,{controlsRef:p,fit:h,pan:_,zoom:g})]})});RN.displayName=`GraphView`;var zN=8,BN=e=>new Map(e.map((e,t)=>[e,t])),VN=(e,t,n)=>{let r=BN(e),i=BN(t),a=n.flatMap(([e,t])=>{let n=r.get(e),a=i.get(t);return n===void 0||a===void 0?[]:[[n,a]]}),o=0;for(let[e,[t=0,n=0]=[]]of a.entries())for(let[r=0,i=0]of a.slice(e+1))(t-r)*(n-i)<0&&(o+=1);return o},HN=(e,t)=>e.slice(1).reduce((n,r,i)=>n+VN(e[i]??[],r,t),0),UN=(e,t,n)=>{let r=(e,r)=>{let i=(t.get(e)??[]).flatMap(e=>{let t=n.get(e);return t===void 0?[]:[t]});return i.length===0?r:i.reduce((e,t)=>e+t,0)/i.length};return e.map((e,t)=>({id:e,index:t,weight:r(e,t)})).toSorted((e,t)=>e.weight-t.weight||e.index-t.index).map(({id:e})=>e)},WN=(e,t)=>{let n=new Map,r=new Map;for(let[e,i]of t)n.set(i,[...n.get(i)??[],e]),r.set(e,[...r.get(e)??[],i]);let i=e.map(e=>[...e]),a=i,o=HN(i,t);for(let e=0;e<zN&&o>0;e+=1){let s=e%2==0,c=i.map(e=>[...e]),l=c.map((e,t)=>t);for(let e of s?l.slice(1):l.slice(0,-1).toReversed()){let t=BN(c[e+(s?-1:1)]??[]);c[e]=UN(c[e]??[],s?n:r,t)}i=c;let u=HN(i,t);u<o&&(o=u,a=i)}return a},GN=12,KN=(e,t)=>{let n=[],r=0;for(let[i]of e.entries())i>0&&(r+=t[i-1]??0),n.push(r);let i=[];for(let[t,r]of e.entries())for(i.push({sum:r-(n[t]??0),size:1});;){let e=i.at(-1),t=i.at(-2);if(e===void 0||t===void 0||t.sum/t.size<=e.sum/e.size)break;i.splice(-2,2,{sum:t.sum+e.sum,size:t.size+e.size})}return i.flatMap(({sum:e,size:t})=>Array.from({length:t},()=>e/t)).map((e,t)=>e+(n[t]??0))},qN=(e,t,n)=>{let r=new Map,i=new Map;for(let[e,n]of t)r.set(n,[...r.get(n)??[],e]),i.set(e,[...i.get(e)??[],n]);let a=new Map,o=(e,t)=>{let r=KN(t,e.slice(1).map((t,r)=>n(e[r]??``,t)));for(let[t,n]of e.entries())a.set(n,r[t]??0)};for(let t of e)o(t,t.map(()=>0));let s=(e,t)=>{let n=e.map(e=>{let n=t.flatMap(t=>t.get(e)??[]).map(e=>a.get(e)??0);return n.length===0?a.get(e)??0:n.reduce((e,t)=>e+t,0)/n.length});o(e,n)};for(let t=0;t<GN;t+=1){let n=t%2==0;for(let a of n?e:e.toReversed())s(a,t===11?[r,i]:[n?r:i])}return a},JN=e=>{let t=new Set(e.nodes.map(e=>e.id)),n=[],r=(e,t,r,i)=>{n.push({index:n.length,from:e,to:t,kind:r,label:i})},i=new Set;for(let{from:n,to:a,when:o,maxRounds:s}of e.edges)t.has(n)&&t.has(a)&&(i.add(`${n}\n${a}`),r(n,a,s!==void 0||n===a?`back`:`flow`,o));for(let{id:n,parent:a}of e.nodes)a!==void 0&&t.has(a)&&!i.has(`${a}\n${n}`)&&r(a,n,`owner`);for(let[n,i]of e.channels??[])t.has(n)&&t.has(i)&&n!==i&&r(n,i,`message`);return n},YN=(e,t)=>{let n=new Map;for(let e of t)n.set(e.from,[...n.get(e.from)??[],e]);let r=new Map,i=e=>{r.set(e,`open`);for(let t of n.get(e)??[]){let e=r.get(t.to);e===`open`?t.kind=`back`:e===void 0&&i(t.to)}r.set(e,`done`)};for(let t of e)r.has(t)||i(t)},XN=(e,t)=>{let n=new Set(t.filter(e=>e.kind===`flow`).map(e=>e.to)),r=t.filter(e=>e.kind===`flow`||e.kind===`owner`&&!n.has(e.to));YN(e,r);let i=r.filter(e=>e.kind!==`back`),a=new Map(e.map(e=>[e,0])),o=!0;for(let t=0;o&&t<=e.length;t+=1){o=!1;for(let{from:e,to:t}of i){let n=(a.get(e)??0)+1;n>(a.get(t)??0)&&(a.set(t,n),o=!0)}}return a},ZN=12,QN=(e,t)=>{let n=new Map,r=(e,t,r)=>{n.set(e,[...n.get(e)??[],{top:t,bottom:r}])};for(let n of e.values())r(t(n.id),n.y-ZN,n.y+n.height+ZN);return(e,t)=>{let i=t=>e.every(e=>(n.get(e)??[]).every(({top:e,bottom:n})=>t<=e||t>=n)),a=e.flatMap(e=>(n.get(e)??[]).flatMap(({top:e,bottom:t})=>[e,t])),o=t[0]??0,s=t.find(e=>i(e))??a.filter(e=>i(e)).toSorted((e,t)=>Math.abs(e-o)-Math.abs(t-o)||e-t)[0]??o;for(let t of e)r(t,s-ZN,s+ZN);return s}},$N=48,eP=36,tP=16,nP={flow:0,owner:0,back:14,message:-14},rP=(e,t)=>e.y+e.height/2+nP[t],iP=e=>e?.x??0,aP=e=>e?.y??0,oP=([e,t,n,r])=>({x:(iP(e)+3*iP(t)+3*iP(n)+iP(r))/8,y:(aP(e)+3*aP(t)+3*aP(n)+aP(r))/8}),sP=(e,t)=>({from:e.from,to:e.to,kind:e.kind,shape:`curve`,points:t,...e.label===void 0?{}:{label:e.label,labelAt:oP(t)}}),cP=(e,t,n)=>{let r=Math.max(eP,Math.abs(n.x-t.x)/2),i=n.x>=t.x?1:-1;return sP(e,[t,{x:t.x+r*i,y:t.y},{x:n.x-r*i,y:n.y},n])},lP=(e,t)=>{let n=Math.max(e.y,t.y),r=Math.min(e.y+e.height,t.y+t.height);return r-n<tP?void 0:(n+r)/2},uP=(e,t)=>{let n=t.x+t.width*.3,r=t.x+t.width*.7,i=t.y-30,a=sP(e,[{x:r,y:t.y},{x:r,y:i},{x:n,y:i},{x:n,y:t.y}]);return e.label===void 0?a:{...a,labelLimit:21}},dP=(e,t,n)=>{let r={x:t.x+t.width,y:rP(t,e.kind)},i={x:n.x+n.width,y:rP(n,e.kind)};return sP(e,[r,{x:r.x+$N,y:r.y},{x:i.x+$N,y:i.y},i])},fP=e=>{let t=[];for(let n of e){let e=t.at(-1),r=t.at(-2);(e?.x!==n.x||e.y!==n.y)&&(e!==void 0&&r!==void 0&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)&&t.pop(),t.push(n))}return t},pP=e=>{let t=e[0]??{x:0,y:0},n=-1;for(let[r,i]of e.slice(1).entries()){let a=e[r]??i,o=Math.abs(i.x-a.x)+Math.abs(i.y-a.y);o>n&&(n=o,t={x:(a.x+i.x)/2,y:(a.y+i.y)/2})}return t},mP=(e,t)=>{let n=fP(t);return{from:e.from,to:e.to,kind:e.kind,shape:`lines`,points:n,...e.label===void 0?{}:{label:e.label,labelAt:pP(n)}}},hP=e=>{let{chains:t,nodes:n,stopY:r,rankOf:i,columnX:a,columnWidth:o,gapWidth:s}=e,c=e=>a(e)+o,l=QN(n,i),u=t.filter(({stops:e})=>e.length>2),d=new Map,f=new Map;for(let{edge:e,stops:t}of u){let a=n.get(e.from),o=n.get(e.to);if(a!==void 0&&o!==void 0){let n=rP(a,e.kind),s=rP(o,e.kind),c=l(t.slice(1,-1).map(e=>{let[,t=``]=e.split(`:`);return Number(t)}),[n,s,...t.slice(1,-1).map(e=>r.get(e)??n)]);d.set(e.index,c);let u=Math.min(i(e.from),i(e.to)),p=Math.max(i(e.from),i(e.to));for(let t of[u,p-1])f.set(t,[...f.get(t)??[],e.index])}}let p=(e,t)=>{let n=f.get(e)??[];return c(e)+s(e)*(n.indexOf(t)+1)/(n.length+1)};return t.flatMap(({edge:e})=>{let t=n.get(e.from),r=n.get(e.to);if(t===void 0||r===void 0)return[];if(e.from===e.to)return[uP(e,t)];let a=i(e.from),o=i(e.to);if(a===o)return[dP(e,t,r)];let s=o>a,c={x:s?t.x+t.width:t.x,y:rP(t,e.kind)},l={x:s?r.x:r.x+r.width,y:rP(r,e.kind)},u=d.get(e.index);if(u===void 0){let n=lP(t,r);return[n===void 0?cP(e,c,l):cP(e,{...c,y:n},{...l,y:n})]}let f=Math.min(a,o),m=Math.max(a,o),h=p(s?f:m-1,e.index),g=p(s?m-1:f,e.index);return[mP(e,[c,{x:h,y:c.y},{x:h,y:u},{x:g,y:u},{x:g,y:l.y},l])]})},gP=({layers:e,chains:t,centers:n,space:r,reach:i})=>{let a=e=>n.get(e)??0,o=(e,t,o,s)=>{let c=a(e),l=t.map(e=>a(e)).toSorted((e,t)=>Math.abs(e-c)-Math.abs(t-c))[0];l!==void 0&&Math.abs(l-c)<i&&(o===void 0||a(o)+r(o,e)<=l)&&(s===void 0||l<=a(s)-r(e,s))&&n.set(e,l)},s=new Map,c=new Map;for(let{edge:e,stops:n}of t)e.kind===`flow`&&n.length===2&&(s.set(e.to,[...s.get(e.to)??[],e.from]),c.set(e.from,[...c.get(e.from)??[],e.to]));for(let t of e)for(let[e,n]of t.entries())o(n,s.get(n)??[],t[e-1],t[e+1]);for(let t of e)for(let[e,n]of t.entries())s.has(n)||o(n,c.get(n)??[],t[e-1],t[e+1])},_P=14,vP=(e,t)=>`\0${String(e.index)}:${String(t)}`,yP=e=>e.startsWith(`\0`),bP=e=>(t,n)=>{let r=e=>yP(e)?0:30,i=yP(t)||yP(n)?_P:20;return r(t)+r(n)+Math.max(i,e.get(n)??0)},xP=e=>{let t=new Map;for(let{from:n,to:r,label:i}of e)n===r&&t.set(n,Math.max(t.get(n)??0,jj(i)));return t},SP=(e,t)=>e.map(e=>{let n=t.get(e.from)??0,r=t.get(e.to)??0,i=r>n?1:-1,a=Array.from({length:Math.max(Math.abs(r-n)-1,0)},(t,r)=>vP(e,n+i*(r+1)));return{edge:e,stops:[e.from,...a,e.to]}}),CP=(e,t)=>e.flatMap(({stops:e})=>e.slice(1).flatMap((n,r)=>{let i=e[r]??n,a=t(i),o=t(n);return a===o?[]:a<o?[[i,n]]:[[n,i]]})),wP=(e,t)=>{let n=[...e.flatMap(e=>[e.x,e.x+e.width]),...t.flatMap(e=>e.points.map(e=>e.x))],r=[...e.flatMap(e=>[e.y,e.y+e.height]),...t.flatMap(e=>e.points.map(e=>e.y)),...t.flatMap(({label:e,labelAt:t,labelLimit:n})=>{if(e===void 0||t===void 0)return[];let r=Aj(kj(e,n).length)/2;return[t.y-r,t.y+r]})];return{minX:Math.min(...n),minY:Math.min(...r),maxX:Math.max(...n),maxY:Math.max(...r)}},TP=(e,t)=>{let{minX:n,minY:r,maxX:i,maxY:a}=wP(e,t),o=16-n,s=16-r,c=({x:e,y:t})=>({x:e+o,y:t+s});return{nodes:e.map(e=>({...e,...c(e)})),edges:t.map(e=>({...e,points:e.points.map(c),...e.labelAt===void 0?{}:{labelAt:c(e.labelAt)}})),width:i-n+32,height:a-r+32}},EP=e=>{let t=e.nodes.map(e=>e.id),n=JN(e),r=XN(t,n),i=SP(n,r),a=new Map;for(let{edge:e,stops:t}of i){let n=r.get(e.from)??0,i=(r.get(e.to)??0)>n?1:-1;for(let[e,r]of t.slice(1,-1).entries())a.set(r,n+i*(e+1))}let o=e=>r.get(e)??a.get(e)??0,s=Math.max(0,...r.values()),c=Array.from({length:s+1},()=>[]);for(let e of[...t,...a.keys()])c[o(e)]?.push(e);let l=CP(i,o),u=bP(xP(n)),d=WN(c,l),f=qN(d,l,u);gP({layers:d,chains:i,centers:f,space:u,reach:30});let p=new Map;for(let{edge:e,stops:t}of i)if(e.label!==void 0&&e.from!==e.to&&t.length===2&&o(e.from)!==o(e.to)){let t=Math.min(o(e.from),o(e.to)),n=Math.max(...kj(e.label).map(e=>e.length))*Nj+32;p.set(t,Math.max(p.get(t)??48,n))}let m=e=>p.get(e)??48,h=[0];for(let e=0;e<s;e+=1)h.push((h[e]??0)+152+m(e));let g=e=>h[e]??0,_=new Map(e.nodes.map(({id:e,type:t})=>{let n=o(e);return[e,{id:e,type:t,x:g(n),y:(f.get(e)??0)-30,width:152,height:60,rank:n}]})),v=hP({chains:i,nodes:_,stopY:f,rankOf:o,columnX:g,columnWidth:152,gapWidth:m});return TP([..._.values()],v)},DP=e=>typeof e==`object`&&!!e&&!Array.isArray(e),OP=e=>Array.isArray(e)?e.filter(e=>DP(e)):[],kP=e=>typeof e.description==`string`?e.description:void 0,AP=e=>e===!0?`On`:e===!1?`Off`:typeof e==`string`||typeof e==`number`?String(e):``,jP=e=>(Array.isArray(e.enum)?e.enum:`const`in e?[e.const]:e.type===`boolean`?[!0,!1]:void 0)?.map(e=>({value:e,label:AP(e)})),MP=e=>[...OP(e.anyOf),...OP(e.oneOf)],NP=e=>{let t=MP(e);if(t.length>0){let e=t.map(e=>jP(e));if(e.every(e=>e!==void 0))return{kind:`choice`,options:e.flat()};let[n]=t;return t.length===1&&n!==void 0?NP(n):{kind:`variants`,variants:t}}let n=jP(e);if(n!==void 0)return{kind:`choice`,options:n};if(e.type===`string`)return{kind:`text`,pattern:typeof e.pattern==`string`?e.pattern:void 0};if(e.type===`number`||e.type===`integer`)return{kind:`number`,integer:e.type===`integer`};if(e.type===`array`){let t=OP(e.prefixItems),[n]=t;return n===void 0?{kind:`list`,item:DP(e.items)?e.items:{}}:{kind:`list`,item:n,fixed:t.length}}if(e.type===`object`){if(DP(e.properties)){let t=Array.isArray(e.required)?e.required:[];return{kind:`object`,fields:Object.entries(e.properties).flatMap(([e,n])=>DP(n)?[{key:e,schema:n,required:t.includes(e)}]:[])}}return{kind:`record`,value:DP(e.additionalProperties)?e.additionalProperties:{}}}return{kind:`free`}},PP=(e,t)=>{let n=NP(e);switch(n.kind){case`text`:return typeof t==`string`;case`number`:return typeof t==`number`;case`choice`:return n.options.some(e=>e.value===t);case`list`:return Array.isArray(t);case`object`:case`record`:return DP(t);case`variants`:return n.variants.some(e=>PP(e,t));case`free`:return!0;default:return!1}},FP=(e,t)=>{let n=e.findIndex(e=>PP(e,t));return n===-1?0:n},IP=[[`text`,`Text`],[`number`,`Number`],[`choice`,`Choice`],[`list`,`List`],[`object`,`Details`],[`record`,`Named values`],[`variants`,`Other`],[`free`,`Anything`]],LP=e=>{let{kind:t}=NP(e);return IP.find(([e])=>e===t)?.[1]??t},RP=e=>{let t=NP(e);switch(t.kind){case`number`:return 0;case`choice`:return t.options[0]?.value;case`list`:return[];case`object`:case`record`:return{};case`text`:case`variants`:case`free`:return``;default:return t}},zP=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):``,BP={budgetUsd:`Budget (USD)`,budgetTokens:`Budget (tokens)`,plainEnv:`Plain environment`,env:`Environment`,cwd:`Working folder`,maxRounds:`Max rounds`,maxTurns:`Max turns`,maxMessages:`Max messages`,dayUsd:`Per day (USD)`,dayTokens:`Per day (tokens)`,weekUsd:`Per week (USD)`,monthUsd:`Per month (USD)`},VP=e=>{let t=BP[e];if(t!==void 0)return t;let n=e.replaceAll(/([a-z0-9])([A-Z])/gu,`$1 $2`).toLowerCase();return`${n.charAt(0).toUpperCase()}${n.slice(1)}`},HP=new Set([`prompt`,`instructions`,`question`,`script`,`body`,`command`]),UP=(e,t)=>HP.has(e)||typeof t==`string`&&t.includes(`
93
+ `),WP=e=>Number.isFinite(Number(e))&&String(Number(e))===e,GP=e=>{let t=e.trim();if(t!==``){if(t===`true`)return!0;if(t===`false`)return!1;if(t===`null`)return null;if(WP(t))return Number(t);if(!/^[[{"]/u.test(t))return e;try{return JSON.parse(t)}catch{return e}}},KP=e=>e===void 0?``:typeof e==`string`&&GP(e)===e?e:JSON.stringify(e),qP=(e,t)=>{let n=DP(e.properties)?e.properties.nodes:void 0,r=DP(n)?n.additionalProperties:void 0;return DP(r)?MP(r).find(e=>{let n=e.properties,r=DP(n)?n.type:void 0;return DP(r)&&r.const===t}):void 0},JP=e=>{let t=DP(e.properties)?e.properties.nodes:void 0,n=DP(t)?t.additionalProperties:void 0;return DP(n)?MP(n).flatMap(e=>{let t=e.properties,n=DP(t)?t.type:void 0;return DP(n)&&typeof n.const==`string`?[n.const]:[]}):[]},YP=e=>{let[t,n]=e.path;return t===`nodes`&&typeof n==`string`?n:void 0},XP=e=>{let t=e.path.at(-1);return e.message.endsWith(`received undefined`)&&typeof t==`string`?`${VP(t)} is required.`:XE(e)},ZP=e=>{let t=new Map;for(let n of e){let e=YP(n);e!==void 0&&t.set(e,[...t.get(e)??[],n])}return t},QP=(e,t)=>`${String(e)} ${t}${e===1?``:`s`}`,$P=(e,t)=>{let n=ZP(t),r=!t.some(({code:e})=>/^(schema|yaml)\./u.test(e));return new Map(e.nodes.map(({id:e})=>{let t=n.get(e)??[],i=t.filter(e=>e.severity===`error`).length,a=t.length-i;return i>0?[e,{status:`failed`,word:QP(i,`error`)}]:a>0?[e,{status:`waiting`,word:QP(a,`warning`)}]:[e,{status:`queued`,word:r?`no problems`:`not checked yet`}]}))},eF=(e,t)=>e.filter(e=>e.path.length===t.length&&e.path.every((e,n)=>e===t[n])),tF=(e,t)=>{let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(typeof n==`object`&&n&&!Array.isArray(n))n=Object.entries(n).find(([t])=>t===e)?.[1];else return;return n},nF=(e,t)=>e===t||e!==void 0&&t!==void 0&&JSON.stringify(e)===JSON.stringify(t),rF=e=>e.filter(e=>e.severity===`error`).length,iF=(e,t)=>{let n=(e.split(`.`).at(-1)??`node`).toLowerCase();if(!t.includes(n))return n;let r=2;for(;t.includes(`${n}-${String(r)}`);)r+=1;return`${n}-${String(r)}`},aF=new Set([`tool.gh`,`tool.aws`,`mcp.call`,`workflow.call`]),oF=e=>e.nodes.filter(({type:e})=>aF.has(e)).map(({id:e,type:t})=>`${e} (${t})`),sF=e=>e.nodes.filter(({type:e})=>e===`agent.leader`||e===`agent.worker`).map(({id:e})=>e),cF={panel:`_panel_16yrr_8`,tools:`_tools_16yrr_21`,chooser:`_chooser_16yrr_37`,create:`_create_16yrr_38`,actions:`_actions_16yrr_39`,connect:`_connect_16yrr_40`,notices:`_notices_16yrr_53`,status:`_status_16yrr_73`,error:`_error_16yrr_79`,empty:`_empty_16yrr_89`,body:`_body_16yrr_99`,palette:`_palette_16yrr_118`,inspector:`_inspector_16yrr_119`,middle:`_middle_16yrr_146`,canvas:`_canvas_16yrr_160`,problems:`_problems_16yrr_174`,clean:`_clean_16yrr_175`,problemsHead:`_problemsHead_16yrr_203`,walk:`_walk_16yrr_215`,problemList:`_problemList_16yrr_224`,types:`_types_16yrr_225`,edges:`_edges_16yrr_226`,problemLink:`_problemLink_16yrr_250`,heading:`_heading_16yrr_266`,subheading:`_subheading_16yrr_283`,type:`_type_16yrr_225`,fields:`_fields_16yrr_321`,edge:`_edge_16yrr_226`,testRow:`_testRow_16yrr_338`,field:`_field_16yrr_321`,choice:`_choice_16yrr_345`,problem:`_problem_16yrr_174`,problemIcon:`_problemIcon_16yrr_376`,problemWords:`_problemWords_16yrr_386`,hint:`_hint_16yrr_390`,group:`_group_16yrr_404`,summary:`_summary_16yrr_424`,row:`_row_16yrr_435`,rowName:`_rowName_16yrr_449`,edgeName:`_edgeName_16yrr_480`},lF=({builder:e})=>{let t=e.schema===null?[]:JP(e.schema),n=e.view?.graph.nodes.map(({id:e})=>e)??[],r=async t=>{let r=iF(t,n);await e.edit({op:`addNode`,id:r,node:{type:t}})&&e.select(r)};return(0,K.jsxs)(`nav`,{"aria-label":`Add a node`,className:cF.palette,children:[(0,K.jsx)(`h2`,{className:cF.heading,children:`Add a node`}),(0,K.jsx)(`ul`,{className:cF.types,children:t.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{className:cF.type,onClick:()=>{r(e)},type:`button`,children:[(0,K.jsx)(BM,{type:e}),yM(e)]})},e))})]})},uF=({problems:e,walk:t,onChoose:n})=>e.length===0?(0,K.jsxs)(`output`,{className:cF.clean,children:[`No problems found.`,t===null?``:` ${t}`]}):(0,K.jsxs)(`section`,{"aria-label":`Problems`,className:cF.problems,children:[(0,K.jsxs)(`div`,{className:cF.problemsHead,children:[(0,K.jsx)(`h2`,{className:cF.heading,children:rF(e)>0?`Fix these before saving`:`Warnings`}),t===null?null:(0,K.jsx)(`p`,{className:cF.walk,children:t})]}),(0,K.jsx)(`ul`,{className:cF.problemList,children:e.map(e=>{let t=YP(e),r=`${e.code} ${e.path.join(`.`)} ${e.message}`;return(0,K.jsx)(`li`,{children:t===void 0?(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:XP(e)})}):(0,K.jsxs)(`button`,{className:cF.problemLink,onClick:()=>{n(t)},type:`button`,children:[XP(e).startsWith(`\`${t}\``)?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`code`,{children:t}),`:`,` `]}),(0,K.jsx)(J,{text:XP(e)})]})},r)})})]}),dF={fields:[],canFail:!1,canDeclare:!1},fF=3,pF=(e,t)=>e.says?.[t]??dF,mF={is:`is`,isnt:`isn't`,above:`is above`,atLeast:`is at least`,below:`is below`,atMost:`is at most`,contains:`contains`,anyIs:`any is`,allAre:`all are`,isTrue:`is true`,isFalse:`is false`},hF={values:[`is`,`isnt`],statuses:[`anyIs`,`allAre`],number:[`above`,`atLeast`,`below`,`atMost`,`is`,`isnt`],boolean:[`isTrue`,`isFalse`],text:[`contains`,`is`,`isnt`]},gF=e=>hF[e.kind],_F=e=>e!==`isTrue`&&e!==`isFalse`,vF=e=>e.filter(({items:e})=>e===void 0),yF=(e,t)=>{let n=vF(t).find(({field:t})=>t===e.field);return n===void 0||!gF(n).includes(e.test)?!1:n.values===void 0||e.value===void 0||n.values.includes(e.value)},bF=({condition:e,when:t},n)=>{let r=e??{mode:`succeeds`};return r.mode===`test`&&!r.rows.every(e=>yF(e,n.fields))?{mode:`hand`,text:t??``}:r},xF=(e,t)=>{let n=gF(e)[0]??`is`;if(!_F(n))return{field:e.field,test:n};let r=e.values?.[0]??(e.kind===`number`?0:``);return{field:e.field,test:n,value:t??r}},SF=(e,t)=>{let n=vF(e.fields),r=n.find(({values:e})=>(e??[]).length>0)??n[0];return r===void 0?void 0:xF(r,r.values?.includes(t??``)===!0?t:void 0)},CF=e=>e.fields.flatMap(({field:e,values:t})=>e===`choice`?(t??[]).map(String):[]),wF=({condition:e},t)=>e===void 0||e.mode===`succeeds`||e.mode===`test`&&e.rows.some(({test:e,value:n})=>e===`is`&&n===t),TF=(e,t)=>{let n=e.edges.filter(({from:e})=>e===t);return n.length===0?[]:CF(pF(e,t)).filter(e=>!n.some(t=>wF(t,e)))},EF=(e,t,n)=>{let r=new Set([t]),i=[t];for(let t of i)for(let n of e.edges)n.from===t&&!r.has(n.to)&&(r.add(n.to),i.push(n.to));return r.has(n)},DF=e=>e===void 0?void 0:sO({mode:`test`,join:`all`,rows:[e]}),OF=(e,t,n)=>{let r=pF(e,t);if(EF(e,n,t))return DF(SF(r,`changes_requested`));let i=e.edges.filter(e=>e.from===t),a=CF(r);if(a.length>0){let[n]=i.length===0?a:TF(e,t);return n===void 0?void 0:DF({field:`choice`,test:`is`,value:n})}let o=i.find(({maxRounds:e})=>e!==void 0);return o?.condition===void 0?e.nodes.find(({id:e})=>e===t)?.type===`control.router`?DF(SF(r))??`true`:void 0:lO(o.condition)},kF=(e,t,n)=>{let r=OF(e,t,n);return{op:`connect`,from:t,to:n,...r===void 0?{}:{when:r},...EF(e,n,t)?{maxRounds:fF}:{}}},AF=e=>typeof e==`object`&&!!e&&!Array.isArray(e),jF=(e,t)=>{let n=new Set,r=[t];for(let t of r)for(let i of e.edges)i.to===t&&i.maxRounds===void 0&&!n.has(i.from)&&(n.add(i.from),r.push(i.from));return n.delete(t),n},MF=(e,t)=>{let n=jF(e,t);return e.nodes.filter(e=>n.has(e.id)).flatMap(t=>pF(e,t.id).fields.flatMap(({field:e,items:n})=>n===void 0?[]:[{node:t.id,field:e,items:n,template:`{{nodes.${t.id}.output.${e}}}`}]))},NF=e=>AF(e)?`from`in e?`from`:`items`in e?`items`:`once`:`once`,PF=10,FF=(e,t)=>{if(t===`once`)return;let n=AF(e)?e:{},r=Object.fromEntries(Object.entries(n).filter(([e])=>e===`maxParallel`||e===`onFailure`));return t===`items`?{items:[``],...r}:{from:``,maxItems:PF,...r}},IF=e=>{let t=Number(e.trim());return e.trim()!==``&&Number.isSafeInteger(t)&&t>0?t:void 0},LF=/^[A-Za-z_][A-Za-z0-9_-]*$/u,RF=[`string`,`number`,`integer`,`boolean`],zF=e=>{let t=new Map,n=[];for(let r of e.split(`,`)){let e=r.trim();if(e===``)continue;let[i=``,a=`string`,...o]=e.split(`:`).map(e=>e.trim());!LF.test(i)||o.length>0?n.push(`\`${e}\` isn't a field name. Use letters, digits, _ or -, then an optional :type.`):RF.some(e=>e===a)?t.has(i)?n.push(`\`${i}\` is listed twice.`):t.set(i,a):n.push(`\`${e}\` isn't a type. Use string, number, integer or boolean.`)}return{shape:Object.fromEntries(t),problems:n}},BF=e=>LF.test(e),VF=(e,t,n)=>n&&(t||e.startsWith(`agent.`)),HF=(e,t)=>e.startsWith(`agent.`)?t:`json.${t}`,UF=e=>{let t=(Array.isArray(e)?e:[]).map(e=>AF(e)?Object.keys(e):[]),[n=[]]=t;return n.filter(e=>t.every(t=>t.includes(e)))},WF=(e,t)=>{if(!AF(t))return[];if(`items`in t)return UF(t.items);let n=t.from;if(typeof n!=`string`)return[];let r=/^\{\{\s*nodes\.([^.\s]+)\.output\.(.+?)\s*\}\}$/u.exec(n);return pF(e,r?.[1]??``).fields.find(({field:e})=>e===r?.[2])?.items?.map(e=>e.field)??[]},GF=new Set([`prompt`,`command`,`arguments`,`inputs`,`env`,`ref`]),KF=(e,t,n,r)=>{let[i,,a]=t;if(i!==`nodes`||typeof a!=`string`||!GF.has(a)||!AF(n))return r;let o=WF(e,n);return[r,`Reads ${["`{{item}}` and `{{index}}`",...o.length===0?[]:[o.map(e=>`\`{{item.${e}}}\``).join(`, `)]].join(`, and `)}.`].filter(Boolean).join(` `)},qF=e=>{let t=NP(e),n=t.kind===`variants`?t.variants[0]:void 0,r=n===void 0?void 0:n.properties,i=AF(r)?r.items:void 0;return AF(i)?i:{}},JF=(e,t,n)=>{let r=jF(e,n);return e.nodes.flatMap(({id:n,type:i})=>{let a=pF(e,n),o=t===null?void 0:qP(t,i),s=o===void 0?void 0:o.properties;return r.has(n)&&!a.fields.some(({kind:e})=>e===`statuses`)&&VF(i,a.canDeclare,AF(s)&&`output`in s)?[{id:n,type:i,fields:a.fields.map(({field:e})=>e.replace(/^json\./u,``))}]:[]})},YF=(e,t)=>{e.context.change(e.path,()=>t)},XF=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ZF=({lines:e})=>e.map(e=>(0,K.jsxs)(`p`,{className:cF.problem,children:[(0,K.jsx)(`span`,{className:cF.problemIcon,children:(0,K.jsx)($j,{})}),(0,K.jsx)(`span`,{className:cF.problemWords,children:(0,K.jsx)(J,{text:e})})]},e)),QF=({label:e,unseen:t,shown:n,commit:r,description:i,required:a=!1,multiline:o=!1,number:s=!1})=>{let[c,l]=(0,H.useState)(n),[u,d]=(0,H.useState)(n),[f,p]=(0,H.useState)(null);return u!==n&&(d(n),p(null),n!==f&&l(n)),(0,K.jsx)(jk,{description:i,label:e,unseen:t,multiline:o,onChange:l,onCommit:()=>{c!==n&&c!==f&&(p(c),r(c))},required:a,type:s?`number`:`text`,value:c})},$F=`__not_set__`,eI=({options:e,...t})=>{let{name:n,schema:r,value:i,required:a}=t,o=[...a&&i!==void 0?[]:[{value:$F,label:a?`Choose one`:`Default`}],...e.map(e=>({value:zP(e.value),label:e.label}))],s=kP(r);return(0,K.jsxs)(`div`,{className:cF.choice,children:[(0,K.jsx)(Ok,{label:VP(n),onChange:n=>{YF(t,n===$F?void 0:e.find(e=>zP(e.value)===n)?.value)},options:o,value:i===void 0?o[0]?.value??``:zP(i)}),s===void 0?null:(0,K.jsx)(`p`,{className:cF.hint,children:(0,K.jsx)(J,{text:s})})]})},tI=({name:e,description:t,open:n,children:r})=>(0,K.jsxs)(`details`,{className:cF.group,open:n,children:[(0,K.jsx)(`summary`,{className:cF.summary,children:VP(e)}),t===void 0?null:(0,K.jsx)(`p`,{className:cF.hint,children:(0,K.jsx)(J,{text:t})}),(0,K.jsx)(`div`,{className:cF.fields,children:r})]}),nI=/^[A-Za-z_][A-Za-z0-9_-]*$/u,rI=e=>e.split(`,`).map(e=>e.trim()).filter(e=>e!==``).map(e=>e===`true`?!0:e===`false`?!1:Number.isFinite(Number(e))?Number(e):e),iI=({to:e,onDeclare:t})=>{let[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(``);if(!n)return(0,K.jsxs)(Y,{onClick:()=>{r(!0)},children:[`Add a field`,(0,K.jsxs)(Dk,{children:[`, to `,e]})]});let c=rI(o);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jk,{description:`A field of the JSON this node gives, such as state.`,label:`New field`,unseen:`, to ${e}`,onChange:a,value:i}),(0,K.jsx)(jk,{description:`Separated by commas. A run fails this node on anything else.`,label:`Its values`,unseen:`, to ${e}`,onChange:s,value:o}),(0,K.jsxs)(Y,{disabled:!nI.test(i)||c.length===0,onClick:()=>{t(i,c),r(!1),a(``),s(``)},children:[`Add `,i===``?`field`:i]})]})},aI=(e,t)=>{e?.querySelector(t)?.focus()},oI=({to:e,holders:t,onDeclare:n})=>{let r=(0,H.useRef)(null),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(``),f=t.find(({id:e})=>e===o)??t[0];if(f===void 0)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Y,{disabled:!0,children:[`Add a list`,(0,K.jsxs)(Dk,{children:[`, for `,e]})]}),(0,K.jsx)(`p`,{className:cF.hint,children:`No earlier node can declare a list. A list comes from a Claude node, tool or MCP call that runs before this one.`})]});if(!i)return(0,K.jsx)(`div`,{ref:r,children:(0,K.jsxs)(Y,{onClick:()=>{a(!0),queueMicrotask(()=>{aI(r.current,`input, [role=combobox]`)})},children:[`Add a list`,(0,K.jsxs)(Dk,{children:[`, for `,e]})]})});let p=zF(u),m=f.fields.includes(c),h=c!==``&&!BF(c)?[`\`${c}\` isn't a name. Use letters, digits, _ or -.`]:m?[`\`${c}\` is already a field of \`${f.id}\`.`]:[],g=()=>{a(!1),l(``),d(``),queueMicrotask(()=>{aI(r.current,`button`)})};return(0,K.jsxs)(`div`,{className:cF.fields,ref:r,children:[t.length<2?null:(0,K.jsx)(Ok,{label:`On node`,onChange:s,options:t.map(({id:e})=>({value:e,label:e})),value:f.id}),(0,K.jsx)(jk,{description:`A field of the JSON that node gives, such as tasks.`,label:`New list`,onChange:l,value:c}),(0,K.jsx)(ZF,{lines:h}),(0,K.jsx)(jk,{description:`Separated by commas: a name, or name:type. Types: string, number, integer, boolean. Empty for items with no fields.`,label:`Item fields`,onChange:d,value:u}),(0,K.jsx)(ZF,{lines:p.problems}),(0,K.jsxs)(Y,{disabled:!BF(c)||m||p.problems.length>0,onClick:()=>{n(f.id,c,p.shape),g()},children:[`Add `,c===``?`list`:c]}),(0,K.jsx)(Y,{onClick:g,children:`Cancel`})]})},sI=(e,t)=>t&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):e,cI=({row:e,fields:t,to:n,index:r,onChange:i})=>{let a=t.find(({field:t})=>t===e.field),o=`${r===0?``:`${String(r+1)} `}to ${n}`;if(a===void 0)return null;let s=a.values??[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ok,{label:`Field`,unseen:`, ${o}`,onChange:e=>{let n=t.find(t=>t.field===e);n!==void 0&&i(xF(n))},options:t.map(({field:e})=>({value:e,label:e})),value:e.field}),(0,K.jsx)(Ok,{label:`Test`,unseen:`, ${o}`,onChange:t=>{let n=t,{value:r}=xF(a);i({field:e.field,test:n,..._F(n)?{value:e.value??r??``}:{}})},options:gF(a).map(e=>({value:e,label:mF[e]})),value:e.test}),_F(e.test)&&s.length>0?(0,K.jsx)(Ok,{label:`Value`,unseen:`, ${o}`,onChange:t=>{i({...e,value:s.find(e=>String(e)===t)??t})},options:s.map(e=>({value:String(e),label:String(e)})),value:String(e.value)}):null,_F(e.test)&&s.length===0?(0,K.jsx)(QF,{commit:t=>{i({...e,value:sI(t,a.kind===`number`)})},label:`Value`,unseen:`, ${o}`,number:a.kind===`number`,shown:String(e.value??``)}):null]})},lI=e=>`row ${String(e)}`,uI=({condition:e,says:t,to:n,onChange:r})=>{let{rows:i,join:a}=e,o=e=>{r({mode:`test`,join:a,rows:e})},s=SF(t);return(0,K.jsxs)(K.Fragment,{children:[i.length<2?null:(0,K.jsx)(Ok,{label:`Which tests`,unseen:`, to ${n}`,onChange:e=>{r({mode:`test`,join:e===`any`?`any`:`all`,rows:i})},options:[{value:`all`,label:`All of these`},{value:`any`,label:`Any of these`}],value:a}),i.map((e,r)=>(0,K.jsxs)(`div`,{className:cF.testRow,children:[(0,K.jsx)(cI,{fields:vF(t.fields),index:r,onChange:e=>{o(i.map((t,n)=>n===r?e:t))},row:e,to:n}),i.length<2?null:(0,K.jsxs)(Y,{onClick:()=>{o(i.filter((e,t)=>t!==r))},children:[`Remove test `,String(r+1),(0,K.jsxs)(Dk,{children:[`, to `,n]})]})]},lI(r))),s===void 0?null:(0,K.jsxs)(Y,{onClick:()=>{o([...i,s])},children:[`Add a test`,(0,K.jsxs)(Dk,{children:[`, to `,n]})]})]})},dI=({to:e,says:t,condition:n,when:r,loop:i,gate:a,canBeOtherwise:o,onChange:s,onDeclare:c})=>{let[l,u]=(0,H.useState)(!1),d=SF(t),f=l?`hand`:n.mode,p=e=>{u(e===`hand`),e!==`hand`&&(e===`fails`?s(`!ok`):e===`otherwise`?s(`true`):e===`succeeds`?s():d!==void 0&&s(sO({mode:`test`,join:`all`,rows:[d]})))},m=[{value:`succeeds`,label:i?`Every round`:a?`Whatever the answer`:`When it succeeds`},...t.canFail?[{value:`fails`,label:`When it fails`}]:[],...d===void 0?[]:[{value:`test`,label:`When a test holds`}],...o?[{value:`otherwise`,label:`Otherwise`}]:[],{value:`hand`,label:`Written by hand`}];return(0,K.jsxs)(`div`,{className:cF.fields,children:[(0,K.jsx)(Ok,{label:`Follow this edge`,unseen:`, to ${e}`,onChange:p,options:m,value:f}),f===`test`&&n.mode===`test`?(0,K.jsx)(uI,{condition:n,onChange:e=>{s(sO(e))},says:t,to:e}):null,f===`hand`?(0,K.jsx)(QF,{commit:e=>{s(e===``?void 0:e)},description:`An expression, such as status == 'pass'. It's kept as you write it.`,label:`Condition`,unseen:`, to ${e}`,shown:r??``}):null,t.canDeclare?(0,K.jsx)(iI,{onDeclare:c,to:e}):null]})},fI=e=>e.when===void 0?{}:{whenWas:e.when},pI=({edge:e,last:t,builder:n})=>{let{from:r,to:i}=e,a=n.view?.graph;if(a===void 0)return null;let o=a.nodes.find(({id:e})=>e===r)?.type,s=pF(a,r),c=e.maxRounds===void 0?{}:{maxRounds:e.maxRounds},l=t=>({op:`setEdge`,from:r,to:i,...t===void 0?{}:{when:t},...c,...fI(e)}),u=e.maxRounds!==void 0;return(0,K.jsxs)(`li`,{className:cF.edge,children:[(0,K.jsxs)(`p`,{className:cF.edgeName,children:[`To `,i]}),(0,K.jsx)(dI,{canBeOtherwise:o===`control.router`&&t,condition:bF(e,s),gate:o===`human.gate`,loop:u,onChange:e=>{n.edit(l(e))},onDeclare:(e,t)=>{let[i]=t;n.edit({op:`set`,path:[`nodes`,r,`output`,`schema`,e],value:t},l(sO({mode:`test`,join:`all`,rows:[{field:`json.${e}`,test:`is`,...i===void 0?{}:{value:i}}]})))},says:s,to:i,when:e.when}),(0,K.jsx)(QF,{commit:t=>{n.edit({op:`setEdge`,from:r,to:i,...e.when===void 0?{}:{when:e.when},...t===``?{}:{maxRounds:Number(t)},...fI(e)})},description:`Needed on an edge that closes a loop.`,label:`Max rounds`,unseen:`, to ${i}`,number:!0,shown:e.maxRounds===void 0?``:String(e.maxRounds)}),(0,K.jsxs)(Y,{onClick:()=>{n.edit({op:`disconnect`,from:r,to:i,...fI(e)})},children:[`Remove edge`,(0,K.jsxs)(Dk,{children:[` to `,i]})]})]})},mI=({id:e,builder:t})=>{let n=t.view?.graph,[r,i]=(0,H.useState)(``);if(n===void 0)return null;let a=n.edges.filter(({from:t})=>t===e),o=n.edges.filter(({to:t})=>t===e),s=n.nodes.map(e=>e.id).filter(e=>!a.some(({to:t})=>t===e)).toSorted((t,n)=>Number(t===e)-Number(n===e)),c=s.includes(r)?r:s[0]??``,l=TF(n,e);return(0,K.jsxs)(`section`,{"aria-label":`Edges of ${e}`,className:cF.fields,children:[(0,K.jsx)(`h3`,{className:cF.subheading,children:`Edges`}),o.length===0?null:(0,K.jsxs)(`p`,{className:cF.hint,children:[`From `,o.map(({from:e})=>e).join(`, `)]}),a.length===0?(0,K.jsx)(`p`,{className:cF.hint,children:`Nothing follows this node yet.`}):(0,K.jsx)(`ul`,{className:cF.edges,children:a.map((e,n)=>(0,K.jsx)(pI,{builder:t,edge:e,last:n===a.length-1},`${e.to} ${String(a.slice(0,n).filter(({to:t})=>t===e.to).length)}`))}),l.length===0?null:(0,K.jsxs)(`p`,{className:cF.hint,children:[`Answering `,l.join(` or `),` ends the run here.`]}),s.length===0?null:(0,K.jsxs)(`div`,{className:cF.connect,children:[(0,K.jsx)(Ok,{label:`Connect to`,onChange:i,options:s.map(e=>({value:e,label:e})),value:c}),(0,K.jsx)(Y,{onClick:()=>{t.edit(kF(n,e,c))},children:`Connect`}),(0,K.jsx)(Y,{"aria-pressed":t.connecting,onClick:()=>{t.setConnecting(!t.connecting)},children:t.connecting?`Cancel picking`:`Pick a card`})]})]})},hI=()=>{},gI=e=>Array.isArray(e)?e:[],_I=({name:e,path:t,schema:n,value:r,context:i,item:a,fixed:o,minRows:s=0,draw:c})=>{let l=Array.isArray(r)?r:[];return(0,K.jsxs)(tI,{description:kP(n),name:e,open:l.length>0,children:[l.map((n,r)=>(0,K.jsxs)(`div`,{className:cF.row,children:[c({context:i,name:`${e} ${String(r+1)}`,path:[...t,r],required:!0,schema:a,value:n}),o===void 0&&l.length>s?(0,K.jsxs)(Y,{onClick:()=>{i.change(t,e=>{let t=gI(e).filter((e,t)=>t!==r);return t.length===0?void 0:t})},children:[`Remove `,VP(e).toLowerCase(),` `,r+1]}):null]},r)),o!==void 0&&l.length>=o?null:(0,K.jsxs)(Y,{onClick:()=>{i.change(t,e=>[...gI(e),RP(a)])},children:[`Add to `,VP(e).toLowerCase()]})]})},vI=({name:e,path:t,schema:n,value:r,context:i,valueSchema:a,draw:o})=>{let s=XF(r)?Object.entries(r):[],[c,l]=(0,H.useState)(``),u=c.trim(),d=s.some(([e])=>e===u);return(0,K.jsxs)(tI,{description:kP(n),name:e,open:s.length>0,children:[s.map(([e,n])=>(0,K.jsxs)(`div`,{className:cF.row,children:[o({context:i,name:e,path:[...t,e],required:!0,schema:a,value:n}),(0,K.jsxs)(Y,{onClick:()=>{i.change([...t,e],hI)},children:[`Remove `,e]})]},e)),(0,K.jsx)(jk,{description:d?`${u} is already here.`:void 0,label:`New name in ${VP(e).toLowerCase()}`,onChange:l,value:c}),(0,K.jsxs)(Y,{disabled:u===``||d,focusableWhenDisabled:!0,onClick:()=>{i.change([...t,u],e=>e===void 0?RP(a):e),l(``)},children:[`Add to `,VP(e).toLowerCase()]})]})},yI=e=>{let{name:t,value:n,variants:r,draw:i}=e,a=FP(r,n),o=r[a]??{};return(0,K.jsxs)(`div`,{className:cF.fields,children:[(0,K.jsx)(Ok,{label:`${VP(t)} as`,onChange:t=>{YF(e,RP(r[Number(t)]??{}))},options:r.map((e,t)=>({value:String(t),label:LP(e)})),value:String(a)}),i({...e,schema:o})]})},bI=e=>(0,K.jsx)(CI,{...e}),xI=({fields:e,value:t,path:n,context:r})=>{let i=XF(t)?t:{};return(0,K.jsx)(K.Fragment,{children:e.map(({key:e,schema:t,required:a})=>(0,K.jsx)(CI,{context:r,name:e,path:[...n,e],required:a,schema:t,value:i[e]},e))})},SI=e=>{let{name:t,path:n,schema:r,value:i,required:a,context:o}=e,s=NP(r),c=kP(r);switch(s.kind){case`text`:return(0,K.jsx)(QF,{commit:t=>{YF(e,t===``&&!a?void 0:t)},description:c,label:VP(t),multiline:UP(t,i),required:a,shown:typeof i==`string`?i:``});case`number`:return(0,K.jsx)(QF,{commit:t=>{YF(e,t===``?void 0:Number(t))},description:c,label:VP(t),number:!0,required:a,shown:typeof i==`number`?String(i):``});case`choice`:return(0,K.jsx)(eI,{...e,options:s.options});case`object`:return(0,K.jsx)(tI,{description:c,name:t,open:XF(i)&&Object.keys(i).length>0,children:(0,K.jsx)(xI,{context:o,fields:s.fields,path:n,value:i})});case`list`:return(0,K.jsx)(_I,{...e,draw:bI,fixed:s.fixed,item:s.item,minRows:typeof r.minItems==`number`?r.minItems:0});case`record`:return(0,K.jsx)(vI,{...e,draw:bI,valueSchema:s.value});case`variants`:return(0,K.jsx)(yI,{...e,draw:bI,variants:s.variants});case`free`:return(0,K.jsx)(QF,{commit:t=>{YF(e,GP(t))},description:c??`Text, or JSON for a number or a list. Quote text that looks like either, such as "5".`,label:VP(t),multiline:typeof i==`string`&&i.includes(`
94
+ `),shown:KP(i)});default:return s}},CI=e=>{let{path:t,context:n,schema:r}=e,i=n.problems(t),a=t.length===3?n.hint?.(t,kP(r)):void 0,o=a===void 0?e:{...e,schema:{...r,description:a}};return(0,K.jsxs)(`div`,{className:cF.field,"data-problem":i.length>0?``:void 0,children:[n.custom?.(e)??SI(o),(0,K.jsx)(ZF,{lines:i})]})},wI=e=>Array.isArray(e)?e:[],TI=({field:e,catalog:t})=>{let n=Array.isArray(e.value)?e.value.filter(e=>typeof e==`string`):[],[r,i]=(0,H.useState)(``),a=t=>{e.context.change(e.path,e=>wI(e).includes(t)?e:[...wI(e),t])},o=t.skills.filter(({name:e})=>!n.includes(e));return(0,K.jsxs)(`div`,{className:cF.fields,children:[(0,K.jsx)(`h3`,{className:cF.subheading,children:`Skills`}),n.length===0?(0,K.jsx)(`p`,{className:cF.hint,children:`It gets what the workflow and the project give it.`}):(0,K.jsx)(`ul`,{className:cF.edges,children:n.map(t=>(0,K.jsxs)(`li`,{className:cF.row,children:[(0,K.jsx)(`span`,{className:cF.rowName,children:t}),(0,K.jsxs)(Y,{onClick:()=>{e.context.change(e.path,e=>{let n=wI(e).filter(e=>e!==t);return n.length===0?void 0:n})},children:[`Remove `,t]})]},t))}),(0,K.jsx)(oC,{empty:`No skill matches.`,label:`Add a skill`,onChange:e=>{e!==null&&a(e)},options:o.map(({name:e,layer:t})=>({value:e,label:`${e} (${t})`})),placeholder:o.length===0?`No skills found`:`Type to find a skill`,value:null}),(0,K.jsx)(jk,{description:`Or a path to one, such as ./skills/checklist.`,label:`Skill by path`,onChange:i,onCommit:()=>{r.trim()!==``&&a(r.trim()),i(``)},value:r})]})},EI=(e,t)=>NP(t.schema).kind===`list`?(0,K.jsx)(TI,{catalog:e.catalog,field:t}):null,DI=`stop looking`,OI=({says:e,condition:t,until:n,onChange:r,onDeclare:i})=>{let[a,o]=(0,H.useState)(!1),s=bF({condition:t,when:n},e),c=SF(e),l=!a&&s.mode===`test`,u=n===void 0&&!a,d=u?`unset`:l?`test`:`hand`;return(0,K.jsxs)(`div`,{className:cF.fields,children:[(0,K.jsx)(Ok,{label:`Look until`,onChange:e=>{o(e===`hand`),e===`test`&&c!==void 0&&r(sO({mode:`test`,join:`all`,rows:[c]}))},options:[...u?[{value:`unset`,label:`Choose one`}]:[],...c===void 0?[]:[{value:`test`,label:`A test holds`}],{value:`hand`,label:`Written by hand`}],value:d}),l?(0,K.jsx)(uI,{condition:s,onChange:e=>{r(sO(e))},says:e,to:DI}):null,d===`hand`?(0,K.jsx)(QF,{commit:e=>{r(e===``?void 0:e)},description:`An expression, such as json.state != 'pending'. It's kept as you write it.`,label:`Condition`,shown:n??``,unseen:`, to ${DI}`}):null,e.canDeclare?(0,K.jsx)(iI,{onDeclare:i,to:DI}):null]})},kI=({builder:e,id:t,field:n})=>{let r=e.view?.graph;return r===void 0?null:(0,K.jsx)(OI,{condition:r.untils?.[t],onChange:e=>{YF(n,e)},onDeclare:(n,r)=>{let[i]=r;e.edit({op:`set`,path:[`nodes`,t,`output`,`schema`,n],value:r},{op:`set`,path:[`nodes`,t,`watch`,`until`],value:`json.${n} == ${JSON.stringify(i)}`})},says:pF(r,t),until:typeof n.value==`string`?n.value:void 0})},AI=`__none__`,jI=(e,t)=>{let{document:n}=e.view??{},r=XF(n)?n.inputs:void 0,i=XF(r)?r[String(t.path[1])]:void 0,a=XF(i)?i.type:void 0,o=typeof a==`string`?a:`string`;return t.value===void 0||typeof t.value===o?SI({...t,schema:{...t.schema,type:o}}):null},MI=(e,t,n)=>{let r=e.view?.graph;if(r===void 0)return null;let i=n.path.at(-1),a=typeof n.value==`string`?n.value:void 0;if(i===`parent`&&t!==null){let e=r.nodes.map(e=>e.id).filter(e=>e!==t);return(0,K.jsx)(Ok,{label:`Owner`,onChange:e=>{YF(n,e===AI?void 0:e)},options:[...n.required?[]:[{value:AI,label:`None`}],...e.map(e=>({value:e,label:e}))],value:a??AI})}if(i===`n`&&t!==null&&n.path.length===3){let e=r.edges.filter(({to:e})=>e===t).length,i=typeof n.value==`number`?n.value:1,a=Array.from({length:Math.max(e,i,1)},(e,t)=>String(t+1));return(0,K.jsx)(Ok,{label:`How many inputs to wait for`,onChange:e=>{YF(n,Number(e))},options:a.map(e=>({value:e,label:e})),value:String(i)})}if((i===`recommended`||i==="default")&&t!==null&&n.path.length===3){let e=pF(r,t).fields.find(({field:e})=>e===`choice`)?.values??[];if(e.length>0)return(0,K.jsx)(Ok,{label:i==="default"?`If it times out`:`Recommended`,onChange:e=>{YF(n,e===AI?void 0:e)},options:[{value:AI,label:`None`},...e.map(e=>({value:String(e),label:String(e)}))],value:a??AI})}return i===`until`&&t!==null&&n.path.includes(`watch`)?(0,K.jsx)(kI,{builder:e,field:n,id:t}):i===`to`&&n.path.includes(`notify`)?(0,K.jsx)(Ok,{label:`To`,onChange:e=>{YF(n,e)},options:sF(r).map(e=>({value:e,label:e})),value:a??``}):i===`agent`?(0,K.jsx)(oC,{empty:`No agent matches.`,label:`Agent`,onChange:e=>{YF(n,e??void 0)},options:e.catalog.agents.map(({name:e,source:t})=>({value:e,label:`${e} (${t})`})),placeholder:`Type to find an agent`,value:a??null}):i==="default"&&n.path[0]===`inputs`?jI(e,n):i===`skills`?EI(e,n):null},NI=`__not_chosen__`,PI=[{value:`once`,label:`Once`},{value:`items`,label:`Once per item, listed here`},{value:`from`,label:`Once per item of a list from an earlier node`}],FI=({field:e,label:t,description:n,required:r,bad:i,onBad:a})=>(0,K.jsxs)(`div`,{className:cF.field,children:[(0,K.jsx)(QF,{commit:t=>{let n=IF(t),i=t.trim()===``&&!r;a(n===void 0&&!i),(n!==void 0||i)&&YF(e,n)},description:n,label:t,number:!0,required:r,shown:typeof e.value==`number`?String(e.value):``}),(0,K.jsx)(`div`,{role:`alert`,children:(0,K.jsx)(ZF,{lines:i?[`${t} needs a whole number above 0.`]:[]})})]}),II=({builder:e,id:t,field:n})=>{let r=e.view?.graph,i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),l=NF(n.value),[u,d]=(0,H.useState)(l!==`once`);if(l!==`once`&&!u&&d(!0),r===void 0)return null;let{value:f,context:p,path:m}=n,h=XF(f)?f:{},g=typeof h.from==`string`?h.from:``,_=MF(r,t),v=_.find(({template:e})=>e===g),y=JF(r,e.schema,t),b=async(t,n,r)=>{let a=`{{nodes.${t}.output.${HF(y.find(e=>e.id===t)?.type??``,n)}}}`;await e.edit({op:`set`,path:[`nodes`,t,`output`,`schema`,n],value:{list:r}},{op:`set`,path:[...m,`from`],value:a}),i.current?.querySelectorAll(`[role=combobox]`)[1]?.focus()},x=e=>({...n,name:e,path:[...m,e],value:h[e]});return(0,K.jsx)(tI,{description:kP(n.schema),name:`forEach`,open:u,children:(0,K.jsxs)(`div`,{className:cF.fields,ref:i,children:[(0,K.jsx)(Ok,{label:`Run this node`,onChange:e=>{YF(n,FF(f,e))},options:PI,value:l}),l===`once`?null:(0,K.jsx)(`p`,{className:cF.hint,children:(0,K.jsx)(J,{text:`Items are \`${t}.0\` to \`${t}.n\`. Their results gather into \`results\`, \`statuses\` and \`count\`.`})}),l===`items`?(0,K.jsx)(CI,{...x(`items`),required:!0,schema:qF(n.schema)}):null,l===`from`?(0,K.jsxs)(`div`,{className:cF.field,children:[(0,K.jsx)(Ok,{label:`List from`,onChange:e=>{let t=_.find(({template:t})=>t===e);t!==void 0&&p.change([...m,`from`],()=>t.template)},options:[...g===``?[{value:NI,label:`Choose a list`}]:[],...g===``||v!==void 0?[]:[{value:g,label:`${g} (not offered)`}],..._.map(({node:e,field:t,template:n})=>({value:n,label:`${t} (from ${e})`}))],value:g===``?NI:g}),(0,K.jsx)(ZF,{lines:p.problems([...m,`from`])}),v===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:cF.hint,children:(0,K.jsx)(J,{text:`Writes \`${v.template}\``})}),(0,K.jsx)(`p`,{className:cF.hint,children:(0,K.jsx)(J,{text:v.items.length===0?`Items have no declared fields.`:`Each item has ${v.items.map(e=>`\`${e.field}\``).join(`, `)}.`})})]}),_.length===0?(0,K.jsx)(`p`,{className:cF.hint,children:`No earlier node declares a list. Add one below, or connect this node after one that does.`}):null,(0,K.jsx)(oI,{holders:y,onDeclare:(e,t,n)=>{b(e,t,n)},to:t})]}):null,l===`from`?(0,K.jsx)(FI,{bad:a,description:`A longer list asks whether to stop, run this many, or run all.`,field:x(`maxItems`),label:`Most items`,onBad:o,required:!0}):null,l===`once`?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(FI,{bad:s,description:"Default: the run's `limits.concurrency`.",field:x(`maxParallel`),label:`Most at once`,onBad:c,required:!1}),(0,K.jsx)(Ok,{label:`When an item fails`,onChange:e=>{p.change([...m,`onFailure`],()=>e===`stop`?`stop`:void 0)},options:[{value:`finish`,label:`Run every item`},{value:`stop`,label:`Start no more items`}],value:h.onFailure===`stop`?`stop`:`finish`})]})]})})},LI=(e,t,n)=>n.path.at(-1)===`forEach`&&t!==null&&n.path.length===3?(0,K.jsx)(II,{builder:e,field:n,id:t}):null,RI=e=>typeof e!=`string`||e.includes(`{{`)?void 0:ZE(e,mD).driver,zI="A model for the run's driver, or `<driver>.<model>`, such as `claude-code.sonnet`.",BI=(e,t)=>{let n=RI(e);return[t??zI,...n===void 0?[]:[`Runs on ${n}.`]].join(` `)},VI=(e,t)=>{let n=RI(e);return n===void 0||typeof t!=`string`||t===n?void 0:`Model names ${n}, but this node's driver is ${t}. Make them match, or drop the prefix.`},HI=e=>e.at(-1)===`model`&&(e[0]===`nodes`&&e.length===3||e[0]===`defaults`&&e.length===2),UI=(e,t,n)=>({custom:n=>LI(e,t,n)??MI(e,t,n),hint:(t,n)=>{let r=e.view?.graph,i=e.view?.document,a=XF(i)?i.nodes:void 0,o=XF(a)?a[String(t[1])]:void 0,s=r===void 0||!XF(o)?n:KF(r,t,o.forEach,n);return HI(t)&&XF(o)?BI(o.model,s):s},change:(t,n)=>{e.change(t,n)},problems:t=>{let r=eF(n,t).map(e=>XP(e)),i=e.view?.document,a=HI(t)&&r.length===0?VI(tF(i,t),tF(i,[...t.slice(0,-1),`driver`])):void 0;return a===void 0?r:[...r,a]}}),WI=({schema:e,value:t,path:n,hide:r,context:i})=>{let a=NP(e);if(a.kind!==`object`)return null;let o=XF(t)?t:{};return(0,K.jsx)(K.Fragment,{children:a.fields.filter(({key:e})=>!r.includes(e)).map(e=>(0,K.jsx)(CI,{context:i,name:e.key,path:[...n,e.key],required:e.required,schema:e.schema,value:o[e.key]},e.key))})},GI=e=>XF(e)&&typeof e.type==`string`?e.type:``,KI=({id:e,builder:t})=>{let{view:n,schema:r}=t,[i,a]=(0,H.useState)(e),o=(0,H.useRef)(e),s=n?.document,c=XF(s)?s.nodes:void 0,l=XF(c)?c[e]:void 0,u=GI(l),d=r===null?void 0:qP(r,u),f=async()=>{i!==o.current&&(o.current=i,await t.edit({op:`renameNode`,from:e,to:i})?t.select(i):(o.current=e,a(e)))},p=async()=>{await t.edit({op:`removeNode`,id:e})&&t.select(null)};return(0,K.jsxs)(`div`,{className:cF.fields,children:[(0,K.jsx)(`h2`,{className:cF.heading,children:yM(u)}),(0,K.jsx)(jk,{description:`Lowercase, and read by other nodes. A new name follows every reference.`,label:`Name`,onChange:a,onCommit:()=>{f()},value:i}),d===void 0?(0,K.jsx)(`p`,{className:cF.hint,children:`This node has no known type, so there are no fields to show.`}):(0,K.jsx)(WI,{context:UI(t,e,n?.diagnostics??[]),hide:[`type`],path:[`nodes`,e],schema:d,value:l}),(0,K.jsx)(mI,{builder:t,id:e}),(0,K.jsxs)(Y,{onClick:()=>{p()},children:[`Remove `,e]})]})},qI=({builder:e})=>{let{view:t,schema:n}=e;return n===null?null:(0,K.jsxs)(`div`,{className:cF.fields,children:[(0,K.jsx)(`h2`,{className:cF.heading,children:`Workflow`}),(0,K.jsx)(WI,{context:UI(e,null,t?.diagnostics??[]),hide:[`schemaVersion`,`nodes`,`edges`],path:[],schema:n,value:t?.document})]})},JI=({builder:e})=>{let{selected:t,view:n}=e,r=n?.graph.nodes.some(({id:e})=>e===t)===!0;return t!==null&&r?(0,K.jsx)(KI,{builder:e,id:t},t):(0,K.jsx)(qI,{builder:e})},YI=({builder:e})=>{let t=e.view?.graph,n=e.view?.diagnostics,r=(0,H.useMemo)(()=>t===void 0?null:EP(t),[t]),i=(0,H.useMemo)(()=>t===void 0||n===void 0?void 0:$P(t,n),[t,n]);if(t===void 0||r===null)return null;if(t.nodes.length===0)return(0,K.jsx)(dO,{title:`No nodes yet.`,children:`Add one from the list beside this.`});let{selected:a,connecting:o}=e;return(0,K.jsx)(RN,{facts:i,label:`Workflow ${e.opened?.name??``}`,layout:r,onSelect:n=>{o&&a!==null?(e.setConnecting(!1),e.edit(kF(t,a,n))):e.select(n)},selected:a??void 0})},XI=({builder:e})=>{let{view:t}=e;return t===null?(0,K.jsx)(`div`,{className:cF.empty,children:(0,K.jsxs)(dO,{title:`No workflow open.`,children:[`Choose one above, or name a new one. A workflow you make here is the same file you could write by hand, and works with every`,` `,(0,K.jsx)(`code`,{children:`ork`}),` command.`]})}):(0,K.jsxs)(`div`,{className:cF.body,children:[(0,K.jsx)(lF,{builder:e}),(0,K.jsxs)(`div`,{className:cF.middle,children:[(0,K.jsx)(`div`,{className:cF.canvas,children:(0,K.jsx)(YI,{builder:e})}),(0,K.jsx)(uF,{onChoose:e.select,problems:t.diagnostics,walk:t.walk})]}),(0,K.jsx)(`aside`,{"aria-label":`Inspector`,className:cF.inspector,children:(0,K.jsx)(JI,{builder:e})})]})},ZI=({builder:e})=>{let t=sb(),n=yb(t.projects.state),r=yb(t.workflows.state),i=n.status===`ready`?n.data:[],a=yb(t.builder.project),[o,s]=(0,H.useState)(``),c=a??(i.length===1?i[0]?.id:null)??null,{chooseProject:l}=e;(0,H.useEffect)(()=>{t.projects.load()},[t]),(0,H.useEffect)(()=>{c!==null&&(t.workflows.load(c),l(c))},[t,c,l]);let u=r.status===`ready`&&r.arg===c?r.data.map(({name:e})=>e):[],d=[...new Set([...u,...e.drafts])].toSorted(),f=async()=>{c!==null&&o!==``&&await e.create(c,o)&&s(``)};return(0,K.jsxs)(`div`,{className:cF.chooser,children:[(0,K.jsx)(oC,{empty:`No project matches.`,label:`Project`,onChange:e=>{t.builder.project.setValue(e)},options:i.map(({id:e})=>({value:e,label:e})),placeholder:`Type to find a project`,value:c}),(0,K.jsx)(oC,{disabled:c===null||d.length===0,empty:`No workflow matches.`,label:`Workflow`,onChange:t=>{c!==null&&t!==null&&e.open(c,t)},options:d.map(t=>({value:t,label:e.drafts.includes(t)?`${t} (draft)`:t})),placeholder:d.length===0?`None yet`:`Type to find one`,value:e.opened?.name??null}),(0,K.jsxs)(`form`,{className:cF.create,onSubmit:e=>{e.preventDefault(),f()},children:[(0,K.jsx)(jk,{label:`New workflow`,onChange:s,value:o}),(0,K.jsx)(Y,{disabled:c===null||o===``,focusableWhenDisabled:!0,type:`submit`,children:`Create`})]})]})},QI={agents:[],skills:[]},$I=e=>typeof e==`object`&&!!e&&!Array.isArray(e),eL=e=>{let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(QI),[a,o]=(0,H.useState)([]),s=(0,H.useRef)(null);(0,H.useEffect)(()=>{(async()=>{let t=await e.call(`builderSchema`);t.ok&&$I(t.data)&&n(t.data)})()},[e]);let c=(0,H.useCallback)(async t=>{let n={id:t},[r,a]=await Promise.all([e.call(`builderDrafts`,{params:n}),e.call(`builderCatalog`,{params:n})]);s.current===t&&(r.ok&&o(r.data),a.ok&&i(a.data))},[e]);return{schema:t,catalog:r,drafts:a,setDrafts:o,forProject:(0,H.useCallback)(e=>{s.current!==e&&o([]),s.current=e,c(e)},[c]),refreshDrafts:(0,H.useCallback)(()=>{s.current!==null&&c(s.current)},[c])}},tL=({project:e,name:t})=>({id:e,name:t}),nL=()=>{let{client:e,builder:t}=sb(),{inTurn:n,history:r,view:i,opened:a}=t,o=yb(a),s=yb(i),c=yb(t.selected),l=yb(r).length>0,[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(null),{schema:g,catalog:_,drafts:v,setDrafts:y,refreshDrafts:b,forProject:x}=eL(e),S=(0,H.useCallback)(e=>{r.setValue(e)},[r]),C=(0,H.useCallback)(e=>{let t=a.getValue();return t?.project===e.project&&t.name===e.name},[a]),w=(0,H.useCallback)((e,n)=>{t.show(e,n),d(!1),p(null),h(null)},[t]),T=(0,H.useCallback)(e=>{x(e);let t=a.getValue();t!==null&&t.project!==e&&w(null,null)},[x,a,w]),E=(0,H.useCallback)((e,n)=>C(e)?n.ok?(t.update(n.data),p(null),!0):(p(n.error),!1):n.ok,[C,t]),D=(0,H.useCallback)((t,r)=>n(async()=>{let n={project:t,name:r},i=await e.call(`builderView`,{params:tL(n)});i.ok?w(n,i.data):p(i.error)}),[e,n,w]),O=(0,H.useCallback)((t,r)=>n(async()=>{let n=await e.call(`builderCreate`,{params:{id:t},body:{name:r}});return n.ok?(w({project:t,name:r},n.data),y(e=>[...e,r]),!0):(p(n.error),!1)}),[e,n,y,w]),k=(0,H.useCallback)(async(t,n)=>{let i=await e.call(`builderEdit`,{params:tL(t),body:{edits:n}}),a=E(t,i);return i.ok&&C(t)&&i.data.text!==i.data.previous.text&&S([...r.getValue(),i.data.previous]),a},[e,r,C,E,S]);return{opened:o,view:s,selected:c,connecting:u,refusal:f,canUndo:l,replaceAsked:m,schema:g,catalog:_,drafts:v,chooseProject:T,open:D,create:O,edit:(0,H.useCallback)((...e)=>o===null?Promise.resolve(!1):n(()=>k(o,e)),[n,o,k]),change:(0,H.useCallback)((e,t)=>o===null?Promise.resolve(!1):n(()=>{if(!C(o))return Promise.resolve(!1);let n=tF(i.getValue()?.document,e),r=t(n);if(nF(n,r))return Promise.resolve(!0);let a=[...e];return k(o,[r===void 0?{op:`delete`,path:a}:{op:`set`,path:a,value:r}])}),[n,C,o,k,i]),undo:(0,H.useCallback)(()=>o===null?Promise.resolve():n(async()=>{let t=r.getValue().at(-1);if(t===void 0||!C(o))return;let n=await e.call(`builderRestore`,{params:tL(o),body:t});E(o,n)&&S(r.getValue().slice(0,-1))}),[e,r,n,C,o,E,S]),discard:(0,H.useCallback)(()=>o===null?Promise.resolve():n(async()=>{let t=await e.call(`builderDiscard`,{params:tL(o)});b(),C(o)&&(t.ok?`gone`in t.data?w(null,null):w(o,t.data):p(t.error))}),[e,n,C,o,b,w]),save:(0,H.useCallback)((t=!1)=>{if(o===null)return Promise.resolve(!1);let r=tL(o);return n(async()=>{let n=await e.call(`builderSave`,{params:r,body:t?{force:!0}:{}});return n.ok?n.data.saved?(p(null),b(),C(o)&&S([]),E(o,await e.call(`builderView`,{params:r})),nb.add({title:`Saved ${o.name}`}),!0):(n.data.why===`changed`?h(n.data.message):p(n.data.message),!1):(p(n.error),!1)})},[e,n,C,o,b,E,S]),select:t.select,setConnecting:d,setReplaceAsked:h}},rL=()=>{let e=sb(),t=nL(),{view:n,opened:r,refusal:i,connecting:a,selected:o}=t,[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d=n===null?0:rF(n.diagnostics),f=n===null?[]:oF(n.graph),p=async()=>{await t.save()&&c(!0)},m=()=>{r!==null&&(e.workflows.load(r.project),e.runPreset.setValue({project:r.project,workflow:r.name}),e.runDialog.setValue(!0))};return(0,K.jsxs)(`div`,{className:cF.panel,children:[(0,K.jsxs)(`header`,{className:cF.tools,children:[(0,K.jsx)(ZI,{builder:t}),n===null?null:(0,K.jsxs)(`div`,{className:cF.actions,children:[(0,K.jsx)(Y,{disabled:!t.canUndo,focusableWhenDisabled:!0,onClick:()=>{t.undo()},children:`Undo`}),(0,K.jsx)(Y,{disabled:!n.draft,focusableWhenDisabled:!0,onClick:()=>{u(!0)},children:`Discard`}),(0,K.jsx)(Y,{disabled:d>0||!n.draft,focusableWhenDisabled:!0,onClick:()=>{t.save()},variant:`primary`,children:`Save`}),(0,K.jsx)(Y,{disabled:d>0,focusableWhenDisabled:!0,onClick:()=>{p()},children:`Run…`})]})]}),n===null?null:(0,K.jsxs)(`div`,{className:cF.notices,children:[i===null?null:(0,K.jsx)(`p`,{className:cF.error,role:`alert`,children:(0,K.jsx)(J,{text:i})}),(0,K.jsx)(`output`,{className:cF.status,children:a&&o!==null?`Choose the card ${o} leads to.`:n.changedOnDisk?`The file changed since this draft began. Saving will ask before replacing it.`:n.draft?`Unsaved changes are kept as a draft.`:``})]}),(0,K.jsx)(XI,{builder:t}),(0,K.jsx)(IC,{confirm:`Discard the draft`,description:`This throws away every unsaved change, and it can't be undone.`,onConfirm:()=>{u(!1),t.discard()},onOpenChange:u,open:l,title:`Discard the draft of ${r?.name??``}?`}),(0,K.jsx)(IC,{confirm:`Replace the file`,description:`${t.replaceAsked??``} Replacing it loses what changed there.`,onConfirm:()=>{t.setReplaceAsked(null),t.save(!0)},onOpenChange:e=>{e||t.setReplaceAsked(null)},open:t.replaceAsked!==null,title:`The file changed`}),(0,K.jsx)(IC,{confirm:`Choose how to run it`,description:`This starts a real run, which can spend money and commit work.${f.length===0?``:` These nodes act outside its worktree: ${f.join(`, `)}.`}`,onConfirm:()=>{c(!1),m()},onOpenChange:c,open:s,title:`Run ${r?.name??``}?`})]})},iL=new Set([`agent.leader`,`agent.worker`]),aL=e=>{let t=new Set;for(let{event:n}of e)if(n.type===`run.started`)for(let{id:e,type:r}of n.nodes)iL.has(r)&&t.add(e);else n.type===`node.started`&&iL.has(n.nodeType)&&t.add(n.id);return[...t]},oL={now:`delivered to its session`,queued:`waits for its next session`,resumed:`resumed its session`},sL=e=>e===void 0?{}:{note:e===`script`?`a script`:`a rule`},cL=/^mcp__ork__/u,lL=new Set([`StructuredOutput`]),uL=(e,t)=>e.type===`assistant.text`?{...t,kind:`node`,text:e.text}:e.type===`tool.called`?lL.has(e.name)?void 0:{...t,kind:`activity`,text:`Used ${e.name.replace(cL,``)}`}:e.type===`session.started`?{...t,kind:`activity`,text:`Session on ${e.model}`}:void 0,dL=({seq:e,at:t,event:n},r)=>{let i={seq:e,at:t},a=e=>({...i,kind:`activity`,text:e});if(n.type===`node.event`)return n.id===r?n.event.fork===!0?n.event.type===`session.started`?a(`A fork took a child's question`):void 0:uL(n.event,i):void 0;if(n.type===`node.finished`){if(n.id!==r)return;let{summary:e}=n.output;if(n.ok&&typeof e==`string`)return{...i,kind:`node`,text:e,note:`its report`};let t=n.error===void 0?``:`: ${n.error}`;return a(n.ok?`Finished.`:`Failed${t}`)}if(n.type===`message.sent`&&n.to===r)return{...i,kind:`peer`,from:n.node,text:n.body,...sL(n.via)};if(`node`in n&&n.node===r){if(n.type===`user.message`)return{...i,kind:`you`,text:n.body,note:oL[n.delivered]};if(n.type===`message.sent`)return a(n.via===`rule`?`A rule wrote to ${n.to}: ${n.body}`:`Wrote to ${n.to}: ${n.body}`);if(n.type===`message.received`)return{...i,kind:`peer`,from:n.from,text:n.body,...sL(n.via)};if(n.type===`decision.opened`)return a(`Asked you: ${n.question}`);if(n.type===`decision.answered`)return a(n.note===void 0?`You answered: ${n.answer}`:`You answered: ${n.answer}. You said: ${n.note}`)}},fL=(e,t)=>e.flatMap(e=>dL(e,t)??[]),pL=({live:e})=>e===`running`?null:e===`paused`?`The run is paused. Continue it to write to this node.`:`The run has ended (${e}). To resume this node's session, use:`,mL=(e,t)=>`ork chat ${e} ${t}`,hL={panel:`_panel_s0gbu_7`,tools:`_tools_s0gbu_23`,main:`_main_s0gbu_33`,thread:`_thread_s0gbu_46`,items:`_items_s0gbu_62`,message:`_message_s0gbu_73`,meta:`_meta_s0gbu_81`,speaker:`_speaker_s0gbu_91`,time:`_time_s0gbu_101`,note:`_note_s0gbu_102`,text:`_text_s0gbu_112`,activity:`_activity_s0gbu_118`,activityText:`_activityText_s0gbu_131`,composer:`_composer_s0gbu_136`,box:`_box_s0gbu_156`,labelRow:`_labelRow_s0gbu_179`,send:`_send_s0gbu_189`,hint:`_hint_s0gbu_197`,why:`_why_s0gbu_198`,refusal:`_refusal_s0gbu_207`},gL=({run:e,node:t})=>{let n=sb(),r=(0,H.useId)(),i=(0,H.useId)(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),d=pL(e),f=mL(e.id,t),p=(0,H.useRef)(!1),m=(0,H.useRef)(null);(0,H.useEffect)(()=>{d!==null&&p.current&&(p.current=!1,m.current?.focus())},[d]);let h=async()=>{if(s||a.trim()===``)return;c(!0),u(null);let r=await n.sendMessage(e.id,t,a);c(!1),r.ok?o(``):u(r.error)};return d===null?(0,K.jsxs)(`form`,{className:hL.composer,onSubmit:e=>{e.preventDefault(),h()},children:[(0,K.jsxs)(`div`,{className:hL.labelRow,children:[(0,K.jsxs)(`label`,{className:rC.label,htmlFor:r,children:[`Message to `,t]}),(0,K.jsx)(`span`,{className:hL.hint,id:i,children:`Enter sends, Shift+Enter starts a new line.`})]}),(0,K.jsxs)(`div`,{className:hL.send,children:[(0,K.jsx)(`textarea`,{"aria-describedby":i,className:hL.box,id:r,onBlur:()=>{p.current=!1},onChange:e=>{o(e.target.value)},onFocus:()=>{p.current=!0},onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),h())},rows:1,value:a}),(0,K.jsx)(Y,{cli:`${f} -m …`,disabled:s||a.trim()===``,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:s?`Sending…`:`Send`})]}),l===null?null:(0,K.jsx)(`p`,{className:hL.refusal,role:`alert`,children:(0,K.jsx)(J,{text:l})})]}):(0,K.jsxs)(`div`,{"aria-describedby":r,"aria-label":`Message to ${t}`,className:hL.composer,ref:m,role:`group`,tabIndex:-1,children:[(0,K.jsx)(`p`,{className:hL.why,id:r,children:(0,K.jsx)(J,{text:d})}),e.live===`paused`?null:(0,K.jsx)(lC,{command:f})]})},_L=e=>e.replaceAll(/\s+/gu,` `).trim(),vL=({event:e})=>{switch(e.type){case`session.started`:return`session on ${e.model}`;case`assistant.text`:return _L(e.text);case`session.waiting`:return _L(e.reason);case`tool.called`:return`${e.name} ${_L(JSON.stringify(e.input))}`;case`tool.result`:return e.isError?`tool failed`:`tool done`;case`plan.limit`:return e.status===`allowed`?``:`plan: ${e.window.replaceAll(`_`,` `)} limit ${e.status===`rejected`?`reached`:`is close`}`;case`session.finished`:return`session finished`;default:return``}},yL=e=>{let t=vL(e);return e.event.fork===!0&&t!==``?`fork: ${t}`:t},bL=e=>`id`in e?e.id:`node`in e?e.node:`from`in e?e.from:void 0,xL=e=>e===void 0?``:` (${e})`,SL=e=>e.type===`node.finished`&&e.end.actor!==null?e:void 0,CL=(e,t)=>e>1?`round ${String(e)}: ${t}`:t,wL=({round:e,end:t})=>CL(e,t.message),TL=e=>{let{output:t,round:n,end:r}=e;if(r.actor!==null)return CL(n,`${r.label}: ${r.message}`);let{summary:i}=t;return CL(n,`ok${typeof i==`string`?`: ${_L(i)}`:``}`)},EL=e=>{if(e.type!==`node.started`)return;let t=e.description?.trim();return t===void 0||t===``?void 0:t},DL=e=>{switch(e.type){case`run.started`:return`${e.workflow}, ${String(e.nodes.length)} nodes`;case`run.resumed`:return`keeps ${String(e.kept.length)} nodes`;case`run.command`:return e.node===void 0?e.command:`${e.command} ${e.node}`;case`run.finished`:return e.result.status;case`node.started`:return e.round>1?`${e.nodeType}, round ${String(e.round)}`:e.nodeType;case`node.event`:return yL(e);case`node.finished`:return TL(e);case`each.listed`:return`${String(e.count)} items`;case`each.exceeded`:return`${String(e.count)} items, over ${String(e.maxItems)}`;case`edge.taken`:return`${e.from} -> ${e.to}`;case`loop.exhausted`:return`${e.from} -> ${e.to} after ${String(e.maxRounds)} rounds`;case`watch.started`:return`until ${e.until}, every ${e.every}`;case`watch.changed`:return`look ${String(e.looks)}: ${e.said}`;case`watch.ended`:return`${e.outcome} after ${String(e.looks)} looks`;case`worktree`:return`${e.action} ${e.branch??e.path}`;case`decision.opened`:return _L(e.question);case`decision.answered`:{let t=e.note===void 0?``:`; said: ${_L(e.note)}`;return`${e.answer}, by ${e.by}${t}`}case`message.sent`:return`to ${e.to}${xL(e.via)}: ${_L(e.body)}`;case`message.received`:return`from ${e.from}${xL(e.via)}: ${_L(e.body)}`;case`call.started`:return`${e.workflow} as ${e.run}`;case`link.notice`:return _L(e.text);case`owner.asked`:return`about ${e.about}: ${_L(e.text)}`;case`owner.answered`:return e.answer;case`user.message`:return`${e.delivered}: ${_L(e.body)}`;case`claim.taken`:return e.resource;case`claim.refused`:return`${e.resource}: ${e.holder} holds ${e.held}`;case`claim.released`:return`${e.resource}, ${e.reason}`;case`feedback.recorded`:return _L(e.feedback.title);case`slot.waiting`:return`held by ${e.holders.join(`, `)}`;case`lock.waiting`:return`${e.lock}, held by ${e.holders.join(`, `)}`;case`verify.skipped`:return _L(`${e.check}: already passed on these files · ${e.at} · ${e.who}`);case`message.read`:return`${String(e.ids.length)} messages`;case`decision.withdrawn`:case`slot.taken`:case`lock.taken`:case`lock.released`:case`node.held`:case`node.released`:case`node.skipped`:case`owner.unanswered`:return``;default:return``}},OL=new WeakMap,kL=e=>{let t=OL.get(e);if(t!==void 0)return t;let n=JSON.stringify(e.event).toLowerCase();return OL.set(e,n),n},AL=e=>/^(.+)\.\d+$/u.exec(e)?.[1],jL=(e,t)=>e!==void 0&&(e===t||AL(e)===t),ML=(e,{node:t,type:n,text:r})=>{let i=r.trim().toLowerCase();return t===null&&n===null&&i===``?e:e.filter(e=>(t===null||jL(bL(e.event),t))&&(n===null||e.event.type===n)&&(i===``||kL(e).includes(i)))},NL=e=>[...new Set(e)].toSorted((e,t)=>e.localeCompare(t,void 0,{numeric:!0})),PL=(e,t)=>({value:e,label:t.some(t=>AL(t)===e)?`${e} and its items`:e}),FL=(e,t)=>NL([...e.flatMap(({event:e})=>bL(e)??[]),...t===null?[]:[t]]),IL=e=>NL(e.map(({event:e})=>e.type)),LL=(e,t,n)=>`${e===t?`${String(e)} events`:`${String(e)} of ${String(t)} loaded`}${n>t?`, ${String(n)} in the run`:``}`,RL=(e,t,n=!0)=>`ork logs ${e}${t===null?``:` --node ${t}`}${n?` --follow`:``}`,zL=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),BL=32,VL=({kind:e,from:t},n)=>e===`you`?`You`:e===`node`?n:t??``,HL=(0,H.memo)(({item:e,node:t})=>e.kind===`activity`?(0,K.jsxs)(`li`,{className:hL.activity,children:[(0,K.jsx)(`span`,{className:hL.activityText,children:e.text}),(0,K.jsx)(`span`,{className:hL.time,children:zL(e.at)})]}):(0,K.jsxs)(`li`,{className:hL.message,"data-kind":e.kind,children:[(0,K.jsxs)(`p`,{className:hL.meta,children:[(0,K.jsx)(`span`,{className:hL.speaker,children:VL(e,t)}),(0,K.jsx)(`span`,{className:hL.time,children:zL(e.at)}),e.note===void 0?null:(0,K.jsx)(`span`,{className:hL.note,children:e.note})]}),(0,K.jsx)(`p`,{className:hL.text,children:e.text})]}));HL.displayName=`ThreadRow`;var UL=({items:e,node:t})=>{let n=(0,H.useRef)(null),r=(0,H.useRef)(!0);return(0,H.useLayoutEffect)(()=>{let e=n.current;e!==null&&r.current&&(e.scrollTop=e.scrollHeight)}),(0,H.useEffect)(()=>{let e=n.current,t=new ResizeObserver(()=>{e!==null&&r.current&&(e.scrollTop=e.scrollHeight)});return e!==null&&t.observe(e),()=>{t.disconnect()}},[]),(0,K.jsx)(`div`,{"aria-label":`Conversation with ${t}`,className:hL.thread,onScroll:e=>{let{scrollHeight:t,scrollTop:n,clientHeight:i}=e.currentTarget;r.current=t-n-i<BL},ref:n,role:`log`,tabIndex:0,children:(0,K.jsx)(`ol`,{className:hL.items,children:e.map(e=>(0,K.jsx)(HL,{item:e,node:t},e.seq))})})},WL=({run:e,selected:t})=>{let n=sb(),r=(0,H.useMemo)(()=>n.feedOf(e.id),[n,e.id]);(0,H.useEffect)(()=>n.retainRun(e.id),[n,e.id]);let{events:i,tail:a,following:o,link:s}=yb(r.state),c=o?i:a,l=(0,H.useMemo)(()=>aL(i),[i]),u=t!==null&&l.includes(t)?t:l[0]??null,d=(0,H.useMemo)(()=>u===null?[]:fL(c,u),[c,u]);return u===null?(0,K.jsx)(dO,{title:s===`loading`&&i.length===0?`Reading the run…`:`This run has no one to talk to.`,children:`Only leaders and workers have sessions.`}):(0,K.jsxs)(`div`,{className:hL.panel,children:[(0,K.jsx)(`div`,{className:hL.tools,children:(0,K.jsx)(oC,{empty:`No node matches.`,label:`Node`,onChange:n.selectNode,options:l.map(e=>({value:e,label:e})),value:u})}),(0,K.jsx)(`div`,{className:hL.main,children:d.length===0?(0,K.jsx)(dO,{title:`Nothing from ${u} yet.`,children:`What it says and what you write show here.`}):(0,K.jsx)(UL,{items:d,node:u},u)}),(0,K.jsx)(gL,{node:u,run:e},`${e.id}/${u}`)]})},GL=()=>{let e=sb(),{run:t,node:n}=yb(e.selection),r=yb(e.runs)?.find(({id:e})=>e===t);return r===void 0?(0,K.jsx)(dO,{cli:`ork chat <run> <node>`,title:`No run chosen.`,children:`Choose one in the Runs panel, or in a terminal:`}):(0,K.jsx)(WL,{run:r,selected:n},r.id)},KL=({id:e,label:t})=>t??e,qL=({id:e,runId:t},n,r=``)=>{let i=r.trim()===``?``:` --say ${Yk(r.trim())}`;return`ork decide ${t} --id ${e} --choose ${n?.id??`<option>`}${i}`},JL={terminal:`in the run's terminal`,decide:"with `ork decide`",ui:"in `ork ui`",owner:`by its owner`,yolo:`by the run itself, as it runs with --yolo`},YL=({status:e,options:t,answer:n,answeredBy:r,owner:i})=>{if(e===`withdrawn`)return`Withdrawn: it no longer needs an answer.`;if(e===`open`)return`Its run ended before it was answered.`;let a=t.find(({id:e})=>e===n),o=a===void 0?n??``:KL(a);if(r===`owner`&&i!==void 0)return`Answered ${o} by \`${i}\`, its owner.`;let s=i===void 0?``:`, after \`${i}\` passed it on`;return r===void 0?`Answered ${o}${s}.`:`Answered ${o} ${JL[r]}${s}.`},XL=({note:e})=>e===void 0?void 0:`They said: ${e}`,ZL=(e,t)=>/^[1-9]$/u.test(t)?e[Number(t)-1]:void 0,QL=e=>(t,n)=>`${n===1?`Copy code`:`Copy code block ${t} of ${n}`} (${e})`,$L=({runId:e,id:t})=>`ork decide ${e} --id ${t} --document`,eR=e=>e.startsWith(`{
95
+ `),tR=(e,t,n,r=[])=>{let i=[...new Set([...e.map(({runId:e})=>e),...r.map(({id:e})=>e)])];return{project:n,workflow:[...new Set(i.flatMap(e=>t(e)??[]))].toSorted((e,t)=>e.localeCompare(t)).map(e=>({value:e,label:e})),run:i.map(e=>{let n=t(e);return{value:e,label:n===void 0?e:`${e} · ${n}`}})}},nR=e=>e===1?`1 open decision.`:`${e} open decisions.`,rR={panel:`_panel_5xfzy_6`,list:`_list_5xfzy_22`,card:`_card_5xfzy_27`,fromText:`_fromText_5xfzy_43`,from:`_from_5xfzy_43`,read:`_read_5xfzy_69`,length:`_length_5xfzy_79`,document:`_document_5xfzy_90`,filter:`_filter_5xfzy_120`,options:`_options_5xfzy_131`,option:`_option_5xfzy_131`,optionMark:`_optionMark_5xfzy_194`,optionCommand:`_optionCommand_5xfzy_204`,unreachable:`_unreachable_5xfzy_216`,readFailed:`_readFailed_5xfzy_241`,optionText:`_optionText_5xfzy_261`,optionLabel:`_optionLabel_5xfzy_285`,optionDescription:`_optionDescription_5xfzy_292`,refusal:`_refusal_5xfzy_301`,settled:`_settled_5xfzy_309`,settledTitle:`_settledTitle_5xfzy_319`,settledList:`_settledList_5xfzy_336`,settledQuestion:`_settledQuestion_5xfzy_357`,settledEnding:`_settledEnding_5xfzy_361`,settledNote:`_settledNote_5xfzy_371`},iR="Cannot answer here: `ork ui` is not reachable.",aR=`Cannot answer here: ork ui is not reachable`,oR=({decision:e,note:t,onNote:n,sending:r,unreachable:i,onChoose:a})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jk,{description:`It goes with the option you choose; a gate passes it on as its note.`,label:`Note for the run (optional)`,multiline:!0,onChange:n,rows:2,value:t}),t.trim()===``?null:(0,K.jsx)(lC,{command:qL(e,void 0,t)}),(0,K.jsx)(`ul`,{className:rR.options,children:e.options.map((n,o)=>{let s=n.id===e.recommended,c=qL(e,n,t),l=o<9?String(o+1):void 0;return(0,K.jsx)(`li`,{children:(0,K.jsx)(l_,{cli:c,label:i?iR:void 0,children:(0,K.jsxs)(`button`,{...c_(c,i?aR:void 0),"aria-disabled":r||i?`true`:void 0,"aria-keyshortcuts":l,className:rR.option,"data-option":``,"data-recommended":s?``:void 0,"data-unreachable":i?``:void 0,onClick:()=>{a(n)},type:`button`,children:[l===void 0?null:(0,K.jsx)(i_,{keys:[l]}),(0,K.jsxs)(`span`,{className:rR.optionText,children:[(0,K.jsx)(`span`,{className:rR.optionLabel,children:KL(n)}),n.description===void 0?null:(0,K.jsx)(`span`,{className:rR.optionDescription,children:n.description}),i?(0,K.jsx)(`code`,{className:rR.optionCommand,children:c}):null]}),s?(0,K.jsx)(`span`,{className:rR.optionMark,children:`recommended`}):null]})})},n.id)})})]}),sR={};function cR(e,t){let n=t||sR;return lR(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function lR(e,t,n){if(dR(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return uR(e.children,t,n)}return Array.isArray(e)?uR(e,t,n):``}function uR(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=lR(e[i],t,n);return r.join(``)}function dR(e){return!!(e&&typeof e==`object`)}var fR=document.createElement(`i`);function pR(e){let t=`&`+e+`;`;fR.innerHTML=t;let n=fR.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function mR(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function hR(e,t){return e.length>0?(mR(e,e.length,0,t),e):t}var gR={}.hasOwnProperty;function _R(e){let t={},n=-1;for(;++n<e.length;)vR(t,e[n]);return t}function vR(e,t){let n;for(n in t){let r=(gR.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){gR.call(r,a)||(r[a]=[]);let e=i[a];yR(r[a],Array.isArray(e)?e:e?[e]:[])}}}function yR(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);mR(e,0,0,r)}function bR(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function xR(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var SR=PR(/[A-Za-z]/),CR=PR(/[\dA-Za-z]/),wR=PR(/[#-'*+\--9=?A-Z^-~]/);function TR(e){return e!==null&&(e<32||e===127)}var ER=PR(/\d/),DR=PR(/[\dA-Fa-f]/),OR=PR(/[!-/:-@[-`{-~]/);function kR(e){return e!==null&&e<-2}function AR(e){return e!==null&&(e<0||e===32)}function jR(e){return e===-2||e===-1||e===32}var MR=PR(/\p{P}|\p{S}/u),NR=PR(/\s/);function PR(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function FR(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return jR(r)?(e.enter(n),s(r)):t(r)}function s(r){return jR(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function IR(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&jR(t)?(e.enter(r),c(t)):l(t)}function c(t){return jR(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var LR={tokenize:RR};function RR(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),FR(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return kR(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var zR=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){BR(this,e,t,n,!1)}addBefore(e,t,n){BR(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function BR(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var VR={tokenize:UR},HR={tokenize:WR};function UR(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new zR;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(HR,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(HR,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return kR(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new zR;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function WR(e,t,n){return FR(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function GR(e){if(e===null||AR(e)||NR(e))return 1;if(MR(e))return 2}function KR(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var qR={name:`attention`,resolveAll:JR,tokenize:YR};function JR(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};XR(o,-a),XR(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=hR(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=hR(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=hR(r,KR(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=hR(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=hR(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),mR(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function YR(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=GR(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=GR(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function XR(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ZR={name:`autolink`,tokenize:QR};function QR(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return SR(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||CR(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||CR(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||TR(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):wR(t)?(e.consume(t),l):n(t)}function u(e){return CR(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||CR(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var $R={partial:!0,tokenize:ez};function ez(e,t,n){return r;function r(t){return jR(t)?FR(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||kR(e)?t(e):n(e)}}var tz={continuation:{tokenize:rz},exit:iz,name:`blockQuote`,tokenize:nz};function nz(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return jR(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function rz(e,t,n){let r=this;return i;function i(t){return jR(t)?FR(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(tz,t,n)(r)}}function iz(e){e.exit(`blockQuote`)}var az={name:`characterEscape`,tokenize:oz};function oz(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return OR(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var sz={name:`characterReference`,tokenize:cz};function cz(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=CR,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=DR,u):(e.enter(`characterReferenceValue`),a=7,o=ER,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===CR&&!pR(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var lz={partial:!0,tokenize:uz};function uz(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var dz={concrete:!0,name:`codeFenced`,tokenize:fz};function fz(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),jR(t)?FR(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||kR(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(lz,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||kR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):jR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),FR(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||kR(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||kR(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&jR(t)?FR(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||kR(t)?e.check(lz,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||kR(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),jR(t)?FR(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),jR(t)?FR(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||kR(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var pz={name:`codeIndented`,tokenize:hz},mz={partial:!0,tokenize:gz};function hz(e,t,n){return r;function r(t){return e.enter(`codeIndented`),IR(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):kR(t)?e.attempt(mz,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||kR(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function gz(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):kR(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):IR(e,t,a,`linePrefix`,4,4)(o)}function a(e){return kR(e)?i(e):n(e)}}var _z={name:`codeText`,previous:yz,resolve:vz,tokenize:bz};function vz(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yz(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function bz(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):kR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||kR(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var xz=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Sz(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Sz(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Sz(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Sz(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Sz(this.left,t.reverse())}}}};function Sz(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Cz(e){let t={},n=-1,r,i,a,o,s,c,l,u=new xz(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,wz(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return mR(e,0,1/0,u.slice(0)),!l}function wz(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Tz={resolve:Dz,tokenize:Oz},Ez={partial:!0,tokenize:kz};function Dz(e){return Cz(e),e}function Oz(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):kR(t)?e.check(Ez,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function kz(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),FR(e,a,`linePrefix`)}function a(i){if(i===null||kR(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Az(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||TR(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||kR(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||AR(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||TR(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function jz(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):kR(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||kR(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!jR(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Mz(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):kR(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),FR(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||kR(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Nz(e,t){let n;return r;function r(i){return kR(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):jR(i)?FR(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Pz={name:`definition`,tokenize:Iz},Fz={partial:!0,tokenize:Lz};function Iz(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return jz.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=xR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return AR(t)?Nz(e,l)(t):l(t)}function l(t){return Az(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Fz,d,d)(t)}function d(t){return jR(t)?FR(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||kR(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Lz(e,t,n){return r;function r(t){return AR(t)?Nz(e,i)(t):n(t)}function i(t){return Mz(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return jR(t)?FR(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||kR(e)?t(e):n(e)}}var Rz={name:`hardBreakEscape`,tokenize:zz};function zz(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return kR(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Bz={name:`headingAtx`,resolve:Vz,tokenize:Hz};function Vz(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};mR(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function Hz(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||AR(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||kR(n)?(e.exit(`atxHeading`),t(n)):jR(n)?FR(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||AR(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Uz=`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.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Wz=[`pre`,`script`,`style`,`textarea`],Gz={concrete:!0,name:`htmlFlow`,resolveTo:qz,tokenize:Jz},Kz={partial:!0,tokenize:Yz};function qz(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Jz(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):SR(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):SR(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return SR(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||AR(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Wz.includes(l)?(i=1,r.interrupt?t(s):O(s)):Uz.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||CR(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return jR(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||SR(t)?(e.consume(t),b):jR(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||CR(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):jR(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):jR(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||kR(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||AR(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||jR(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||kR(t)?O(t):jR(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):kR(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Kz,R,k)(t)):t===null||kR(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(lz,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||kR(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Wz.includes(n)?(e.consume(t),L):O(t)}return SR(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||kR(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function Yz(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt($R,t,n)}}var Xz={name:`htmlText`,tokenize:Zz};function Zz(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):SR(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):SR(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):kR(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):kR(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):kR(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):kR(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return SR(t)?(e.consume(t),S):n(t)}function S(t){return t===45||CR(t)?(e.consume(t),S):C(t)}function C(t){return kR(t)?(o=C,N(t)):jR(t)?(e.consume(t),C):M(t)}function w(t){return t===45||CR(t)?(e.consume(t),w):t===47||t===62||AR(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||SR(t)?(e.consume(t),E):kR(t)?(o=T,N(t)):jR(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||CR(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):kR(t)?(o=D,N(t)):jR(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):kR(t)?(o=O,N(t)):jR(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):kR(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||AR(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||AR(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return jR(t)?FR(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Qz={name:`labelEnd`,resolveAll:nB,resolveTo:rB,tokenize:iB},$z={tokenize:aB},eB={tokenize:oB},tB={tokenize:sB};function nB(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&mR(e,0,e.length,n),e}function rB(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=hR(o,e.slice(i+1,i+r+3)),o=hR(o,[[`enter`,l,t]]),o=hR(o,KR(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=hR(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=hR(o,e.slice(a+1)),o=hR(o,[[`exit`,s,t]]),mR(e,i,e.length,o),e}function iB(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(xR(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt($z,u,o?u:d)(t):t===91?e.attempt(eB,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(tB,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function aB(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return AR(t)?Nz(e,a)(t):a(t)}function a(t){return t===41?u(t):Az(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return AR(t)?Nz(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Mz(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return AR(t)?Nz(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function oB(e,t,n){let r=this;return i;function i(t){return jz.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(xR(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function sB(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var cB={name:`labelStartImage`,resolveAll:Qz.resolveAll,tokenize:lB};function lB(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var uB={name:`labelStartLink`,resolveAll:Qz.resolveAll,tokenize:dB};function dB(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var fB={name:`lineEnding`,tokenize:pB};function pB(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),FR(e,t,`linePrefix`)}}var mB={name:`thematicBreak`,tokenize:hB};function hB(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||kR(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),jR(t)?FR(e,s,`whitespace`)(t):s(t))}}var gB={continuation:{tokenize:bB},exit:SB,name:`list`,tokenize:yB},_B={partial:!0,tokenize:CB},vB={partial:!0,tokenize:xB};function yB(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:ER(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(mB,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return ER(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check($R,r.interrupt?n:u,e.attempt(_B,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return jR(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function bB(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($R,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,FR(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!jR(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(vB,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,FR(e,e.attempt(gB,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function xB(e,t,n){let r=this;return FR(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function SB(e){e.exit(this.containerState.type)}function CB(e,t,n){let r=this;return FR(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!jR(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var wB={name:`setextUnderline`,resolveTo:TB,tokenize:EB};function TB(e,t){let n=new zR,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function EB(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),jR(t)?FR(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||kR(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var DB={tokenize:OB};function OB(e){let t=this,n=e.attempt($R,r,e.attempt(this.parser.constructs.flowInitial,i,FR(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Tz,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var kB={resolveAll:NB()},AB=MB(`string`),jB=MB(`text`);function MB(e){return{resolveAll:NB(e===`text`?PB:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function NB(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):t[r]&&t[r][1].type===`data`||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function PB(e,t){let n=new zR,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var FB=M({attentionMarkers:()=>UB,contentInitial:()=>LB,disable:()=>WB,document:()=>IB,flow:()=>zB,flowInitial:()=>RB,insideSpan:()=>HB,string:()=>BB,text:()=>VB}),IB={42:gB,43:gB,45:gB,48:gB,49:gB,50:gB,51:gB,52:gB,53:gB,54:gB,55:gB,56:gB,57:gB,62:tz},LB={91:Pz},RB={[-2]:pz,[-1]:pz,32:pz},zB={35:Bz,42:mB,45:[wB,mB],60:Gz,61:wB,95:mB,96:dz,126:dz},BB={38:sz,92:az},VB={[-5]:fB,[-4]:fB,[-3]:fB,33:cB,38:sz,42:qR,60:[ZR,Xz],91:uB,92:[Rz,az],93:Qz,95:qR,96:_z},HB={null:[qR,kB]},UB={null:[42,95]},WB={null:[]};function GB(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=hR(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=KR(a,l.events,l),l.events):[]}function f(e,t){return qB(p(e),t)}function p(e){return KB(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){kR(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&mR(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function KB(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function qB(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
96
+ `;break;case-3:o=`\r
97
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function JB(e){let t={constructs:_R([FB,...(e||{}).extensions||[]]),content:n(LR),defined:[],document:n(VR),flow:n(DB),lazy:{},string:n(AB),text:n(jB)};return t;function n(e){return n;function n(n){return GB(t,e,n)}}}function YB(e){for(;!Cz(e););return e}var XB=/[\0\t\n\r]/g;function ZB(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){XB.lastIndex=c;let n=XB.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var QB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $B(e){return e.replace(QB,eV)}function eV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return bR(n.slice(t?2:1),t?16:10)}return pR(n)||e}function tV(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?rV(e.position):`start`in e||`end`in e?rV(e):`line`in e||`column`in e?nV(e):``}function nV(e){return iV(e&&e.line)+`:`+iV(e&&e.column)}function rV(e){return nV(e&&e.start)+`-`+nV(e&&e.end)}function iV(e){return e&&typeof e==`number`?e:1}var aV={}.hasOwnProperty;function oV(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),sV(n)(YB(JB(n).document().write(ZB()(e,t,!0))))}function sV(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(_e),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(pe),blockQuote:o(ce),characterEscape:E,characterReference:E,codeFenced:o(le),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(le,s),codeText:o(ue,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(de),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(fe),hardBreakEscape:o(me),hardBreakTrailing:o(me),htmlFlow:o(he,s),htmlFlowData:E,htmlText:o(he,s),htmlTextData:E,image:o(ge),label:s,link:o(_e),listItem:o(ye),listItemValue:p,listOrdered:o(ve,f),listUnordered:o(ve),paragraph:o(be),reference:te,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(pe),strong:o(xe),thematicBreak:o(Se)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:se,autolinkProtocol:oe,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ie,characterReference:ae,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:I,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:L,resourceTitleString:R,resource:ee,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};lV(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),aV.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||dV).call(o,void 0,e[0])}for(r.position={start:cV(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:cV(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:cV(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+tV({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||dV).call(this,e,r[0])),n.position.end=cV(e.end)}function d(){return cR(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=xR(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&n.type===`text`||(n=z(),n.position={start:cV(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=cV(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=cV(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=$B(t),n.identifier=xR(t).toLowerCase()}function I(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function R(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=xR(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function ie(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=bR(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=pR(t);let i=this.stack[this.stack.length-1];i.value+=r}function ae(e){let t=this.stack.pop();t.position.end=cV(e.end)}function oe(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function se(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ce(){return{type:`blockquote`,children:[],position:void 0}}function le(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function ue(){return{type:`inlineCode`,value:``,position:void 0}}function de(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function fe(){return{type:`emphasis`,children:[],position:void 0}}function pe(){return{type:`heading`,depth:0,children:[],position:void 0}}function me(){return{type:`break`,position:void 0}}function he(){return{type:`html`,value:``,position:void 0}}function ge(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function _e(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function ve(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function ye(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function be(){return{type:`paragraph`,children:[],position:void 0}}function xe(){return{type:`strong`,children:[],position:void 0}}function z(){return{type:`text`,value:``,position:void 0}}function Se(){return{type:`thematicBreak`,position:void 0}}}function cV(e){return{line:e.line,column:e.column,offset:e.offset}}function lV(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?lV(e,r):uV(e,r)}}function uV(e,t){let n;for(n in t)if(aV.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function dV(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+tV({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+tV({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+tV({start:t.start,end:t.end})+`) is still open`)}var fV=new Set([`http:`,`https:`,`mailto:`]),pV=e=>{try{return fV.has(new URL(e).protocol)}catch{return!1}},mV=50,hV=e=>{let t=0,n=[{node:e,depth:0}];for(let e=n.pop();e!==void 0;e=n.pop())if(t=Math.max(t,e.depth),`children`in e.node)for(let t of e.node.children)n.push({node:t,depth:e.depth+1});return t},gV=e=>{let t=oV(e);if(hV(t)>mV)throw RangeError(`Nested too deep`);return t},_V=e=>e.type===`break`?`
98
+ `:e.type===`image`||e.type===`imageReference`?e.alt??``:`value`in e?e.value:`children`in e?e.children.map(_V).join(``):``,vV=[`root`,`blockquote`,`listItem`],yV=e=>`children`in e?e.children.reduce((t,n)=>t+(n.type===`code`||n.type===`html`&&vV.includes(e.type)?1:0)+yV(n),0):0,bV=(e,t=120)=>{let n=e=>{let n=e.trim();return n.length>t?`${n.slice(0,t-1)}…`:n};try{return n(_V(gV(e).children.find(e=>_V(e).trim()!==``)??{type:`text`,value:``}).split(`
99
+ `).find(e=>e.trim()!==``)??``)}catch{return n(e.split(`
100
+ `).find(e=>e.trim()!==``)??``)}},xV=e=>e===``?0:e.replace(/\n+$/u,``).split(`
101
+ `).length,SV={markdown:`_markdown_q1zph_9`,inline:`_inline_q1zph_94`,target:`_target_q1zph_103`,link:`_link_q1zph_108`,image:`_image_q1zph_113`,note:`_note_q1zph_117`,written:`_written_q1zph_122`},CV=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],wV=(e,t)=>t===1?`Copy code`:`Copy code block ${e} of ${t}`,TV=e=>String(e.position?.start.offset),EV=(e,t)=>{let n=0;return e.split(`
102
+ `).flatMap((e,r)=>{let i=`${t}:${n}`;return n+=e.length+1,r===0?[e]:[(0,K.jsx)(`br`,{},i),e]})},DV=e=>e.map(e=>(0,K.jsx)(H.Fragment,{children:OV(e)},TV(e))),OV=e=>e.type===`text`?EV(e.value,TV(e)):e.type===`emphasis`?(0,K.jsx)(`em`,{children:DV(e.children)}):e.type===`strong`?(0,K.jsx)(`strong`,{children:DV(e.children)}):e.type===`delete`||e.type===`linkReference`?DV(e.children):e.type===`inlineCode`?(0,K.jsx)(`code`,{className:SV.inline,children:e.value}):e.type===`break`?(0,K.jsx)(`br`,{}):e.type===`html`?e.value:e.type===`link`?kV(e.url,e.children):e.type===`image`||e.type===`imageReference`?(0,K.jsx)(`span`,{className:SV.image,children:e.alt===void 0||e.alt===null||e.alt===``?`image`:`image: ${e.alt}`}):null,kV=(e,t)=>{if(pV(e))return(0,K.jsxs)(`a`,{className:SV.link,href:e,rel:`noopener noreferrer`,target:`_blank`,children:[DV(t),(0,K.jsx)(Dk,{children:` (opens in a new tab)`})]});let n=t.map(e=>_V(e)).join(``);return n===e||n===``?(0,K.jsx)(`code`,{className:SV.target,children:e}):(0,K.jsxs)(K.Fragment,{children:[DV(t),` (`,(0,K.jsx)(`code`,{className:SV.target,children:e}),`)`]})},AV=(e,t,n)=>{let r=TV(e);if(e.type===`paragraph`)return(0,K.jsx)(`p`,{children:DV(e.children)},r);if(e.type===`heading`){let t=CV[Math.min(6,n.startLevel+e.depth-1)-1]??`h6`;return(0,K.jsx)(t,{children:DV(e.children)},r)}if(e.type===`thematicBreak`)return(0,K.jsx)(`hr`,{},r);if(e.type===`blockquote`)return(0,K.jsx)(`blockquote`,{children:MV(e,n)},r);if(e.type===`list`){let t=e.children.map(e=>(0,K.jsx)(`li`,{children:MV(e,n)},TV(e)));return e.ordered===!0?(0,K.jsx)(`ol`,{start:e.start??1,children:t},r):(0,K.jsx)(`ul`,{children:t},r)}return e.type===`definition`?(0,K.jsxs)(`p`,{children:[`[`,e.label??e.identifier,`]:`,` `,(0,K.jsx)(`code`,{className:SV.target,children:e.url})]},r):e.type===`code`?jV(e.value,e.lang,n,r):e.type===`html`?vV.includes(t.type)?jV(e.value,void 0,n,r):(0,K.jsx)(H.Fragment,{children:e.value},r):null},jV=(e,t,n,r)=>(0,K.jsx)(lC,{caption:t??void 0,command:e,label:n.copyLabel(n.next(),n.blocks)},r),MV=(e,t)=>e.children.map(n=>AV(n,e,t)),NV=e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:SV.note,children:`Could not render this as Markdown: showing the text as written.`}),(0,K.jsx)(`pre`,{className:SV.written,children:e})]}),PV=({text:e,startLevel:t,lead:n=!1,muted:r=!1,copyLabel:i=wV})=>{let a;try{let n=gV(e),r=0;a=MV(n,{startLevel:t,blocks:yV(n),next:()=>++r,copyLabel:i})}catch{a=NV(e)}return(0,K.jsx)(`div`,{className:SV.markdown,"data-lead":n?``:void 0,"data-muted":r?``:void 0,children:a})},FV=e=>{let t=xV(e);return t===1?`1 line`:`${t} lines`},IV=({decision:e,document:t})=>{let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(null),{id:a,node:o,runId:s}=e;return(0,K.jsxs)(`div`,{className:rR.read,children:[(0,K.jsx)(Y,{cli:$L(e),onClick:()=>{r(!0)},variant:`ghost`,children:`Read document`}),(0,K.jsx)(`span`,{className:rR.length,children:FV(t)}),(0,K.jsxs)(PC,{description:`Document for run ${s}. Read-only.`,initialFocus:i,onOpenChange:r,open:n,size:`wide`,title:`\`${o}\` · \`${a}\``,children:[(0,K.jsx)(`div`,{"aria-label":`Document`,className:rR.document,ref:i,role:`region`,tabIndex:0,children:(0,K.jsx)(PV,{copyLabel:QL(`${o} document`),startLevel:3,text:t})}),(0,K.jsx)(FC,{children:(0,K.jsx)(Y,{onClick:()=>{r(!1)},children:`Close`})})]})]})},LV={region:`_region_1w5dd_7`,more:`_more_1w5dd_23`},RV=e=>{let t=Number(getComputedStyle(e).lineHeight.replace(`px`,``));return e.scrollHeight>0&&t>0?Math.round(e.scrollHeight/t):null},zV=({source:e,children:t})=>{let n=(0,H.useRef)(null),r=(0,H.useId)(),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(()=>xV(e)),c=(0,H.useCallback)(()=>{let t=n.current;s((t===null?null:RV(t))??xV(e))},[e]);(0,H.useEffect)(()=>{c();let e=typeof ResizeObserver>`u`?null:new ResizeObserver(c);return n.current!==null&&e?.observe(n.current),()=>{e?.disconnect()}},[c]);let l=o>20;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:LV.region,"data-folded":l&&!i?``:void 0,id:r,onFocus:()=>{a(!0)},ref:n,children:t}),l?(0,K.jsx)(`div`,{className:LV.more,children:(0,K.jsx)(Y,{"aria-controls":r,"aria-expanded":i,onClick:()=>{i&&n.current?.closest(`section`)?.scrollIntoView?.({block:`nearest`}),a(!i)},variant:`ghost`,children:i?`Show less`:`Show all (${o} lines)`})}):null]})},BV=({decision:{kind:e,node:t,question:n,context:r},nameId:i})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{hidden:!0,id:i,children:bV(n)}),(0,K.jsx)(zV,{source:n,children:(0,K.jsx)(PV,{copyLabel:QL(t),lead:!0,startLevel:4,text:n})}),r===void 0?null:e===`permission`?(0,K.jsx)(lC,{caption:eR(r)?`json`:void 0,command:r,label:`Copy command (${t})`}):(0,K.jsx)(zV,{source:r,children:(0,K.jsx)(PV,{copyLabel:QL(t),muted:!0,startLevel:4,text:r})})]}),VV=e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLButtonElement&&!(`option`in e.dataset),HV=({decision:e,workflow:t,unreachable:n=!1,onAnswer:r,onOpenRun:i})=>{let{id:a,runId:o,node:s,document:c,options:l,recommended:u,owner:d}=e,f=(0,H.useId)(),p=(0,H.useId)(),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(``),b=async e=>{if(m||n)return;h(!0),_(null);let t=await r(a,e.id,v);h(!1),t.ok||_(t.error)};return(0,K.jsxs)(`section`,{"aria-labelledby":`${p} ${f}`,className:rR.card,"data-decision":a,onKeyDown:e=>{if(!(e.target instanceof Node)||!e.currentTarget.contains(e.target)||e.metaKey||e.ctrlKey||e.altKey||VV(e.target))return;let t=e.target===e.currentTarget,n=e.key===`Enter`&&t?l.find(e=>e.id===u):ZL(l,e.key);n!==void 0&&(e.preventDefault(),b(n))},tabIndex:0,children:[(0,K.jsxs)(`div`,{className:rR.from,children:[(0,K.jsxs)(`h3`,{className:rR.fromText,id:p,children:[t===void 0?``:`${t} · `,o,` · `,s,d===void 0?``:`, passed on by ${d}`]}),(0,K.jsx)(Y,{onClick:()=>{i(o,s)},variant:`ghost`,children:`Open run`})]}),(0,K.jsx)(BV,{decision:e,nameId:f}),c===void 0?null:(0,K.jsx)(IV,{decision:e,document:c}),(0,K.jsx)(oR,{decision:e,note:v,onChoose:e=>{b(e)},onNote:y,sending:m,unreachable:n}),g===null?null:(0,K.jsxs)(`p`,{className:rR.refusal,role:`alert`,children:[`Could not answer: `,(0,K.jsx)(J,{text:g})]})]})},UV=()=>{let{listFields:e}=sb(),t=yb(e.state);(0,H.useEffect)(()=>{t.status===`idle`&&e.load()},[e,t.status]);let n=()=>{e.load()};return t.status===`ready`?{status:`ready`,fields:t.data,error:null,retry:n}:t.status===`failed`?{status:`failed`,fields:null,error:t.error,retry:n}:{status:`loading`,fields:null,error:null,retry:n}};function WV(e){let{openOnInputClick:t=!1,value:n,defaultValue:r,onValueChange:i,mode:a=`list`,itemToStringValue:o,...s}=e,c=(a===`inline`||a===`both`)&&!e.readOnly,l=a===`inline`||a===`none`,u=n!==void 0,[d,f]=H.useState(r??``),[p,m]=H.useState(``);H.useEffect(()=>{(u||!c)&&m(``)},[n,u,c]);let h;h=c&&p!==``?p:u?n??``:d;let g=Cx({locale:s.locale}),_=String((u?n:d)??``).trim(),v=l||s.filter===null?null:s.filter??g.contains;function y(e,t){m(``),u||f(e),i?.(e,t)}function b(t,n){e.onItemHighlighted?.(t,n),n.reason!==`pointer`&&m(c&&t!=null?Qb(t,o):``)}return(0,K.jsx)(jx,{...s,itemToStringLabel:o,openOnInputClick:t,selectionMode:`none`,fillInputOnItemPress:!0,filter:v,filterQuery:a===`both`?_:void 0,autoComplete:a,inputValue:h,defaultInputValue:r,onInputValueChange:y,onItemHighlighted:b})}var GV=iS,KV=eS,qV=$S,JV=e=>e.value,YV=({label:e,placeholder:t,describedBy:n,invalid:r,suggestions:i,text:a,onText:o,onCommit:s,onRestore:c})=>{let l=(0,H.useId)(),u=(0,H.useRef)(!1),d=(0,H.useRef)(!1);return(0,K.jsxs)(WV,{items:i,itemToStringValue:JV,onItemHighlighted:e=>{u.current=e!==void 0},onOpenChange:e=>{d.current=e},onValueChange:(e,t)=>{t.reason===`item-press`?(o(e),s(e)):t.reason===`input-change`&&o(e)},value:a,children:[(0,K.jsxs)(`div`,{className:rC.field,children:[(0,K.jsx)(`label`,{className:rC.label,htmlFor:l,children:e}),(0,K.jsxs)(KV,{className:rC.group,"data-invalid":r?``:void 0,children:[(0,K.jsx)(Qx,{"aria-describedby":n,"aria-invalid":r?!0:void 0,"aria-label":e,className:rC.input,id:l,onBlur:()=>{s(a)},onKeyDown:e=>{e.key===`Enter`&&!u.current&&s(a),e.key===`Escape`&&!d.current&&c()},placeholder:t}),(0,K.jsx)(GV,{"aria-label":`Show ${e} suggestions`,className:rC.inputButton,children:(0,K.jsx)(ly,{})})]})]}),(0,K.jsx)(wS,{children:(0,K.jsx)(zS,{align:`start`,className:`${a_.positioner} ${a_.suggestions}`,sideOffset:4,children:(0,K.jsx)(VS,{className:a_.popup,children:(0,K.jsx)(vS,{"aria-label":`${e} suggestions`,children:e=>(0,K.jsx)(qV,{className:a_.item,value:e,children:e.label},e.value)})})})})]})},XV={runs:{bar:`runs`,plural:`runs`,singular:`run`,command:`ork ps`,help:`ork ps --help`},decisions:{bar:`decisions`,plural:`decisions`,singular:`decision`,command:`ork decide --list`,help:`ork decide --help`},"follow-ups":{bar:`follow-ups`,plural:`follow-ups`,singular:`follow-up`,command:`ork follow-ups list`,help:`ork follow-ups list --help`},feedback:{bar:`feedback`,plural:`feedback items`,singular:`feedback item`,command:`ork feedback list`,help:`ork feedback list --help`},worktrees:{bar:`worktrees`,plural:`worktrees`,singular:`worktree`,command:`ork worktrees list`,help:`ork worktrees list --help`},usage:{bar:`usage`,plural:`usage rows`,singular:`usage row`,command:`ork usage`,help:`ork usage --help`}},ZV=e=>Object.values(e).some(e=>e!==void 0&&e!==``),QV=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===void 0||t===``?[]:[[e,t]])),$V=e=>/^[\w@%+=:,./-]+$/u.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`,eH=(e,t)=>[XV[e].command,...aD[e].flatMap(e=>{let n=t[e];return n===void 0||n===``?[]:[`--${e} ${$V(n)}`]})].join(` `),tH=e=>/^--([a-z][a-z-]*)/u.exec(e)?.[1],nH=(e,t)=>{let n=tH(t);return n!==void 0&&aD[e].includes(n)?{message:t,field:n}:null},rH=(e,t)=>{let{plural:n,singular:r}=XV[e];return t===0?`No ${n} match.`:t===1?`1 ${r} matches.`:`${String(t)} ${n} match.`},iH=(e,t,n)=>{let{[t]:r,...i}=e;return n===``?i:{...i,[t]:n}},aH=e=>`${e.slice(0,1).toUpperCase()}${e.slice(1)}`,oH={bar:`_bar_1xh9m_9`,fields:`_fields_1xh9m_25`,field:`_field_1xh9m_25`,status:`_status_1xh9m_40`,tools:`_tools_1xh9m_48`,count:`_count_1xh9m_56`,note:`_note_1xh9m_68`,alert:`_alert_1xh9m_74`,failed:`_failed_1xh9m_83`,actions:`_actions_1xh9m_89`},sH=`~unset`,cH=[`24h`,`7d`,`30d`,`90d`],lH={workflow:`workflow name`,run:`run id or prefix`,project:`id, root or all`,for:`agent, me, project:name`,since:`24h, 30d or 2026-11-01`,until:`2026-11-01`},uH=e=>({value:e,label:e}),dH=(e,t)=>[...e.type===`since`?[...cH,...e.all===!0?[`all`]:[]].map(e=>uH(e)):e.name===`for`?[`agent`,`me`].map(e=>uH(e)):e.name===`project`?[uH(`all`)]:[],...t],fH=(e,t)=>[{value:sH,label:t===void 0?`Any`:`Default (${t})`},...(e.values??[]).map(e=>uH(e)),...e.all===!0&&t!==void 0?[{value:`all`,label:`All`}]:[]],pH=({field:e,alertId:t,idPrefix:n,fallback:r,suggestions:i,value:a,draft:o,onApply:s,onDraft:c,onCommit:l,onRestore:u})=>{let{name:d}=e,f=aH(d),p=`${n}-${d}-help`,m=t!==void 0,h=m?`${p} ${t}`:p,[g,_]=(0,H.useState)(!1);return(0,K.jsx)(l_,{disabled:g,label:e.description,children:(0,K.jsxs)(`div`,{className:oH.field,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},onFocus:()=>{_(!0)},"data-narrow":e.type===`since`||e.type===`until`?``:void 0,children:[e.type===`enum`?(0,K.jsx)(Ok,{describedBy:h,invalid:m,label:f,onChange:e=>{s(e===sH?``:e)},options:fH(e,r),value:a??sH}):(0,K.jsx)(YV,{describedBy:h,invalid:m,label:f,onCommit:l,onRestore:u,onText:c,placeholder:r===void 0?lH[d]??``:`Default: ${r}`,suggestions:dH(e,i),text:o??a??``}),(0,K.jsx)(Dk,{children:(0,K.jsx)(`span`,{id:p,children:e.description})})]})})},mH=({id:e,text:t})=>(0,K.jsxs)(`p`,{className:oH.alert,id:e,role:`alert`,children:[(0,K.jsx)(My,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:t})})]}),hH=({list:e,error:t,onRetry:n})=>{let{help:r}=XV[e];return(0,K.jsxs)(`div`,{className:oH.failed,children:[(0,K.jsx)(mH,{text:`Couldn't read the filter fields: ${t}. The list shows without filters.`}),(0,K.jsx)(`div`,{className:oH.actions,children:(0,K.jsx)(Y,{onClick:n,children:`Try again`})}),(0,K.jsx)(lC,{command:r,label:`Copy command (${r})`})]})},gH=({list:e,values:t,onClear:n})=>(0,K.jsxs)(dO,{cli:eH(e,t),title:`No ${XV[e].plural} match the filter.`,children:[(0,K.jsx)(`p`,{children:`Clear the filter to see the default list.`}),(0,K.jsx)(Y,{cli:XV[e].command,onClick:n,variant:`ghost`,children:`Clear filter`})]}),_H=e=>`${e?`The list shows the last filter that worked.`:`Nothing is filtered yet.`} Fix the value, or clear the filter.`,vH={},yH={},bH=(e,t)=>{let{[t]:n,...r}=e;return r},xH=({list:e,values:t,onChange:n,error:r=null,busy:i=!1,worked:a,shown:o=null,summary:s,defaults:c=vH,suggestions:l=yH,extra:u,tools:d})=>{let f=UV(),p=(0,H.useId)(),m=(0,H.useRef)(null),h=(0,H.useRef)(!1),[g,_]=(0,H.useState)({}),[v,y]=(0,H.useState)(!1),b=XV[e],x=ZV(t),[S,C]=(0,H.useState)({});r===null&&!i&&S!==t&&C(t);let w=a??S,T=r===null?void 0:r.field??tH(r.message),E=`${p}-alert`,D=e=>{y(!1),n(e)},O=(e,n)=>{if(h.current)return;_(t=>bH(t,e));let r=n.trim();r!==(t[e]??``)&&D(iH(t,e,r))},k=()=>{h.current=!1,_({}),y(!0),n({}),m.current?.querySelector(`input, [role='combobox']`)?.focus()},A=(f.fields?.[e]??[]).filter(e=>e.name!==`project`||(l.project?.length??0)>=2||t.project!==void 0),j=eH(e,r===null?t:w),M=v?`Filter cleared.`:i?`Updating…`:x?o===null?``:rH(e,o):s??``;return(0,K.jsxs)(`search`,{role:`search`,"aria-label":`Filter ${b.bar}`,className:oH.bar,ref:m,children:[f.status===`loading`?(0,K.jsx)(`output`,{className:oH.note,children:`Reading filters…`}):null,f.status===`failed`?(0,K.jsx)(hH,{error:f.error,list:e,onRetry:f.retry}):null,f.status===`ready`?(0,K.jsxs)(`div`,{className:oH.fields,children:[A.map(e=>(0,K.jsx)(pH,{alertId:T===e.name?E:void 0,draft:g[e.name],field:e,fallback:c[e.name],idPrefix:p,onApply:n=>{D(iH(t,e.name,n))},onCommit:t=>{O(e.name,t)},onDraft:t=>{_(n=>({...n,[e.name]:t}))},onRestore:()=>{_(t=>bH(t,e.name))},suggestions:l[e.name]??[],value:t[e.name]},e.name)),u]}):null,(0,K.jsxs)(`div`,{className:oH.status,children:[(0,K.jsx)(`output`,{className:oH.count,children:M}),d===void 0?null:(0,K.jsx)(`div`,{className:oH.tools,children:d})]}),r===null?null:(0,K.jsx)(mH,{id:E,text:`${r.message} ${_H(ZV(w))}`}),x?(0,K.jsxs)(`div`,{className:oH.actions,children:[(0,K.jsx)(Y,{cli:b.command,onBlur:()=>{h.current=!1},onClick:k,onPointerDown:()=>{h.current=!0},variant:`ghost`,children:`Clear filter`}),(0,K.jsx)(lC,{command:j,label:`Copy command (${j})`})]}):null]})},SH=({values:e,onChange:t,open:n,workflowOf:r,projects:i,runs:a,read:o})=>(0,K.jsx)(`div`,{className:rR.filter,children:(0,K.jsx)(xH,{busy:o.busy,error:o.error===null?null:nH(`decisions`,o.error),list:`decisions`,onChange:t,shown:o.answered?o.rows.length:null,suggestions:tR(n,r,i,a),summary:nR(n.length),values:e})}),CH=e=>{let t=lb.create(null),n=lb.create(null),r=lb.create(null),i=lb.create(null),a=lb.create([]),o=Promise.resolve(),s=(t,n)=>{e.chooseBuilder({project:t.project,workflow:t.name,node:n,draft:r.getValue()?.draft??!1})};return{project:t,opened:n,view:r,selected:i,history:a,inTurn:e=>{let t=o.then(e,e);return o=t.catch(()=>null),t},show:(t,o)=>{let c=n.getValue();n.setValue(t),r.setValue(o),i.setValue(null),a.setValue([]),t===null?e.builderClosed():(t!==c&&s(t,null),o!==null&&e.builderChanged(t.project,t.name,o.draft))},update:t=>{r.setValue(t);let i=n.getValue();i!==null&&e.builderChanged(i.project,i.name,t.draft)},select:e=>{i.setValue(e);let t=n.getValue();t!==null&&s(t,e)}}},wH=(e,t,n)=>e?.kind===`builder`&&e.project===t&&e.workflow===n,TH=()=>{let e=lb.create(null),t=t=>{e.setValue(t)},n=n=>{let r=e.getValue();t({kind:`builder`,...n,revision:wH(r,n.project,n.workflow)?r.revision:0})},r=(n,r,i)=>{let a=e.getValue();wH(a,n,r)&&t({...a,draft:i,revision:a.revision+1})},i=()=>{e.getValue()?.kind===`builder`&&t(null)};return{target:e,chooseBuilder:n,builderChanged:r,builderClosed:i,builder:CH({chooseBuilder:n,builderChanged:r,builderClosed:i}),chooseRun:(e,n)=>{t(e===null?null:{kind:`run`,run:e,node:n})}}},EH=e=>{let t=lb.create([]),n=new Map,r=async n=>{let r=await e.call(`decision`,{params:{id:n.id}}),i=r.ok?r.data:n;t.setValue([i,...t.getValue()].slice(0,20))};return{settled:t,saw:e=>{let t=new Map((e??[]).map(e=>[e.id,e]));for(let[e,i]of n)t.has(e)||r(i);n=t}}},DH=2e3,OH={events:[],latest:0,following:!0},kH=e=>e.events[0]?.seq??1,AH=e=>e.events.at(-1)?.seq??0,jH=e=>kH(e)>1,MH=e=>AH(e)<e.latest,NH=e=>e.slice(-2e3),PH=(e,t)=>Math.max(e.latest,t.at(-1)?.seq??0),FH=(e,t)=>{let n=AH(e);return t.filter(e=>e.seq>n)},IH=(e,t)=>{let n=PH(e,t);return e.following&&!MH(e)?{...e,latest:n,events:NH([...e.events,...FH(e,t)])}:{...e,latest:n}},LH=(e,t)=>({events:NH(t),latest:PH(e,t),following:!0}),RH=(e,t)=>({...e,latest:PH(e,t),events:NH([...e.events,...FH(e,t)])}),zH=(e,t)=>{let n=kH(e),r=[...t.filter(e=>e.seq<n),...e.events].slice(0,DH),i={...e,events:r};return{...i,following:e.following&&!MH(i)}},BH=e=>{let t=kH(e)-1,n=Math.max(0,t-500);return{after:n,limit:t-n}},VH=e=>new EventSource(e),HH=2,UH=1e3,WH=15e3,GH=e=>{try{return JSON.parse(e)}catch{return}},KH=({url:e,open:t,on:n,onStatus:r,onFailure:i})=>{let a=null,o=null,s=UH,c=null,l=e=>{e!==c&&(c=e,r(e))},u=()=>{let r=t(e());a=r,r.addEventListener(`open`,()=>{s=UH,l(`open`)}),r.addEventListener(`error`,()=>{l(`lost`),i?.(),r.readyState===HH&&(r.close(),o=setTimeout(u,s),s=Math.min(s*2,WH))});let c=Object.entries(n);for(let[e,t]of c)r.addEventListener(e,e=>{let n=GH(e.data);n!==void 0&&t(n)})};return l(`connecting`),u(),{close:()=>{o!==null&&clearTimeout(o),o=null,a?.close(),a=null}}},qH=1e3,JH=({runId:e,client:t,open:n})=>{let r=lb.create({...OH,tail:[],link:`idle`,ended:null,paging:!1,error:null}),i=null,a=!1,o=!1,s=0,c=[],l=null,u=null,d=e=>{r.setValue({...r.getValue(),...e})},f=()=>c.at(-1)?.seq??r.getValue().latest,p=async(n,i)=>{d({paging:!0});let a=await t.call(`events`,{params:{id:e},query:n});return a.ok?(d({...i(r.getValue(),a.data),...n.last===void 0?{}:{tail:a.data},paging:!1,error:null}),!0):(d({paging:!1,error:a.error}),!1)},m=async()=>{let e=r.getValue();e.following&&MH(e)&&!e.paging&&await p({after:AH(e),limit:500},RH)&&await m()},h=()=>{if(l!==null&&clearTimeout(l),l=null,c.length===0)return;let e=c;c=[];let t=r.getValue(),n=t.tail.at(-1)?.seq??0;d({...IH(t,e),tail:[...t.tail,...e.filter(e=>e.seq>n)].slice(-500)}),m()},g=()=>{i?.close(),i=null},_=()=>{i=KH({url:()=>`${QD(ZD.run,{id:e})}?after=${String(f())}`,open:n,on:{"run-event":e=>{e.seq<=f()||(c.push(e),l??=setTimeout(h,50))},end:({reason:e})=>{h(),g(),o=!1,d({link:`ended`,ended:e})}},onStatus:e=>{d({link:e===`open`?`live`:e===`lost`?`lost`:`loading`})}})},v=async()=>{let e=s;d({link:`loading`});let t=await p({last:500},LH);e===s&&(t?(a=!0,_()):(d({link:`lost`}),u=setTimeout(()=>void v(),qH)))};return{state:r,start:()=>{o||(o=!0,s+=1,d({ended:null}),a?_():v())},stop:()=>{o=!1,s+=1,u!==null&&clearTimeout(u),u=null,h(),g(),r.getValue().link!==`ended`&&d({link:`idle`})},loadOlder:async()=>{let e=r.getValue();jH(e)&&!e.paging&&await p(BH(e),zH)},loadNewer:async()=>{let e=r.getValue();MH(e)&&!e.paging&&await p({after:AH(e),limit:500},RH)},hold:()=>{d({following:!1})},follow:async()=>{let e=r.getValue();e.paging||(MH(e)?await p({last:500},LH):d({following:!0}),await m())}}},YH=({runId:e,client:t,feed:n})=>{let r=lb.create({graph:null,tree:null,links:[],error:null}),i=e=>{r.setValue({...r.getValue(),...e})},a=0,o=async()=>{a+=1;let n=a,[o,s]=await Promise.all([t.call(`tree`,{params:{id:e}}),t.call(`links`,{query:{run:e}})]);n===a&&(o.ok?i({tree:o.data,links:s.ok?s.data:r.getValue().links,error:null}):i({error:o.error}))},s=async()=>{let n=await t.call(`graph`,{params:{id:e}});n.ok?i({graph:n.data}):i({error:n.error})};return{state:r,start:()=>{let e=null,t=n.state.getValue().latest;s(),o();let r=n.state.subscribe(({latest:n})=>{n!==t&&(t=n,e??=setTimeout(()=>{e=null,o()},250))});return()=>{r(),e!==null&&clearTimeout(e),a+=1}}}},XH=e=>e.live===`running`||e.live===`paused`,ZH=({client:e,open:t})=>{let n=new Map,r=r=>{let i=n.get(r)??{feed:JH({runId:r,client:e,open:t}),retained:0};return n.set(r,i),i},i=()=>{let e=[...n].filter(([,e])=>e.retained===0);for(let[t]of e.slice(0,-4))n.delete(t)};return{reopenResumed:e=>{for(let t of e??[]){let e=n.get(t.id);e!==void 0&&e.retained>0&&XH(t)&&e.feed.state.getValue().link===`ended`&&e.feed.start()}},feedOf:e=>r(e).feed,retainRun:e=>{let t=r(e);return t.retained+=1,t.feed.start(),()=>{--t.retained,t.retained===0&&(t.feed.stop(),n.delete(e),n.set(e,t),i())}},watchRun:t=>YH({runId:t,client:e,feed:r(t).feed})}},QH=`ork.notifications.read`,$H=gs({before:B().nullable(),ids:ms(B())}),eU=e=>{if(e.live===`running`)return null;let t=e.live===`paused`||e.live===`crashed`;return{id:`run:${e.id}:${e.live}`,kind:`run`,runId:e.id,status:e.live,title:`Run ${e.id} of ${e.workflow} ${cM(e.live)}.`,at:e.finishedAt??e.startedAt,pending:t}},tU=e=>({id:`decision:${e.id}`,kind:`decision`,runId:e.runId,node:e.node,status:`waiting`,title:`${e.node} in run ${e.runId} asks: ${e.question}`,at:e.openedAt,pending:!0}),nU=(e,t)=>[...t.map(e=>tU(e)),...e.flatMap(e=>eU(e)??[])].toSorted((e,t)=>t.at.localeCompare(e.at)),rU=(e,t)=>t.ids.includes(e.id)||!e.pending&&t.before!==null&&e.at<=t.before,iU=({runs:e,decisions:t,storage:n,now:r=()=>new Date().toISOString()})=>{let i=new db({before:null,ids:[]},{key:QH,storage:n});$H.safeParse(i.getValue()).success||i.reset();let a=lb.create({items:[],unread:0}),o=null,s=new Set,c=[],l=()=>{let e=i.getValue(),t=c.map(t=>({...t,unread:!rU(t,e)}));a.setValue({items:t,unread:t.filter(({unread:e})=>e).length})},u=()=>{let n=e.getValue(),a=t.getValue();if(n===null||a===null)return;c=nU(n,a),i.getValue().before===null&&i.setValue({...i.getValue(),before:r()});let u=o,d=u===null?[]:c.filter(({id:e})=>!u.has(e));if(o=new Set(c.map(({id:e})=>e)),l(),d.length>0)for(let e of s)e(d)};return{view:a,start:()=>{let n=e.subscribe(u),r=t.subscribe(u);return u(),()=>{n(),r()}},onNew:e=>(s.add(e),()=>{s.delete(e)}),markRead:e=>{let t=i.getValue();i.setValue({...t,ids:[...t.ids,e].slice(-200)}),l()},markAllRead:()=>{i.setValue({before:r(),ids:c.filter(({pending:e})=>e).map(({id:e})=>e).slice(-200)}),l()}}},aU={count:0,items:[]},oU=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===void 0||t===``?[]:[[e,t]])),sU=async(e,t)=>{let n=oU(t),r=await e.call(`projects`);if(!r.ok)return r;let i=await Promise.all(r.data.map(async t=>({project:t,answer:await e.call(`followUps`,{params:{id:t.id},query:n})}))),a=[],o=[];for(let{project:e,answer:t}of i){if(!t.ok)return t;o.push(...t.data.checker.errors);for(let n of t.data.followUps)a.push({...n,projectId:e.id})}return{ok:!0,status:200,data:{rows:a,projects:r.data.map(e=>e.id),checker:{available:o.length===0,errors:[...new Set(o)]}}}},cU=()=>lb.create({}),lU=e=>e.status===`ready`?{data:e.data,arg:e.arg}:e.status===`idle`?void 0:e.shown,uU=e=>{let t=lb.create({status:`idle`}),n=0;return{state:t,load:async r=>{n+=1;let i=n,a=lU(t.getValue());t.setValue({status:`loading`,arg:r,...a===void 0?{}:{shown:a}});let o=await e(r);i===n&&t.setValue(o.ok?{status:`ready`,arg:r,data:o.data}:{status:`failed`,arg:r,error:o.error,code:o.status,...a===void 0?{}:{shown:a}})}}},dU=(e,t)=>JSON.stringify(e)===JSON.stringify(t),fU=(e,t)=>{if(e===null)return t;let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t!==void 0&&dU(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r},pU=({client:e,open:t,pageVersion:n})=>{let r=lb.create(null),i=lb.create(null);return{info:r,open:t,pageVersion:n,dialog:i,restarting:lb.create(!1),receive:e=>{r.setValue(e)},refresh:async()=>{let t=await e.call(`version`);t.ok&&r.setValue(t.data)},openDialog:e=>{i.setValue(e)},closeDialog:()=>{i.setValue(null)}}},mU=({client:e,open:t,pageVersion:n,runs:r,decisions:i})=>{let a=pU({client:e,open:t,pageVersion:n}),o=lb.create(aU);return{version:a,followUpsDue:o,followUps:uU(t=>sU(e,t)),followUpsFilter:cU(),follow:e=>KH({url:()=>ZD.overview,open:t,on:{runs:e=>{r.setValue(fU(r.getValue(),e))},decisions:e=>{i.setValue(fU(i.getValue(),e))},version:a.receive,followUps:e=>{o.setValue(e)}},...e})}},hU=({link:e,server:t})=>e===`lost`||t!==null&&`error`in t,gU=e=>{let{link:t,server:n}=e;return n!==null&&`error`in n?`Cannot reach \`ork ui\`: ${n.error}`:hU(e)?"Lost the stream from `ork ui`. Retrying…":t===`open`&&n!==null?`Ork ${n.version}`:"Connecting to `ork ui`…"},_U=e=>e===null?null:e.filter(e=>XH(e)).length,vU=({client:e,open:t,storage:n,pageVersion:r=null})=>{let i=lb.create(null),a=lb.create(null),o=lb.create({link:`connecting`,server:null}),s=lb.create({run:null,node:null}),c=TH(),l=null,u=e=>{e.run!==l&&(l=null),s.setValue(e),c.chooseRun(e.run,e.node)},d=hb(n),f=lb.create({}),p=lb.create({}),m=lb.create(!1),h=lb.create(null),g=uU(()=>e.call(`projects`)),_=uU(()=>e.call(`triggers`)),v=uU(()=>e.call(`listFields`)),y=uU(t=>e.call(`workflows`,{params:{id:t}})),b=lb.create({}),x=uU(({query:t})=>e.call(`usage`,{query:t})),S=lb.create({values:{},about:`all`}),C=uU(t=>e.call(`feedbackItems`,{query:t})),w=lb.create({}),T=uU(t=>e.call(`worktrees`,{query:t})),E=ZH({client:e,open:t}),D=EH(e),O=iU({runs:i,decisions:a,storage:n}),k=mU({client:e,open:t,pageVersion:r,runs:i,decisions:a}),{version:A,followUps:j,followUpsFilter:M,followUpsDue:N}=k,P=async()=>{let t=await e.call(`health`);o.setValue({...o.getValue(),server:t.ok?t.data:{error:t.error}})};return{runs:i,decisions:a,connection:o,selection:s,contextTarget:c.target,builder:c.builder,preferences:d,runFilter:f,runFilterWorked:p,runDialog:m,runPreset:h,client:e,settledDecisions:D.settled,notifications:O,projects:g,workflows:y,usage:x,usageFilter:b,feedback:C,feedbackFilter:S,followUps:j,followUpsFilter:M,followUpsDue:N,worktrees:T,worktreesFilter:w,triggers:_,listFields:v,version:A,startRun:t=>e.call(`start`,{body:t}),start:()=>{let e=i.subscribe(E.reopenResumed),t=a.subscribe(D.saw),n=O.start(),r=k.follow({onStatus:e=>{o.setValue({...o.getValue(),link:e}),e!==`lost`&&P()},onFailure:()=>void P()});return()=>{e(),t(),n(),r.close()}},feedOf:E.feedOf,retainRun:E.retainRun,control:(t,n,r)=>e.call(t,{params:{id:n},body:r===void 0?{}:{node:r}}),sendMessage:(t,n,r)=>e.call(`message`,{params:{id:t},body:{node:n,body:r}}),answerDecision:(t,n,r=``)=>e.call(`answer`,{params:{id:t},body:r.trim()===``?{choose:n}:{choose:n,note:r}}),watchRun:E.watchRun,selectRun:e=>{l=null,u({run:e,node:null})},arriveAt:e=>{l=e,u({run:e,node:null})},takeArrival:e=>{let t=l===e;return t&&(l=null),t},selectNode:e=>{u({...s.getValue(),node:e})}}},yU=()=>hU(yb(sb().connection)),bU=()=>(0,K.jsxs)(`p`,{className:rR.unreachable,"data-unreachable-notice":``,children:[(0,K.jsx)(My,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:"Cannot answer here: `ork ui` is not reachable. Answer from a terminal with the command under each option."})})]}),xU=({error:e})=>(0,K.jsxs)(`p`,{className:rR.readFailed,"data-read-failed":``,role:`alert`,children:[(0,K.jsx)(My,{"aria-hidden":`true`}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Could not read decisions: ${e}`})})]}),SU=({values:e,onClear:t})=>ZV(e)?(0,K.jsx)(gH,{list:`decisions`,onClear:t,values:e}):(0,K.jsx)(dO,{cli:`ork decide`,title:`No decisions waiting.`,children:`Questions from your runs land here. In a terminal:`}),CU=({settled:e})=>e.length===0?null:(0,K.jsxs)(`section`,{"aria-label":`Settled decisions`,className:rR.settled,children:[(0,K.jsx)(`h3`,{className:rR.settledTitle,children:`Settled`}),(0,K.jsx)(`ul`,{className:rR.settledList,children:e.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:rR.settledQuestion,children:e.question}),(0,K.jsxs)(`span`,{className:rR.settledEnding,children:[(0,K.jsx)(`code`,{children:e.runId}),` · `,(0,K.jsx)(`code`,{children:e.node}),`.`,` `,(0,K.jsx)(J,{text:YL(e)})]}),XL(e)===void 0?null:(0,K.jsx)(`span`,{className:rR.settledNote,children:XL(e)})]},e.id))})]}),wU=(0,H.createContext)(null),TU=e=>e.split(`/`).at(-1)??e,EU=e=>e.split(`/`).slice(-2).join(`/`),DU=(e,t)=>{let n=new Map(e.map(({root:e,id:t})=>[e,t]));for(let{project:e}of t)n.has(e)||n.set(e,TU(e));let r=[...n.values()],i=e=>r.indexOf(e)!==r.lastIndexOf(e);return[{value:`all`,label:`All projects`},...[...n].map(([e,t])=>({value:e,label:i(t)?EU(e):t})).toSorted((e,t)=>e.label.localeCompare(t.label))]},OU=e=>vb(e.decisions,e=>new Set((e??[]).map(({runId:e})=>e))),kU=e=>{let t=yb(e.projects.state);return(0,H.useEffect)(()=>{e.projects.load()},[e]),t.status===`ready`?t.data:[]},AU=e=>({...e.status===void 0?{}:{status:e.status},...e.workflow===void 0?{}:{workflow:e.workflow},...e.project===void 0?{}:{project:e.project},...e.since===void 0?{}:{since:e.since},...e.until===void 0?{}:{until:e.until}}),jU={values:{},rows:null,refused:null,failed:null},MU=(e,t)=>{let n=ZV(t),r=vb(e.runs,e=>e?.map(e=>`${e.id}:${e.live}`).join()??``),[i,a]=(0,H.useState)(jU),o=yb(e.runFilterWorked),[s,c]=(0,H.useState)(n);return s!==n&&(c(n),n||a(jU)),(0,H.useEffect)(()=>{let r=!0;return n?(async()=>{let n=await e.client.call(`runs`,{query:AU(t)});if(!r)return;let i=!n.ok&&n.status===400;n.ok&&e.runFilterWorked.setValue(t);let o=e.runFilterWorked.getValue(),s=i&&ZV(o)?await e.client.call(`runs`,{query:AU(o)}):void 0;r&&a(e=>({values:t,rows:n.ok?n.data:e.rows??(s?.ok===!0?s.data:null),refused:i?n.error:null,failed:n.ok||i?null:n.error}))})():e.runFilterWorked.setValue({}),()=>{r=!1}},[e,n,t,r]),{filtered:n,rows:n?i.rows:null,busy:n&&i.values!==t,refused:n?i.refused:null,failed:n?i.failed:null,worked:o}},NU=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===void 0||t===``?[]:[[e,t]])),PU=()=>{let{value:e,update:t}=sb().preferences;return{values:yb(e).decisionFilter,set:e=>{t({decisionFilter:NU(e)})}}},FU=(e,t)=>{let{client:n,decisions:r}=sb(),[i,a]=(0,H.useState)(null),o=ZV(e),s=JSON.stringify(NU(e)),[c,l]=(0,H.useState)(o);c!==o&&(l(o),o||a(null)),(0,H.useEffect)(()=>{if(!o)return()=>{};let t=!0,i=async()=>{let r=await n.call(`decisions`,{query:NU(e)});t&&a(e=>({key:s,rows:r.ok?r.data:e?.rows??null,error:r.ok?null:r.error}))};i();let c=r.subscribe(()=>{i()});return()=>{t=!1,c()}},[n,r,o,s,e]);let u=i!==null&&i.key===s;return{rows:o?i?.rows??t:t,answered:!o||(i?.rows??null)!==null,busy:o&&!u,error:o&&u?i.error:null,failure:o&&u&&i.error!==null&&nH(`decisions`,i.error)===null?i.error:null}},IU=e=>{let t=sb(),n=yb(t.runs),r=kU(t);return(0,H.useMemo)(()=>{let t=new Set(e.map(({runId:e})=>e));return DU(r,(n??[]).filter(({id:e})=>t.has(e))).filter(e=>e.value!==`all`)},[r,n,e])},LU=e=>{let t=(0,H.use)(wU),n=(0,H.useRef)(e[0]?.id);(0,H.useEffect)(()=>{let r=e[0];r!==void 0&&r.id!==n.current&&(n.current=r.id,t?.announce(`${r.question} ${YL(r)}`))},[e,t])},RU=e=>e.tabIndex>=0?e:e.querySelector(`button`),zU=(e,t)=>{let n=(0,H.useRef)(null),r=(0,H.useRef)(null),i=(0,H.useRef)(e),a=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(e===i.current)return;i.current=e;let a=r.current;if(a===null||document.activeElement!==document.body)return;let o=n.current?.querySelectorAll(t),s=o?.[Math.min(a,(o.length||1)-1)];((s===void 0?null:RU(s))??n.current)?.focus()},[e,t]),(0,H.useEffect)(()=>{let e=a.current;e instanceof Node&&!e.isConnected&&(a.current=null,document.activeElement===document.body&&n.current?.focus())}),{panel:n,onFocus:e=>{let{target:n,currentTarget:i}=e;a.current=n;let o=n instanceof Element?n.closest(t):null;r.current=o===null?null:[...i.querySelectorAll(t)].indexOf(o)}}},BU={},VU=()=>{let e=sb(),t=yb(e.decisions),n=yb(e.settledDecisions),r=yb(e.runs),i=yU(),a=PU(),o=(0,H.useMemo)(()=>t??[],[t]),s=(0,H.useCallback)(e=>r?.find(({id:t})=>t===e)?.workflow,[r]),c=IU(o),l=FU(a.values,o),u=l.rows,d=l.failure,{panel:f,onFocus:p}=zU(u.map(({id:e})=>e).join(`
103
+ `),`[data-decision]`);return LU(n),(0,K.jsxs)(`div`,{"aria-label":`Decisions`,className:rR.panel,onFocus:p,ref:f,role:`group`,tabIndex:-1,children:[(0,K.jsx)(SH,{onChange:a.set,open:o,projects:c,read:l,runs:r??[],values:a.values,workflowOf:s}),d===null?null:(0,K.jsx)(xU,{error:d}),u.length===0?(0,K.jsx)(SU,{onClear:()=>{a.set({})},values:l.answered?a.values:BU}):(0,K.jsxs)(`div`,{className:rR.list,children:[i?(0,K.jsx)(bU,{}):null,u.map(t=>(0,K.jsx)(HV,{decision:t,onAnswer:e.answerDecision,onOpenRun:(t,n)=>{e.selectRun(t),e.selectNode(n)},unreachable:i,workflow:s(t.runId)},t.id))]}),(0,K.jsx)(CU,{settled:n})]})},HU={panel:`_panel_uofd0_8`,tools:`_tools_uofd0_24`,main:`_main_uofd0_39`,status:`_status_uofd0_52`,counts:`_counts_uofd0_65`,error:`_error_uofd0_82`,list:`_list_uofd0_91`,item:`_item_uofd0_106`,row:`_row_uofd0_113`,time:`_time_uofd0_152`,type:`_type_uofd0_153`,label:`_label_uofd0_159`,node:`_node_uofd0_165`,line:`_line_uofd0_167`,detail:`_detail_uofd0_192`,end:`_end_uofd0_216`},UU=e=>e.map(e=>({value:e,label:e})),WU=({events:e,node:t,type:n,text:r,onNode:i,onType:a,onText:o})=>{let s=FL(e,t),c=s.map(e=>PL(e,s));return(0,K.jsxs)(`div`,{className:HU.tools,children:[(0,K.jsx)(oC,{empty:`No node matches.`,label:`Node`,onChange:i,options:c,placeholder:`All nodes`,value:t}),(0,K.jsx)(oC,{empty:`No event type matches.`,label:`Event`,onChange:a,options:UU(IL(e)),placeholder:`All events`,value:n}),(0,K.jsx)(jk,{label:`Text`,onChange:o,value:r})]})},GU={end:`_end_wtaow_6`,note:`_note_wtaow_15`},KU={agent:`failed`,workflow:`failed`,ork:`failed`,account:`waiting`,provider:`interrupted`,user:`interrupted`},qU=e=>KU[e],JU=({end:e,pill:t=!1})=>e.actor===null?null:(0,K.jsxs)(`span`,{className:GU.end,children:[(0,K.jsx)(dM,{pill:t,status:qU(e.actor),word:e.label}),e.transient?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(Dk,{children:`, `}),(0,K.jsx)(`span`,{className:GU.note,"data-transient":!0,children:`may pass`})]}):null]}),YU={well:`_well_14iu2_8`},XU=32,ZU=({label:e,text:t,follow:n=!0,ref:r})=>{let i=(0,H.useRef)(null),a=r??i,o=(0,H.useRef)(!0);return(0,H.useLayoutEffect)(()=>{let e=a.current;e!==null&&n&&o.current&&(e.scrollTop=e.scrollHeight)}),(0,K.jsx)(`section`,{"aria-label":e,className:YU.well,onScroll:()=>{let e=a.current;e!==null&&(o.current=e.scrollHeight-e.scrollTop-e.clientHeight<XU)},ref:a,tabIndex:0,children:t})},QU={details:`_details_1cytm_6`,open:`_open_1cytm_16`,bar:`_bar_1cytm_25`,caption:`_caption_1cytm_35`,copy:`_copy_1cytm_49`},$U=({node:e,detail:t,cli:n})=>{let[r,i]=(0,H.useState)(!1),a=(0,H.useId)();return t===void 0?null:(0,K.jsxs)(`div`,{className:QU.details,children:[(0,K.jsxs)(Y,{"aria-controls":r?a:void 0,"aria-expanded":r,cli:n,onClick:()=>{i(e=>!e)},variant:`ghost`,children:[r?(0,K.jsx)(ly,{}):(0,K.jsx)(uy,{}),`Details`]}),r?(0,K.jsxs)(`div`,{className:QU.open,id:a,children:[(0,K.jsxs)(`div`,{className:QU.bar,children:[(0,K.jsx)(`span`,{className:QU.caption,children:`Scrubbed. At most 4 KiB.`}),(0,K.jsx)(`span`,{className:QU.copy,children:(0,K.jsx)(sC,{label:`Copy details`,text:t})})]}),(0,K.jsx)(ZU,{follow:!1,label:`Raw details of ${e}`,text:t})]}):null]})},eW={note:`_note_1tzmy_7`,message:`_message_1tzmy_24`,hint:`_hint_1tzmy_25`,facts:`_facts_1tzmy_42`,who:`_who_1tzmy_53`,guide:`_guide_1tzmy_81`},tW=`https://github.com/mimshins/ork/blob/main/docs/guides/why-a-node-stopped.md`,nW={agent:`the agent`,workflow:`the workflow`,account:`your account`,provider:`the provider`,user:`you`,ork:`Ork`},rW=e=>e.endsWith(`.`)?e:`${e}.`,iW=({node:e,end:t,runId:n})=>t.actor===null?null:(0,K.jsxs)(`div`,{"aria-label":`How ${e} ended`,className:eW.note,role:`group`,children:[(0,K.jsxs)(`p`,{className:eW.message,children:[(0,K.jsx)(JU,{end:t,pill:!0}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`code`,{children:e}),` `,(0,K.jsx)(J,{text:rW(t.message)})]})]}),t.hint===``?null:(0,K.jsx)(`p`,{className:eW.hint,children:(0,K.jsx)(J,{text:t.hint})}),(0,K.jsxs)(`div`,{className:eW.facts,children:[(0,K.jsxs)(`dl`,{className:eW.who,children:[(0,K.jsx)(`dt`,{children:`Who acts`}),(0,K.jsx)(`dd`,{children:nW[t.actor]})]}),(0,K.jsxs)(`a`,{className:eW.guide,href:`${tW}#${t.docsAnchor}`,rel:`noreferrer`,target:`_blank`,children:[`Why a node stops`,(0,K.jsx)(Fy,{}),(0,K.jsx)(Dk,{children:` — what ${t.label} means (opens the guide in a new tab)`})]})]}),(0,K.jsx)($U,{cli:`ork logs ${n} --node ${e}`,detail:t.detail,node:e})]}),aW=(0,H.memo)(({stored:e,open:t,tabbable:n,onToggle:r})=>{let{seq:i,at:a,event:o}=e,s=SL(o),c=EL(o);return(0,K.jsxs)(`li`,{className:HU.item,children:[(0,K.jsxs)(`button`,{"aria-expanded":t,className:HU.row,"data-log-row":i,onClick:()=>{r(i)},tabIndex:n?0:-1,type:`button`,children:[(0,K.jsx)(`span`,{className:HU.time,children:zL(a)}),(0,K.jsx)(`span`,{className:HU.node,children:bL(o)??`run`}),(0,K.jsx)(`span`,{className:HU.type,children:o.type}),(0,K.jsx)(`span`,{className:HU.line,children:s===void 0?(0,K.jsxs)(K.Fragment,{children:[DL(o),c===void 0?null:(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsxs)(`span`,{className:HU.label,children:[`· `,c]})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(JU,{end:s.end}),` `,wL(s)]})})]}),t&&s!==void 0?(0,K.jsx)(`div`,{className:HU.end,children:(0,K.jsx)(iW,{end:s.end,node:s.id,runId:e.runId})}):null,t?(0,K.jsx)(`pre`,{"aria-label":`Event ${String(i)} in full`,className:HU.detail,role:`group`,tabIndex:0,children:JSON.stringify(o,null,2)}):null]})});aW.displayName=`LogRow`;var oW=({shown:e,listRef:t,onScroll:n,label:r,reading:i})=>{let[a,o]=(0,H.useState)(new Set),[s,c]=(0,H.useState)(null),l=e.some(({seq:e})=>e===s)?s:e.at(-1)?.seq??null,u=(0,H.useCallback)(e=>{c(e),o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]);return e.length===0?(0,K.jsx)(dO,{title:i?`Reading the run…`:`No event matches.`,children:`Only loaded events are filtered. Load older ones to look further.`}):(0,K.jsx)(`ol`,{"aria-label":r,className:HU.list,onKeyDown:e=>{let t=[...e.currentTarget.querySelectorAll(`[data-log-row]`)],n=t.findIndex(t=>t===e.target);if(n===-1)return;let r={ArrowDown:t[n+1],ArrowUp:t[n-1],Home:t[0],End:t.at(-1)};if(!(e.key in r))return;e.preventDefault();let i=r[e.key];i!==void 0&&(c(Number(i.dataset.logRow)),i.focus())},onScroll:n,ref:t,children:e.map(e=>(0,K.jsx)(aW,{onToggle:u,open:a.has(e.seq),stored:e,tabbable:e.seq===l},e.seq))})},sW=({events:e,shown:t,feed:n,cli:r,live:i=!0})=>{let a=e.events.length,o=e.latest-AH(e);return(0,K.jsxs)(`div`,{className:HU.status,children:[(0,K.jsx)(`span`,{className:HU.counts,children:LL(t,a,e.latest)}),(0,K.jsx)(Y,{disabled:!jH(e)||e.paging,focusableWhenDisabled:!0,onClick:()=>{n.loadOlder()},variant:`ghost`,children:`Load older`}),(0,K.jsxs)(Y,{"aria-pressed":e.following&&i,cli:r,onClick:()=>{e.following?n.hold():n.follow()},variant:`ghost`,children:[e.following&&i?(0,K.jsx)(cy,{}):null,`Follow`,o>0?` (${String(o)} new)`:``]})]})},cW=({error:e})=>(0,K.jsx)(`p`,{className:HU.error,role:`alert`,children:(0,K.jsx)(J,{text:e})}),lW=32,uW=e=>e.scrollHeight-e.scrollTop-e.clientHeight<lW,dW=(e,t)=>{let n=(0,H.useRef)(null),{following:r}=t,i=t.events[0]?.seq,a=(0,H.useRef)({firstSeq:i,height:0});return(0,H.useLayoutEffect)(()=>{let e=n.current;e!==null&&(r?e.scrollTop=e.scrollHeight:a.current.firstSeq!==i&&a.current.height>0&&(e.scrollTop+=e.scrollHeight-a.current.height),a.current={firstSeq:i,height:e.scrollHeight})}),(0,H.useEffect)(()=>{let t=n.current,r=new ResizeObserver(()=>{t!==null&&e.state.getValue().following&&(t.scrollTop=t.scrollHeight)});return t!==null&&r.observe(t),()=>{r.disconnect()}}),{listRef:n,onScroll:()=>{let t=n.current;if(t===null)return;let r=uW(t),i=e.state.getValue();i.following&&!r?e.hold():!i.following&&r&&!MH(i)&&e.follow()}}},fW=500,pW=({runId:e,node:t})=>{let n=sb(),r=(0,H.useMemo)(()=>n.feedOf(e),[n,e]);(0,H.useEffect)(()=>n.retainRun(e),[n,e]);let i=yb(r.state),a=vb(n.runs,t=>{let n=t?.find(t=>t.id===e)?.live;return n===void 0||n===`running`||n===`paused`}),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(``),u=(0,H.useMemo)(()=>ML(i.events,{node:t,type:o,text:c}),[i.events,t,o,c]),{listRef:d,onScroll:f}=dW(r,i),p=(0,H.use)(wU),m=JSON.stringify([t,o,c]),h=(0,H.useRef)(m),g=LL(u.length,i.events.length,i.latest);return(0,H.useEffect)(()=>{let e=setTimeout(()=>{m!==h.current&&(h.current=m,p?.announce(g))},fW);return()=>{clearTimeout(e)}},[m,g,p]),(0,K.jsxs)(`div`,{className:HU.panel,children:[(0,K.jsx)(WU,{events:i.events,node:t,onNode:n.selectNode,onText:l,onType:s,text:c,type:o}),(0,K.jsxs)(`div`,{className:HU.main,children:[(0,K.jsx)(sW,{cli:RL(e,t,a),events:i,feed:r,live:a,shown:u.length}),i.error===null?null:(0,K.jsx)(cW,{error:i.error}),(0,K.jsx)(oW,{label:`Events of run ${e}`,listRef:d,onScroll:f,reading:i.link===`loading`&&i.events.length===0,shown:u})]})]})},mW=()=>{let{run:e,node:t}=yb(sb().selection);return e===null?(0,K.jsx)(dO,{cli:`ork logs <run>`,title:`No run chosen.`,children:`Choose one in the Runs panel, or in a terminal:`}):(0,K.jsx)(pW,{node:t,runId:e},e)},hW={monitor:`_monitor_11biq_8`,header:`_header_11biq_25`,stats:`_stats_11biq_43`,stat:`_stat_11biq_43`,statName:`_statName_11biq_58`,statValue:`_statValue_11biq_74`,title:`_title_11biq_90`,runId:`_runId_11biq_101`,controls:`_controls_11biq_111`,error:`_error_11biq_119`,canvas:`_canvas_11biq_133`,table:`_table_11biq_144`,tableHead:`_tableHead_11biq_162`,tree:`_tree_11biq_185`,tableFold:`_tableFold_11biq_197`,treeRow:`_treeRow_11biq_225`,treeNode:`_treeNode_11biq_268`,treeToggle:`_treeToggle_11biq_274`,treeId:`_treeId_11biq_294`,treeLabel:`_treeLabel_11biq_307`,treeType:`_treeType_11biq_324`,treeStatus:`_treeStatus_11biq_340`,treeNow:`_treeNow_11biq_346`,treeTime:`_treeTime_11biq_356`,treeCost:`_treeCost_11biq_369`,sideTitle:`_sideTitle_11biq_392`,sideLabel:`_sideLabel_11biq_401`,node:`_node_11biq_414`,nodeFacts:`_nodeFacts_11biq_430`,watching:`_watching_11biq_431`,end:`_end_11biq_441`,links:`_links_11biq_484`,linkList:`_linkList_11biq_499`,link:`_link_11biq_484`,linkEnds:`_linkEnds_11biq_519`,linkCount:`_linkCount_11biq_530`},gW=({error:e})=>(0,K.jsx)(`p`,{className:hW.error,role:`alert`,children:(0,K.jsx)(J,{text:e})}),_W=({runId:e,layout:t,...n})=>(0,K.jsx)(`div`,{className:hW.canvas,children:t===null?(0,K.jsx)(dO,{cli:`ork tree ${e}`,title:`Reading the run…`,children:`For now:`}):(0,K.jsx)(RN,{...n,layout:t,live:!0})}),vW=e=>{let t=e.template===void 0?void 0:/\.(\d+)$/u.exec(e.id)?.[1];return t===void 0?void 0:Number(t)},yW=e=>{let t=e.children.filter(e=>vW(e)!==void 0).toSorted((e,t)=>(vW(e)??0)-(vW(t)??0));return[...e.children.filter(e=>!t.includes(e)),...t]},bW=(e,t=new Set)=>{let n=(e,r,i)=>e.flatMap(e=>[{node:e,depth:r,parent:i},...t.has(e.id)?[]:n(yW(e),r+1,e.id)]);return n(e,1)},xW={waiting:`queued`,running:`running`,ok:`succeeded`,failed:`failed`,skipped:`skipped`},SW={waiting:`skipped`,running:`interrupted`},CW=(e,t,n=!1)=>{let r=n?SW[e.state]:void 0;return r===void 0?e.held===!0?`paused`:t?`waiting`:xW[e.state]:r},wW=(e,t)=>new Set((e??[]).filter(e=>e.runId===t).map(e=>e.node)),TW=18,EW=(e,t,n)=>{let r=n===0?``:`, ${String(n)} failed`,i=`${String(e)} of ${String(t)}${r}`;return i.length>TW?`${String(e)}/${String(t)}${r}`:i},DW=e=>{let{listed:t}=e;if(t===void 0)return;let n=e.children.filter(e=>(vW(e)??1/0)<t);return EW(n.filter(e=>[`ok`,`failed`,`skipped`].includes(e.state)).length,t,n.filter(e=>e.state===`failed`).length)},OW=(e,t,n,r=!1)=>new Map(bW(e).map(({node:e})=>{let i=e.inputTokens+e.outputTokens+(e.cacheWriteTokens??0);return[e.id,{status:CW(e,t.has(e.id),r),model:e.model,tokens:i===0?void 0:i,unpriced:e.unpriced===!0||void 0,costUsd:e.costUsd===0?void 0:e.costUsd,progress:DW(e),cli:`ork logs ${n} --node ${e.id}`,description:e.description??``}]})),kW=(e,t)=>({run:e,nodes:new Map([...t].map(([e,{status:t}])=>[e,t]))}),AW=new Set([`failed`,`paused`]),jW=(e,t,n)=>[...n.run===t.run||n.run!==`running`?[]:[`Run ${e} ${cM(n.run)}.`],...[...n.nodes].filter(([e,r])=>r!==t.nodes.get(e)&&AW.has(r)&&(r!==`paused`||n.run!==`paused`)).map(([e,t])=>`${e} ${cM(t)}.`)],MW=({live:e},t)=>e===`running`&&t?`waiting`:e,NW=(e,t)=>{let n=new Set(e.nodes.map(e=>e.id)),r=bW(t).map(({node:e})=>e).filter(e=>!n.has(e.id)&&vW(e)===void 0).map(({id:e,type:t,parent:n})=>({id:e,type:t,parent:n}));return{...e,nodes:[...e.nodes,...r]}},PW={enabled:!0},FW=e=>({enabled:!1,why:e}),IW=({live:e})=>e===`running`||e===`paused`,LW=e=>e.id.startsWith(`node-`)?FW(`it ran one node; run that node again instead`):PW,RW=e=>{if(!IW(e)){let t=`the run has ended (${e.live})`,n={pause:FW(t),proceed:FW(t),stop:FW(t)};return e.live===`succeeded`?n:{...n,resume:LW(e)}}let t=e.live===`paused`;return{pause:t?FW(`the run is paused`):PW,proceed:t?PW:FW(`the run is not paused`),stop:PW}},zW=(e,t)=>{if(!IW(e)){let t=`the run has ended (${e.live})`;return{pause:FW(t),proceed:FW(t),stop:FW(t)}}if(t.state!==`running`&&t.state!==`waiting`){let e=`${t.id} has finished`;return{pause:FW(e),proceed:FW(e),stop:FW(e)}}let n=t.held===!0||e.paused.nodes.includes(t.id),r=t.state===`running`?PW:FW(`${t.id} is not running`);if(e.live===`paused`){let e=`the whole run is paused; continue the run`;return{pause:FW(e),proceed:FW(e),stop:r}}return{pause:n?FW(`${t.id} is paused`):PW,proceed:n?PW:FW(`${t.id} is not paused`),stop:r}},BW=e=>e.state===`waiting`||e.state===`skipped`?FW(`it hasn't run`):PW,VW={reason:`_reason_sb9l9_7`},HW={panel:`_panel_pl332_9`,tools:`_tools_pl332_28`,card:`_card_pl332_29`,body:`_body_pl332_57`,count:`_count_pl332_73`,updating:`_updating_pl332_74`,list:`_list_pl332_84`,row:`_row_pl332_95`,rowTop:`_rowTop_pl332_136`,rowTitle:`_rowTitle_pl332_146`,rowMeta:`_rowMeta_pl332_160`,high:`_high_pl332_177`,detail:`_detail_pl332_185`,head:`_head_pl332_194`,title:`_title_pl332_203`,facts:`_facts_pl332_216`,fact:`_fact_pl332_216`,factName:`_factName_pl332_233`,caption:`_caption_pl332_234`,factValue:`_factValue_pl332_251`,actions:`_actions_pl332_266`,line:`_line_pl332_267`,note:`_note_pl332_276`,message:`_message_pl332_277`,lineIcon:`_lineIcon_pl332_287`,alert:`_alert_pl332_296`,section:`_section_pl332_314`,records:`_records_pl332_327`,record:`_record_pl332_327`,recordMeta:`_recordMeta_pl332_350`,recordTitle:`_recordTitle_pl332_368`,recordBody:`_recordBody_pl332_378`,evidence:`_evidence_pl332_387`,form:`_form_pl332_397`,pair:`_pair_pl332_405`,place:`_place_pl332_413`,wellHead:`_wellHead_pl332_423`,wellCopy:`_wellCopy_pl332_432`,preview:`_preview_pl332_440`,link:`_link_pl332_487`,result:`_result_pl332_498`,dialogFoot:`_dialogFoot_pl332_507`},UW=`Meta+Enter Control+Enter`,WW=({onSend:e,children:t})=>(0,K.jsx)(`form`,{className:HW.form,onKeyDown:t=>{t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e())},onSubmit:t=>{t.preventDefault(),e()},children:t}),GW=({why:e,id:t})=>(0,K.jsx)(`output`,{className:VW.reason,id:t,children:(0,K.jsx)(J,{text:e??``})}),KW=({text:e})=>e===null?null:(0,K.jsx)(`p`,{className:HW.alert,role:`alert`,children:(0,K.jsx)(J,{text:e})}),qW=[`friction`,`bug`,`context-gap`,`skill`,`workflow`,`idea`],JW=[`low`,`medium`,`high`],YW=[{value:``,label:`No rating`},{value:`good`,label:`good`},{value:`bad`,label:`bad`}],XW={text:``,rating:``,kind:`friction`,severity:null},ZW=({rating:e,severity:t})=>t??(e===`bad`?`high`:`medium`),QW=e=>e.severity===null&&e.rating===`bad`,$W=e=>e.text.trim()===``?`Write the note first.`:null,eG=(e,t)=>({text:t.text,...e===void 0?{}:{node:e},kind:t.kind,severity:ZW(t),...t.rating===``?{}:{rating:t.rating}}),tG=(e,t,n)=>{let r=ZW({...n,severity:null}),i=ZW(n);return[`ork feedback note`,e,...t===void 0?[]:[Yk(t)],`-m`,n.text.trim()===``?`<text>`:Yk(n.text),...n.kind===`friction`?[]:[`--kind ${n.kind}`],...i===r?[]:[`--severity ${i}`],...n.rating===``?[]:[`--rating ${n.rating}`]].join(` `)},nG=(e,t,n)=>({title:t===void 0?`Noted on run \`${e}\``:`Noted on \`${t}\``,description:`It joined item \`${n.slice(0,12)}\`.`}),rG=e=>e.map(e=>({value:e,label:e})),iG=({runId:e,node:t,onSend:n,onDone:r})=>{let[i,a]=(0,H.useState)(XW),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),u=(0,H.useId)(),d=(0,H.useId)(),f=$W(i),p=e=>{a(t=>({...t,...e}))},m=async()=>{if(f!==null||o)return;s(!0),l(null);let e=await n(eG(t,i));s(!1),l(e),e===null&&r()};return(0,K.jsxs)(WW,{onSend:()=>{m()},children:[(0,K.jsx)(jk,{description:`Its first line is the title.`,label:`Note`,multiline:!0,onChange:e=>{p({text:e})},required:!0,value:i.text}),(0,K.jsx)(Ok,{label:`Rating`,onChange:e=>{p({rating:e})},options:YW,value:i.rating}),(0,K.jsx)(Ok,{label:`Kind`,onChange:e=>{p({kind:e})},options:rG(qW),value:i.kind}),(0,K.jsx)(Ok,{label:`Severity`,onChange:e=>{p({severity:e})},describedBy:d,options:rG(JW),value:ZW(i)}),(0,K.jsx)(GW,{id:d,why:QW(i)?`Severity: high, from the bad rating.`:null}),(0,K.jsx)(lC,{command:tG(e,t,i)}),(0,K.jsx)(GW,{id:u,why:f}),(0,K.jsx)(KW,{text:c}),(0,K.jsxs)(FC,{children:[(0,K.jsx)(Y,{disabled:o,onClick:r,type:`button`,variant:`ghost`,children:`Cancel`}),(0,K.jsx)(Y,{"aria-describedby":u,"aria-keyshortcuts":UW,disabled:f!==null||o,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:o?`Adding…`:`Add note`})]})]})},aG={enabled:!0},oG=({runId:e,node:t,check:n=aG,onSend:r})=>{let[i,a]=(0,H.useState)(!1),o=t??`run ${e}`,s=n.enabled?`Note on ${o}`:`Note on ${o}: ${n.why}`,c=`ork feedback note ${e}${t===void 0?``:` ${t}`} -m <text>`,l=()=>{a(!0)};return(0,K.jsxs)(K.Fragment,{children:[t===void 0?(0,K.jsx)(Sb,{cli:c,label:s,onClick:l,children:(0,K.jsx)(Py,{})}):(0,K.jsxs)(Y,{"aria-label":s,cli:c,disabled:!n.enabled,focusableWhenDisabled:!0,onClick:l,tip:n.enabled?void 0:s,children:[(0,K.jsx)(Py,{}),`Note…`]}),(0,K.jsx)(PC,{description:`It joins run ${e}'s feedback as yours, and groups into an item like any record.`,onOpenChange:a,open:i,title:t===void 0?`Note on run \`${e}\``:`Note on \`${t}\``,children:(0,K.jsx)(iG,{node:t,onDone:()=>{a(!1)},onSend:r,runId:e})})]})},sG={enabled:!0},cG=(e,t,n)=>n.enabled?`${e} ${t}`:`${e} ${t}: ${n.why}`,lG=`It goes on in the background with the inputs and flags it started with. Nodes that finished keep their results and don't run again; the one that failed or was cut off runs again, and so does everything after it. It's a paid run, like any you start.`,uG=({runId:e,action:t})=>{let n=sb(),[r,i]=(0,H.useState)(!1),a=(0,H.useRef)(!1),o=`ork resume ${e} --detach`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(Y,{"aria-label":cG(`Resume`,`run`,t),cli:o,disabled:!t.enabled,focusableWhenDisabled:!0,onClick:()=>{i(!0)},tip:t.enabled?void 0:t.why,variant:`ghost`,children:[(0,K.jsx)(eb,{}),`Resume…`]}),(0,K.jsx)(IC,{cli:o,confirm:`Resume run`,description:lG,finalFocus:()=>{let t=a.current;return a.current=!1,(t?document.querySelector(`[data-run-heading="${e}"]`):null)??!0},onConfirm:async()=>{let t=await n.client.call(`resume`,{params:{id:e},body:{}});return a.current=t.ok,t.ok?null:`Could not resume the run: ${t.error}`},onOpenChange:i,open:r,pending:`Resuming…`,title:`Resume run ${e}?`,variant:`primary`})]})},dG=({runId:e,node:t,actions:n,note:r=sG})=>{let i=sb(),[a,o]=(0,H.useState)(!1),s=t??`run`,c=t===void 0?``:` --node ${t}`,l=n=>{i.control(n,e,t).then(e=>(e.ok||nb.add({title:`Could not ${n} ${s}`,description:e.error}),e))},u=(0,K.jsx)(oG,{check:r,node:t,onSend:async n=>{let r=await i.client.call(`note`,{params:{id:e},body:n});return r.ok?(nb.add(nG(e,t,r.data.item)),null):`Could not add the note: ${r.error}`},runId:e});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-label":t===void 0?`Run controls`:`Controls for ${t}`,className:hW.controls,role:`group`,children:[(0,K.jsx)(Sb,{cli:`ork pause ${e}${c}`,disabled:!n.pause.enabled,focusableWhenDisabled:!0,label:cG(`Pause`,s,n.pause),onClick:()=>{l(`pause`)},children:(0,K.jsx)(ay,{})}),(0,K.jsx)(Sb,{cli:`ork continue ${e}${c}`,disabled:!n.proceed.enabled,focusableWhenDisabled:!0,label:cG(`Continue`,s,n.proceed),onClick:()=>{l(`continue`)},children:(0,K.jsx)(iy,{})}),(0,K.jsx)(Sb,{cli:`ork stop ${e}${c}`,disabled:!n.stop.enabled,focusableWhenDisabled:!0,label:cG(`Stop`,s,n.stop),onClick:()=>{o(!0)},children:(0,K.jsx)(oy,{})}),(0,K.jsx)(IC,{cli:`ork stop ${e}${c}`,confirm:t===void 0?`Stop run`:`Stop ${t}`,description:t===void 0?`Running nodes are interrupted, and runs it called stop too. It can be resumed later, from here or a terminal.`:`Its session is interrupted and \`${t}\` fails with \`stopped by the user\`. The workflow's failure rules then apply.`,onConfirm:()=>{o(!1),l(`stop`)},onOpenChange:o,open:a,title:t===void 0?`Stop run ${e}?`:`Stop ${t}?`}),n.resume===void 0?null:(0,K.jsx)(uG,{action:n.resume,runId:e}),t===void 0?u:null]}),t===void 0?null:u]})},fG={s:1e3,m:6e4,h:36e5},pG=e=>{let t=/^(\d+)([smh])$/u.exec(e);return Number(t?.[1]??0)*(fG[t?.[2]??`s`]??1e3)},mG=e=>{let t=Math.ceil(e/1e3);if(t<60)return`${String(t)} s`;let n=Math.ceil(t/60);return n<60?`${String(n)} min`:`${String(Math.ceil(n/60))} h`},hG=e=>e===`running`||e===`paused`,gG=(e,t)=>{let n=pG(e.every),r=Math.max(0,t-Date.parse(e.at)),i=n===0?0:Math.floor(r/n),a=e.looks+i;return{until:e.until,every:`every ${e.every}`,looks:`${i===0?``:`about `}${String(a)}`,next:`in about ${mG(n===0?0:n-r%n)}`,said:e.said}},_G=5e3,vG=({watching:e})=>{let[t,n]=(0,H.useState)(Date.now);(0,H.useEffect)(()=>{let e=setInterval(()=>{n(Date.now())},_G);return()=>{clearInterval(e)}},[]);let r=gG(e,t);return(0,K.jsxs)(`dl`,{className:hW.watching,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Waiting until`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{children:r.until})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Looks`}),(0,K.jsxs)(`dd`,{children:[r.looks,`, `,r.every]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Next look`}),(0,K.jsx)(`dd`,{children:r.next})]}),r.said===void 0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Last said`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{children:r.said})})]})]})},yG=({run:e,node:t,progress:n,sectionRef:r,onLeave:i,onOpenRun:a})=>{let{calledRun:o}=t,s=vW(t);return(0,K.jsxs)(`section`,{"aria-label":`Node ${t.id}`,className:hW.node,onKeyDown:e=>{let t=document.querySelector(`[data-modal]`)!==null;e.key===`Escape`&&!t&&i()},ref:r,children:[(0,K.jsx)(`h3`,{className:hW.sideTitle,children:t.id}),t.description===void 0||t.description===``?null:(0,K.jsx)(`p`,{className:hW.sideLabel,children:t.description}),(0,K.jsxs)(`dl`,{className:hW.nodeFacts,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Type`}),(0,K.jsx)(`dd`,{children:yM(t.type)})]}),n===void 0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Items`}),(0,K.jsx)(`dd`,{children:n})]}),s===void 0||t.template===void 0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Item`}),(0,K.jsxs)(`dd`,{children:[`of `,(0,K.jsx)(`code`,{children:t.template}),`, index `,s]})]}),s===void 0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Logs`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`code`,{children:`ork logs ${e.id} --node ${t.id}`})})]}),t.model===void 0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Model`}),(0,K.jsx)(`dd`,{children:t.model})]}),t.inputTokens+t.outputTokens===0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{children:`Tokens`}),(0,K.jsxs)(`dd`,{children:[SM(t.inputTokens),` in ·`,` `,SM(t.outputTokens),` out`]})]})]}),t.end===void 0||t.end.actor===null?null:(0,K.jsx)(`div`,{className:hW.end,children:(0,K.jsx)(iW,{end:t.end,node:t.id,runId:e.id},t.id)}),(0,K.jsx)(dG,{actions:zW(e,t),node:t.id,note:BW(t),runId:e.id}),t.watching===void 0||!hG(e.status)?null:(0,K.jsx)(vG,{watching:t.watching}),o===void 0?null:(0,K.jsxs)(Y,{onClick:()=>{a(o)},variant:`ghost`,children:[`Open run `,o]})]})},bG=()=>{let e=new Map;return{get length(){return e.size},clear:()=>{e.clear()},getItem:t=>e.get(t)??null,key:t=>[...e.keys()][t]??null,removeItem:t=>{e.delete(t)},setItem:(t,n)=>{e.set(t,n)}}},xG=()=>{try{return window.localStorage}catch{return bG()}},SG=({open:e})=>e?(0,K.jsx)(ly,{}):(0,K.jsx)(uy,{}),CG=`ork.monitor.nodesFolded`,wG=()=>{try{return xG().getItem(CG)===`1`}catch{return!1}},TG=()=>{let[e,t]=(0,H.useState)(wG);return[e,()=>{try{xG().setItem(CG,e?`0`:`1`)}catch{}t(!e)}]},EG=({folded:e,onToggle:t,treeId:n,count:r})=>(0,K.jsxs)(`div`,{className:hW.tableHead,children:[(0,K.jsxs)(`button`,{"aria-controls":n,"aria-expanded":!e,className:hW.tableFold,onClick:t,title:e?`Show the nodes table`:`Fold the nodes table away`,type:`button`,children:[(0,K.jsx)(SG,{open:!e}),(0,K.jsx)(`span`,{children:e?`Nodes (${String(r)})`:`Node`})]}),e?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:hW.treeType,children:`Type`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`Status`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`Now`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:hW.treeTime,children:`Time`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,className:hW.treeCost,children:`Cost`})]})]}),DG=new Set([`succeeded`,`failed`,`skipped`,`interrupted`]),OG=e=>e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`,kG=(e,t,n)=>{let r=t.filter(({to:t,from:r})=>{let i=t===e?n(r):void 0;return t===e&&(i===void 0||!DG.has(i))}).map(({from:e})=>e);return r.length===0?``:`After ${OG([...new Set(r)])}`},AG=e=>`${e.charAt(0).toUpperCase()}${e.slice(1)}`,jG=(e,t,n,r,i,a)=>{if(a!==void 0){let n=t===`failed`?e.now??``:``;return n===``?a:`${a} · ${n}`}if(t===`queued`)return kG(e.id,n,r);if(e.watching!==void 0&&!DG.has(t)){let{looks:t,next:n}=gG(e.watching,i);return AG(`${t} ${t===`1`?`look`:`looks`}, next ${n}`)}return e.now??``},MG=({startedAt:e,finishedAt:t},n,r)=>{if(e===void 0)return`–`;let i=t??n;return EM((i===void 0?r:Date.parse(i))-Date.parse(e))},NG=e=>{let t=[...e];return`${String(t.filter(e=>DG.has(e)).length)} / ${String(t.length)}`},PG=({skipped:e=0,failuresHandled:t=0})=>{let n=[...e===0?[]:[`${String(e)} skipped`],...t===0?[]:[`${String(t)} ${t===1?`failure`:`failures`} handled`]];return n.length===0?null:n.join(` · `)},FG={status:`queued`},IG=({roots:e,facts:t,connections:n,selected:r,edges:i,hovered:a,now:o,runFinishedAt:s,onHover:c,onSelect:l,onNodeMenu:u})=>{let[d,f]=(0,H.useState)(new Set),[p,m]=TG(),h=(0,H.useId)(),[g,_]=(0,H.useState)(r),[v,y]=(0,H.useState)(r);r!==v&&(y(r),r!==null&&_(r));let b=(0,H.useMemo)(()=>bW(e,d),[e,d]),x=b.some(({node:e})=>e.id===g)?g:b[0]?.node.id??null,S=(e,t)=>{let n=new Set(d);t?n.delete(e):n.add(e),f(n)},C=(e,t)=>{_(t),[...e.currentTarget.parentElement?.querySelectorAll(`[data-tree-row]`)??[]].find(e=>e.dataset.treeRow===t)?.focus()},w=(e,t)=>{let n=b[t];if(n===void 0)return;let{node:r,parent:i}=n,a=r.children.length>0,o=a&&!d.has(r.id),s={ArrowDown:()=>{let n=b[t+1];n!==void 0&&C(e,n.node.id)},ArrowUp:()=>{let n=b[t-1];n!==void 0&&C(e,n.node.id)},ArrowRight:()=>{a&&(o?C(e,yW(r)[0]?.id??r.id):S(r.id,!0))},ArrowLeft:()=>{o?S(r.id,!1):i!==void 0&&C(e,i)},Home:()=>{C(e,b[0]?.node.id??r.id)},End:()=>{C(e,b.at(-1)?.node.id??r.id)},Enter:()=>{l(r.id)}," ":()=>{l(r.id)},ContextMenu:()=>{u(r.id)}}[e.key===`F10`&&e.shiftKey?`ContextMenu`:e.key];s!==void 0&&(e.preventDefault(),s())},T=e=>t.get(e)?.status,E=b.some(({node:e})=>e.children.length>0);return(0,K.jsxs)(`div`,{className:hW.table,"data-folded":p?``:void 0,children:[(0,K.jsx)(EG,{count:b.length,folded:p,onToggle:m,treeId:h}),(0,K.jsx)(`div`,{"aria-label":`Ownership tree`,className:hW.tree,hidden:p,id:h,role:`tree`,children:b.map(({node:e,depth:f},p)=>{let m=t.get(e.id)??FG,h=e.children.length>0,g=h&&!d.has(e.id),v=jG(e,m.status,i,T,o,m.progress);return(0,H.createElement)(`div`,{...c_(vW(e)===void 0?void 0:m.cli,n.get(e.id)),"aria-expanded":h?g:void 0,"aria-label":[DM(e.id,e.type,{...m,progress:void 0,description:e.description}),...v===``?[]:[v]].join(`, `),"aria-level":f,"aria-selected":e.id===r,className:hW.treeRow,"data-dim":a!==null&&a!==e.id?``:void 0,"data-selected":e.id===r?``:void 0,"data-tree-row":e.id,key:e.id,onClick:()=>{_(e.id),l(e.id)},onContextMenu:t=>{t.preventDefault(),u(e.id)},onKeyDown:e=>{w(e,p)},onMouseEnter:()=>{c(e.id)},onMouseLeave:()=>{c(null)},role:`treeitem`,tabIndex:e.id===x?0:-1},(0,K.jsxs)(`span`,{className:hW.treeNode,style:{paddingInlineStart:`${String((f-1)*.75)}rem`},children:[E?(0,K.jsx)(`span`,{"aria-hidden":`true`,className:hW.treeToggle,onClick:h?t=>{t.stopPropagation(),S(e.id,!g)}:void 0,children:h?(0,K.jsx)(SG,{open:g}):null}):null,(0,K.jsx)(`span`,{className:hW.treeId,children:e.id}),e.description===void 0||e.description===``?null:(0,K.jsx)(l_,{label:e.description,children:(0,K.jsx)(`span`,{className:hW.treeLabel,children:e.description})})]}),(0,K.jsx)(`span`,{className:hW.treeType,children:e.type}),(0,K.jsx)(`span`,{className:hW.treeStatus,children:(0,K.jsx)(dM,{status:m.status})}),(0,K.jsx)(`span`,{className:hW.treeNow,children:v}),(0,K.jsx)(`span`,{className:hW.treeTime,children:MG(e,s,o)}),(0,K.jsx)(`span`,{className:hW.treeCost,children:m.unpriced===!0&&m.tokens!==void 0?(0,K.jsx)(PM,{count:m.tokens}):m.costUsd===void 0?`–`:xM(m.costUsd)}))})})]})},LG=new Map;function RG(e,t){let n=JSON.stringify({locale:bx(e),options:t}),r=LG.get(n);if(r)return r;let i=new Intl.NumberFormat(e,t);return LG.set(n,i),i}function zG(e,t,n){return e==null?``:RG(t,n).format(e)}var BG=H.createContext(void 0);function VG(){let e=H.useContext(BG);if(e===void 0)throw Error(gc(38));return e}function HG(e,t,n){return(e-t)*100/(n-t)}var UG=H.forwardRef(function(e,t){let{format:n,getAriaValueText:r,locale:i,max:a=100,min:o=0,value:s,render:c,className:l,children:u,style:d,...f}=e,[p,m]=H.useState(),h=HG(s,o,a),g=T_(Number.isNaN(h)?0:h,0,100),_=T_(Number.isNaN(s)?o:s,o,a),v=n?zG(_,i,n):zG(g/100,i,{style:`percent`}),y=v;r&&(y=r(v,s));let b={"aria-labelledby":p,"aria-valuemax":a,"aria-valuemin":o,"aria-valuenow":_,"aria-valuetext":y,role:`meter`,children:(0,K.jsxs)(H.Fragment,{children:[u,(0,K.jsx)(`span`,{role:`presentation`,style:Yu,children:`x`})]})},x=H.useMemo(()=>({formattedValue:v,percentageValue:g,setLabelId:m,value:s}),[v,g,m,s]),S=qf(`div`,e,{ref:t,props:[b,f]});return(0,K.jsx)(BG.Provider,{value:x,children:S})}),WG=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=VG();return qf(`span`,e,{ref:t,props:[{id:Nx(a,s),role:`presentation`},o]})}),GG={meter:`_meter_1pby1_6`,label:`_label_1pby1_15`,value:`_value_1pby1_31`,track:`_track_1pby1_39`,block:`_block_1pby1_47`},KG=.8,qG=20,JG=(e,t,n=qG)=>e>=t?n:e<=0?0:Math.min(Math.max(Math.round(e/t*n),1),n-1),YG=(e,t)=>e>=t?`full`:e>=t*KG?`high`:`normal`,XG=({value:e,max:t,blocks:n=qG})=>{let r=JG(e,t,n);return(0,K.jsx)(`span`,{"aria-hidden":`true`,className:GG.track,"data-level":YG(e,t),children:Array.from({length:n},(e,t)=>(0,K.jsx)(`span`,{className:GG.block,"data-on":t<r?``:void 0},t))})},ZG=({label:e,value:t,max:n,text:r})=>(0,K.jsxs)(UG,{"aria-valuetext":r,className:GG.meter,"data-level":YG(t,n),max:n,value:Math.min(t,n),children:[(0,K.jsx)(WG,{className:GG.label,children:e}),(0,K.jsx)(`span`,{className:GG.value,children:r}),(0,K.jsx)(XG,{max:n,value:t})]}),QG=16,$G=({run:e,facts:t,budgetUsd:n,budgetTokens:r,now:i})=>{let a=PG(e),o=e.tokens===void 0||e.tokens===0?void 0:e.tokens;return(0,K.jsxs)(`dl`,{className:hW.stats,children:[(0,K.jsxs)(`div`,{className:hW.stat,children:[(0,K.jsxs)(`dt`,{className:hW.statName,children:[`Spent`,n===void 0?``:` · cap ${xM(n,[])}`,r===void 0?``:` · cap ${CM(r)} tokens`]}),(0,K.jsxs)(`dd`,{className:hW.statValue,children:[(0,K.jsx)(MM,{focusable:!0,partial:e.partial===!0,text:xM(e.costUsd)}),n===void 0?null:(0,K.jsx)(XG,{blocks:QG,max:n,value:e.costUsd})]}),o===void 0?null:(0,K.jsxs)(`dd`,{className:hW.statValue,children:[(0,K.jsx)(NM,{count:o}),r===void 0?null:(0,K.jsx)(XG,{blocks:QG,max:r,value:o})]})]}),(0,K.jsxs)(`div`,{className:hW.stat,children:[(0,K.jsx)(`dt`,{className:hW.statName,children:`Nodes`}),(0,K.jsxs)(`dd`,{className:hW.statValue,children:[NG([...t.values()].map(({status:e})=>e)),a===null?null:` · ${a}`]})]}),(0,K.jsxs)(`div`,{className:hW.stat,children:[(0,K.jsx)(`dt`,{className:hW.statName,children:`Elapsed`}),(0,K.jsx)(`dd`,{className:hW.statValue,children:EM((e.finishedAt===void 0?i:Date.parse(e.finishedAt))-Date.parse(e.startedAt))})]})]})},eK=({run:e,waiting:t})=>{let n=sb(),r=(0,H.use)(wU),i=yb(n.decisions)?.filter(({runId:t})=>t===e.id).length;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dM,{pill:!0,status:MW(e,t)}),i===void 0||i===0?null:(0,K.jsxs)(Y,{cli:`ork decide ${e.id} --list`,onClick:()=>{n.preferences.update({decisionFilter:{run:e.id}}),r?.goTo(`decisions`)},tip:`Open Decisions, filtered to this run.`,variant:`ghost`,children:[(0,K.jsx)(My,{}),i===1?`1 decision`:`${i} decisions`,` waiting`]})]})},tK=({run:e,waiting:t,facts:n,budgetUsd:r,budgetTokens:i,now:a})=>{let o=sb(),s=(0,H.useRef)(null),{parent:c}=e;return(0,H.useEffect)(()=>{o.takeArrival(e.id)&&s.current?.focus()},[o,e.id]),(0,K.jsxs)(`header`,{className:hW.header,children:[(0,K.jsxs)(`div`,{className:hW.stat,children:[(0,K.jsx)(`span`,{className:hW.statName,children:`Run`}),(0,K.jsxs)(`span`,{className:hW.statValue,children:[(0,K.jsx)(`h2`,{className:hW.title,"data-run-heading":e.id,ref:s,tabIndex:-1,children:e.workflow}),(0,K.jsx)(`code`,{className:hW.runId,children:e.id})]})]}),(0,K.jsx)($G,{budgetTokens:i,budgetUsd:r,facts:n,now:a,run:e}),(0,K.jsx)(eK,{run:e,waiting:t}),c===void 0?null:(0,K.jsxs)(Y,{onClick:()=>{o.arriveAt(c)},variant:`ghost`,children:[`Called by `,c]}),(0,K.jsx)(dG,{actions:RW(e),runId:e.id})]})},nK=({links:e,runId:t,onOpen:n})=>e.length===0?null:(0,K.jsxs)(`section`,{"aria-label":`Links to other runs`,className:hW.links,children:[(0,K.jsx)(`h3`,{className:hW.sideTitle,children:`Links`}),(0,K.jsx)(`ul`,{className:hW.linkList,children:e.map(e=>{let[r,i]=e.a.run===t?[e.a,e.b]:[e.b,e.a];return(0,K.jsxs)(`li`,{className:hW.link,children:[(0,K.jsxs)(`span`,{className:hW.linkEnds,children:[r.node,` ↔ `,i.run,`/`,i.node]}),(0,K.jsxs)(`span`,{className:hW.linkCount,children:[e.messages,`/`,e.maxMessages,e.endedAt===void 0?``:` · ended`]}),(0,K.jsx)(Y,{onClick:()=>{n(i.run)},variant:`ghost`,children:`Open`})]},e.id)})})]}),rK={ends:`_ends_mstds_6`,list:`_list_mstds_21`,row:`_row_mstds_30`,id:`_id_mstds_62`},iK=3,aK=new Set([`failed`,`crashed`,`budget_exhausted`,`quota_exhausted`,`timed_out`,`interrupted`]),oK=({run:e,roots:t,onSelect:n})=>{let[r,i]=(0,H.useState)(!1),a=bW(t).flatMap(({node:e})=>e.end===void 0||e.end.actor===null?[]:[{id:e.id,end:e.end,at:e.finishedAt??``}]).toSorted((e,t)=>e.at.localeCompare(t.at));if(!aK.has(e.live)||a.length===0)return null;let o=a.length-iK;return(0,K.jsxs)(`section`,{"aria-label":`Why the run stopped`,className:rK.ends,children:[(0,K.jsx)(`ul`,{className:rK.list,children:(r?a:a.slice(0,iK)).map(({id:e,end:t})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-label":`Select ${e}: ${t.label}${t.transient?`, may pass`:``}, ${t.message}`,className:rK.row,onClick:()=>{n(e)},type:`button`,children:[(0,K.jsx)(JU,{end:t}),(0,K.jsx)(`span`,{className:rK.id,children:e}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:t.message})})]})},e))}),o<=0?null:(0,K.jsx)(Y,{"aria-expanded":r,onClick:()=>{i(e=>!e)},variant:`ghost`,children:r?`Show fewer`:`Show ${String(o)} more`})]})},sK={read:`none`},cK=e=>e===void 0?sK:{read:`some`,outputs:e},lK=e=>{let{client:t}=sb(),{id:n,live:r}=e,i=r===`running`||r===`paused`?null:`${n} ${r}`,[a,o]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let e=!0;return i!==null&&(async()=>{let r=await t.call(`run`,{params:{id:n}});if(!e||i===null)return;let a=r.ok?cK(r.data.outputs):{read:`refused`,error:r.error};o({key:i,read:a})})(),()=>{e=!1}},[t,n,i]),a!==null&&a.key===i?a.read:sK},uK={outputs:`_outputs_opfy5_7`,heading:`_heading_opfy5_23`,list:`_list_opfy5_41`,entry:`_entry_opfy5_54`,name:`_name_opfy5_62`,muted:`_muted_opfy5_72`,note:`_note_opfy5_78`,error:`_error_opfy5_86`,bar:`_bar_opfy5_94`,copy:`_copy_opfy5_104`},dK=80,fK=({text:e,cut:t})=>!t&&!e.includes(`
104
+ `)&&e.length<=dK,pK=({output:e})=>{let{name:t,text:n,cut:r}=e,i=(0,K.jsxs)(`span`,{className:uK.name,children:[t,r?(0,K.jsx)(`span`,{className:uK.muted,children:` (cut)`}):null]});return n===``?(0,K.jsxs)(`li`,{className:uK.entry,children:[i,(0,K.jsx)(`span`,{className:uK.muted,children:`empty`})]}):fK(e)?(0,K.jsxs)(`li`,{className:uK.entry,children:[(0,K.jsx)(`span`,{className:uK.name,children:t}),(0,K.jsx)(lC,{command:n,label:`Copy ${t}`})]}):(0,K.jsxs)(`li`,{className:uK.entry,children:[(0,K.jsxs)(`div`,{className:uK.bar,children:[i,(0,K.jsx)(`span`,{className:uK.copy,children:(0,K.jsx)(sC,{label:`Copy ${t}`,text:n})})]}),(0,K.jsx)(ZU,{follow:!1,label:`Output ${t}`,text:n})]})},mK=({run:e})=>{let t=(0,H.useId)(),n=lK(e);if(n.read===`none`)return null;let r=`ork logs ${e.id}`;return(0,K.jsxs)(`section`,{"aria-labelledby":t,className:uK.outputs,children:[(0,K.jsx)(`h3`,{className:uK.heading,id:t,children:`Outputs`}),n.read===`refused`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:uK.error,role:`alert`,children:[(0,K.jsx)($j,{}),` Could not read the outputs: `,n.error,`. See them with:`]}),(0,K.jsx)(lC,{command:r})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:uK.list,children:n.outputs.map(e=>(0,K.jsx)(pK,{output:e},e.name))}),n.outputs.some(({cut:e})=>e)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:uK.note,children:`Cut at 20 lines or ${uO.toLocaleString(`en-US`)} characters. The full values:`}),(0,K.jsx)(lC,{command:`${r} --json`})]}):null]})]})},hK=({run:e,roots:t,onSelect:n})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(oK,{onSelect:n,roots:t,run:e}),(0,K.jsx)(mK,{run:e})]}),gK=1e3,_K=e=>{let[t,n]=(0,H.useState)(Date.now);return(0,H.useEffect)(()=>{let t=e?setInterval(()=>{n(Date.now())},gK):void 0;return()=>{clearInterval(t)}},[e]),t},vK=1e3,yK=(e,t)=>{let n=(0,H.use)(wU),r=(0,H.useRef)(null),i=(0,H.useRef)([]),a=(0,H.useRef)(void 0),{id:o,live:s}=e;(0,H.useEffect)(()=>{if(t.size===0)return;let e=kW(s,t),c=r.current===null?[]:jW(o,r.current,e);r.current=e,i.current.push(...c),i.current.length!==0&&a.current===void 0&&(a.current=setTimeout(()=>{a.current=void 0,n?.announce(i.current.splice(0).join(` `))},vK))},[t,o,s,n]),(0,H.useEffect)(()=>()=>{clearTimeout(a.current)},[])},bK=e=>{let t=sb(),n=e.id,r=(0,H.useMemo)(()=>t.watchRun(n),[t,n]);(0,H.useEffect)(()=>{let e=t.retainRun(n),i=r.start();return()=>{i(),e()}},[t,r,n]);let{graph:i,tree:a,links:o,error:s}=yb(r.state),c=yb(t.decisions),{node:l}=yb(t.selection),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useMemo)(()=>a??[],[a]),p=e.live!==`running`&&e.live!==`paused`,m=(0,H.useMemo)(()=>wW(c,n),[c,n]),h=(0,H.useMemo)(()=>OW(f,m,n,p),[f,m,n,p]),g=bW(f).map(({node:e})=>e.id).join(`
105
+ `),_=(0,H.useMemo)(()=>i===null?null:EP(NW(i,f)),[i,g]),v=(0,H.useMemo)(()=>xj(_?.edges??[]),[_]),y=bW(f).find(({node:e})=>e.id===l)?.node,b=y!==void 0&&vW(y)!==void 0?y.template:void 0;yK(e,h);let x=(0,H.useCallback)(e=>{let{activeElement:n}=document;d.current=n instanceof HTMLElement?n:null,t.selectNode(e),requestAnimationFrame(()=>{u.current?.querySelector(`button`)?.focus()})},[t]),S=(0,H.useCallback)(()=>{d.current?.focus({preventScroll:!0}),d.current=null},[]);return{state:t,graph:i,layout:_,facts:h,waiting:m.size>0,connections:v,roots:f,links:o,error:s,selected:l,holding:b,chosen:y,nodeControls:u,openControls:x,closeControls:S}},xK=({run:e})=>{let{state:t,graph:n,layout:r,facts:i,waiting:a,connections:o,roots:s,links:c,error:l,selected:u,holding:d,chosen:f,nodeControls:p,openControls:m,closeControls:h}=bK(e),[g,_]=(0,H.useState)(null),v=_K(e.live===`running`||e.live===`paused`);return(0,K.jsxs)(`div`,{className:hW.monitor,children:[(0,K.jsx)(tK,{budgetTokens:n?.budgetTokens,budgetUsd:n?.budgetUsd,facts:i,now:v,run:e,waiting:a}),l===null?null:(0,K.jsx)(gW,{error:l}),(0,K.jsx)(hK,{onSelect:t.selectNode,roots:s,run:e}),(0,K.jsx)(_W,{facts:i,holding:d,hovered:g,label:`Graph of run ${e.id}, ${e.workflow}`,layout:r,onHover:_,onNodeMenu:m,onSelect:t.selectNode,runId:e.id,selected:u??void 0}),(0,K.jsx)(IG,{connections:o,edges:n?.edges??[],facts:i,hovered:g,now:v,onHover:_,onNodeMenu:m,onSelect:t.selectNode,roots:s,runFinishedAt:e.finishedAt,selected:u}),f===void 0?null:(0,K.jsx)(yG,{node:f,progress:i.get(f.id)?.progress,onLeave:h,onOpenRun:t.arriveAt,run:e,sectionRef:p}),(0,K.jsx)(nK,{links:c,onOpen:t.arriveAt,runId:e.id})]})},SK=()=>{let e=sb(),{run:t}=yb(e.selection),n=yb(e.runs)?.find(({id:e})=>e===t);return n===void 0?(0,K.jsx)(dO,{cli:`ork tree <run>`,title:`No run chosen.`,children:`Choose one in the Runs panel, or in a terminal:`}):(0,K.jsx)(xK,{run:n},n.id)},CK=()=>`Notification`in globalThis,wK=async()=>CK()?await Notification.requestPermission()===`granted`?`granted`:`denied`:`unsupported`,TK=(e,t,n)=>{if(!CK()||Notification.permission!==`granted`||document.visibilityState===`visible`)return;let r=new Notification(`Ork`,{body:e,tag:t});r.addEventListener(`click`,()=>{window.focus(),n(),r.close()})},EK=(e,t)=>e.live===`running`&&t?`waiting`:e.live,DK=e=>{let t=new Date(e),n=t.toDateString()===new Date().toDateString();return t.toLocaleString(void 0,n?{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},OK=({paused:e,live:t})=>{let n=e.nodes.length;return t!==`running`||n===0?null:n===1?`1 node paused`:`${String(n)} nodes paused`},kK=(0,H.memo)(({run:e,selected:t,tabStop:n,waiting:r,onSelect:i})=>{let a=OK(e);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:Mk.row,"data-run-row":e.id,onClick:()=>{i(e.id)},tabIndex:n?0:-1,type:`button`,children:[(0,K.jsxs)(`span`,{className:Mk.rowTop,children:[(0,K.jsx)(`span`,{className:Mk.workflow,children:e.workflow}),(0,K.jsx)(dM,{status:EK(e,r)})]}),(0,K.jsxs)(`span`,{className:Mk.rowMeta,children:[(0,K.jsx)(`span`,{children:e.id}),(0,K.jsx)(`time`,{dateTime:e.startedAt,children:DK(e.startedAt)}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(MM,{partial:e.partial===!0,text:xM(e.costUsd)}),e.tokens===void 0||e.tokens===0?null:(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(NM,{count:e.tokens,unit:`tok`})]})]}),a===null?null:(0,K.jsx)(`span`,{children:a}),e.yolo===!0&&e.live===`running`?(0,K.jsx)(`span`,{className:Mk.yolo,children:`yolo: no permission prompts`}):null]})]})})});kK.displayName=`RunRow`;var AK=({onClick:e})=>(0,K.jsxs)(Y,{cli:`ork run <workflow>`,"data-run-workflow":``,onClick:e,variant:`primary`,children:[(0,K.jsx)(iy,{}),`Run workflow`]}),jK=()=>(0,K.jsx)(dO,{cli:`ork run <workflow>`,title:`No runs yet.`,children:`Start one with Run workflow, or in a terminal:`}),MK={panel:`_panel_1mlu0_7`,tools:`_tools_1mlu0_22`,main:`_main_1mlu0_38`,refused:`_refused_1mlu0_50`,list:`_list_1mlu0_60`,item:`_item_1mlu0_66`,title:`_title_1mlu0_90`,meta:`_meta_1mlu0_103`,unread:`_unread_1mlu0_121`,actions:`_actions_1mlu0_127`},NK=({item:e})=>{let t=sb(),n=(0,H.use)(wU);return(0,K.jsxs)(`li`,{className:MK.item,"data-notification":e.id,"data-unread":e.unread?``:void 0,children:[(0,K.jsx)(`p`,{className:MK.title,children:e.title}),(0,K.jsxs)(`p`,{className:MK.meta,children:[(0,K.jsx)(dM,{status:e.status}),(0,K.jsx)(`span`,{children:DK(e.at)}),e.unread?(0,K.jsx)(`span`,{className:MK.unread,children:`unread`}):null]}),(0,K.jsxs)(`p`,{className:MK.actions,children:[(0,K.jsx)(Y,{"aria-label":`Open: ${e.title}`,onClick:()=>{t.notifications.markRead(e.id),t.selectRun(e.runId),e.node!==void 0&&t.selectNode(e.node),n?.goTo(e.kind===`decision`?`decisions`:`monitor`)},variant:`ghost`,children:`Open`}),(0,K.jsx)(Y,{"aria-label":`Mark read: ${e.title}`,disabled:!e.unread,focusableWhenDisabled:!0,onClick:()=>{t.notifications.markRead(e.id)},variant:`ghost`,children:`Mark read`})]})]})},PK={denied:`The browser refused. Allow notifications for this page in its settings.`,unsupported:`This browser has no desktop notifications.`},FK=()=>{let{notifications:e,preferences:t}=sb(),{items:n,unread:r}=yb(e.view),{desktopNotifications:i}=yb(t.value),[a,o]=(0,H.useState)(null),{panel:s,onFocus:c}=zU(n.map(({id:e})=>e).join(`
106
+ `),`[data-notification]`),l=async e=>{if(o(null),!e){t.update({desktopNotifications:!1});return}let n=await wK();n===`granted`?t.update({desktopNotifications:!0}):o(PK[n])};return(0,K.jsxs)(`div`,{"aria-label":`Notifications`,className:MK.panel,onFocus:c,ref:s,role:`group`,tabIndex:-1,children:[(0,K.jsxs)(`div`,{className:MK.tools,children:[(0,K.jsx)(IO,{checked:i,label:`Desktop notifications`,onChange:e=>{l(e)}}),(0,K.jsx)(Y,{disabled:r===0,focusableWhenDisabled:!0,onClick:e.markAllRead,variant:`ghost`,children:`Mark all read`})]}),(0,K.jsxs)(`div`,{className:MK.main,children:[a===null?null:(0,K.jsx)(`p`,{className:MK.refused,role:`alert`,children:a}),n.length===0?(0,K.jsx)(dO,{title:`Nothing yet.`,children:`Decisions, and runs that end, crash or pause, land here.`}):(0,K.jsx)(`ul`,{className:MK.list,children:n.map(e=>(0,K.jsx)(NK,{item:e},e.id))})]})]})},IK=3e4,LK={live:`Live`,new:`Off: new, not accepted yet`,changed:`Off: changed since it was accepted`,invalid:`Off: it has an error`},RK={new:`ork watch --accept`,changed:`ork watch --accept`,invalid:`ork validate`},zK=e=>new Date(e).toLocaleTimeString(void 0,{timeStyle:`short`}),BK=e=>[LK[e.standing],...e.lookedAt===void 0?[]:[`Last looked ${zK(e.lookedAt)}`],...e.error===void 0?[]:[`Last look failed: ${e.error}`],...e.held===void 0?[]:[`Waiting: ${e.held}`]],VK=()=>{let{triggers:e}=sb(),t=yb(e.state);(0,H.useEffect)(()=>{e.load();let t=setInterval(()=>{e.load()},IK);return()=>{clearInterval(t)}},[e]);let n=lU(t)?.data;return n===void 0||n.triggers.length===0?null:(0,K.jsxs)(`section`,{"aria-label":`Triggers`,className:Mk.triggers,children:[(0,K.jsx)(`h3`,{className:Mk.triggersTitle,children:`Triggers`}),n.pid===void 0?(0,K.jsxs)(`p`,{className:Mk.note,children:[(0,K.jsx)(`code`,{children:`ork watch`}),` isn't running, so nothing is looking.`]}):null,(0,K.jsx)(`ul`,{className:Mk.triggerList,children:n.triggers.map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:Mk.triggerName,children:e.trigger}),` starts `,(0,K.jsx)(`code`,{children:e.run}),`, every ${e.every}`,BK(e).map(e=>(0,K.jsx)(`span`,{className:Mk.triggerLine,children:(0,K.jsx)(J,{text:e})},e)),RK[e.standing]===void 0?null:(0,K.jsx)(`span`,{className:Mk.triggerCommand,children:(0,K.jsx)(lC,{command:RK[e.standing]??``})})]},`${e.project}/${e.trigger}`))})]})},HK=e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r=t.length-1,i={ArrowDown:Math.min(n+1,r),ArrowUp:Math.max(n-1,0),Home:0,End:r}[e.key];i!==void 0&&(e.preventDefault(),t[i]?.focus())},UK=()=>{let e=sb(),t=yb(e.runs),n=yb(e.runFilter),r=vb(e.selection,({run:e})=>e),i=OU(e),a=kU(e),o=MU(e,n),s=(0,H.useMemo)(()=>t??[],[t]),c=(0,H.useMemo)(()=>DU(a,s).filter(e=>e.value!==`all`),[a,s]),l=(0,H.useMemo)(()=>[...new Set(s.map(({workflow:e})=>e))].toSorted((e,t)=>e.localeCompare(t)).map(e=>({value:e,label:e})),[s]),{filtered:u}=o,d=u?o.rows??t:t,f=d??[],p=f.some(({id:e})=>e===r)?r:f[0]?.id;return(0,K.jsxs)(`div`,{className:Mk.panel,children:[(0,K.jsxs)(`div`,{className:Mk.tools,children:[(0,K.jsx)(`div`,{className:Mk.filter,children:(0,K.jsx)(xH,{busy:o.busy,error:o.refused===null?null:{message:o.refused},worked:o.worked,list:`runs`,onChange:t=>{e.runFilter.setValue(t)},shown:o.rows?.length??null,suggestions:{project:c,workflow:l},values:n})}),(0,K.jsx)(AK,{onClick:()=>{e.runDialog.setValue(!0)}})]}),(0,K.jsxs)(`div`,{className:Mk.main,children:[o.failed===null?null:(0,K.jsxs)(`p`,{className:Mk.note,role:`alert`,children:[`Cannot read runs: `,o.failed]}),d===null?(0,K.jsx)(`p`,{className:Mk.note,children:`Reading runs…`}):f.length===0?u&&o.rows!==null?(0,K.jsx)(gH,{list:`runs`,onClear:()=>{e.runFilter.setValue({})},values:n}):(0,K.jsx)(jK,{}):(0,K.jsx)(`ul`,{"aria-label":`Runs`,className:Mk.list,onKeyDown:HK,children:f.map(t=>(0,K.jsx)(kK,{onSelect:e.selectRun,run:t,selected:t.id===r,tabStop:t.id===p,waiting:i.has(t.id)},t.id))})]}),(0,K.jsx)(VK,{})]})},WK=e=>e.toLocaleString(`en`),GK=e=>`≈${WK(e)}`,KK=e=>{let t=e.trim(),n=/^[a-z]+\s/u.test(t)?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:t;return n===``||/[.!?…]$/u.test(n)?n:`${n}.`},qK=e=>e.reduce((e,t)=>e+(t.tokens??0),0),JK=e=>{let t=e.filter(e=>e.state===`live`).length,n=e.length-t;return n===0?`${WK(t)} live`:`${WK(t)} live, ${WK(n)} off`},YK=(e,t,n=0)=>{let r=`${t(e.length)} · ${GK(qK(e))}`;return n===0?r:`${r}, ${WK(n)} off`},XK=e=>`${WK(e)} ${e===1?`file`:`files`}`,ZK=e=>`${WK(e)} live`,QK=e=>{let t=e.agent===void 0?[]:[{key:`agent/${e.agent.name}`,name:e.agent.name,source:e.agent.where,tokens:e.agent.tokens,text:e.agent.text??``,place:e.agent.where}],n=(e.instructionFiles??[]).map(e=>({key:`instructions/${e.name}`,name:e.name,tokens:e.tokens,text:e.text,place:e.name})),r=e.skills.map(e=>({key:`skill/${e.layer}/${e.name}`,name:e.name,state:e.state,layer:e.layer,source:e.source,tokens:e.tokens,...e.why===void 0?{}:{why:e.why},text:e.text??``,place:e.source===`built-in`?`built-in`:`${e.source}/SKILL.md`})),i=e.files.map((e,t)=>({key:`file/${e.layer}/${e.name}/${String(t)}`,name:e.name,layer:e.layer,tokens:e.tokens,text:e.text??``,place:e.name,...e.cutFrom===void 0?{}:{why:`cut at the lessons cap a session loads; the whole file is about ${WK(e.cutFrom)} tokens`}})),a=[...e.practices.map(e=>({key:`practice/${e.name}`,name:e.name,state:`live`,tokens:e.tokens,text:e.text??``,place:`practice: ${e.name}`})),...e.skippedPractices.map(e=>({key:`practice/${e}`,name:e,state:`off`,why:`The project's own skill wins.`}))];return[{id:`agent`,title:`Agent`,meta:GK(qK(t)),empty:`No agent fills this node.`,pieces:t},{id:`instructions`,title:`Project instructions`,meta:GK(qK(n)),description:`Claude Code reads these itself; they aren't appended.`,empty:KK(e.instructions),pieces:n},{id:`skills`,title:`Skills`,meta:r.length===0?`none`:JK(r),description:`A skill's SKILL.md loads only when the session uses it.`,empty:`No skills.`,pieces:r},{id:`files`,title:`Context files`,meta:YK(i,XK),empty:`No context files.`,pieces:i},{id:`practices`,title:`Practices`,meta:YK(a.filter(e=>e.state===`live`),ZK,e.skippedPractices.length),empty:`No practices.`,pieces:a},{id:`appended`,title:`Appended system prompt`,meta:GK(e.appendedTokens),description:"Everything Ork adds to Claude Code's system prompt, in the order the session reads it: the agent's role, the context files and practices above, Ork's own instructions to the node, and the node's `instructions`.",empty:`Nothing is appended.`,pieces:[{key:`appended`,name:`The whole prompt`,tokens:e.appendedTokens,text:e.appended??``,place:`system prompt, appended`}]}]},$K=(e,t)=>t?`Couldn't update: ${KK(e)} This is the answer from before.`:`Couldn't read the context: ${KK(e)}`,eq=e=>e===``?0:e.replace(/\n$/u,``).split(`
107
+ `).length,tq=(e,t)=>{let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)?e.slice(n.length):e},nq=(e,t)=>`ork context explain ${e} ${t}`,rq={host:`_host_tnhom_9`,panel:`_panel_tnhom_17`,header:`_header_tnhom_36`,card:`_card_tnhom_37`,foot:`_foot_tnhom_38`,facts:`_facts_tnhom_54`,fact:`_fact_tnhom_54`,factName:`_factName_tnhom_71`,factValue:`_factValue_tnhom_85`,title:`_title_tnhom_95`,plannedLine:`_plannedLine_tnhom_107`,planned:`_planned_tnhom_107`,description:`_description_tnhom_117`,why:`_why_tnhom_118`,emptyText:`_emptyText_tnhom_119`,updating:`_updating_tnhom_132`,cardTitle:`_cardTitle_tnhom_142`,notice:`_notice_tnhom_151`,noticeIcon:`_noticeIcon_tnhom_174`,noticeWords:`_noticeWords_tnhom_190`,stack:`_stack_tnhom_194`,section:`_section_tnhom_203`,sectionHead:`_sectionHead_tnhom_219`,sectionNote:`_sectionNote_tnhom_230`,heading:`_heading_tnhom_241`,meta:`_meta_tnhom_251`,layer:`_layer_tnhom_252`,source:`_source_tnhom_253`,tokens:`_tokens_tnhom_254`,state:`_state_tnhom_255`,list:`_list_tnhom_266`,item:`_item_tnhom_272`,row:`_row_tnhom_281`,details:`_details_tnhom_318`,toggle:`_toggle_tnhom_341`,mark:`_mark_tnhom_342`,name:`_name_tnhom_365`,visuallyHidden:`_visuallyHidden_tnhom_426`,well:`_well_tnhom_437`,wellBar:`_wellBar_tnhom_449`,wellPlace:`_wellPlace_tnhom_466`,wellCopy:`_wellCopy_tnhom_473`,copied:`_copied_tnhom_482`,text:`_text_tnhom_488`},iq=({text:e})=>e.split(`≈`).map((e,t)=>t===0?e:(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`≈`}),(0,K.jsx)(`span`,{className:rq.visuallyHidden,children:`about `}),e]},t)),aq=({name:e,value:t})=>(0,K.jsxs)(`div`,{className:rq.fact,children:[(0,K.jsx)(`dt`,{className:rq.factName,children:e}),(0,K.jsx)(`dd`,{className:rq.factValue,children:(0,K.jsx)(iq,{text:t})})]}),oq=({node:e,type:t,from:n,appendedTokens:r,planned:i,reload:a,updating:o,cli:s,onReload:c,titleRef:l,children:u})=>(0,K.jsxs)(`header`,{className:rq.header,children:[(0,K.jsxs)(`dl`,{className:rq.facts,children:[(0,K.jsxs)(`div`,{className:rq.fact,children:[(0,K.jsx)(`dt`,{className:rq.factName,children:`Node`}),(0,K.jsx)(`dd`,{className:rq.factValue,children:(0,K.jsx)(`h2`,{className:rq.title,ref:l,tabIndex:-1,children:e})})]}),t===void 0?null:(0,K.jsx)(aq,{name:`Type`,value:t}),(0,K.jsx)(aq,{name:`From`,value:n}),r===void 0?null:(0,K.jsx)(aq,{name:`Appended`,value:`${GK(r)} tokens`})]}),(0,K.jsxs)(`div`,{className:rq.plannedLine,children:[i===null?null:(0,K.jsx)(`p`,{className:rq.planned,children:i}),o?(0,K.jsx)(`span`,{className:rq.updating,children:`Updating…`}):null,(0,K.jsx)(Y,{cli:s,onClick:c,variant:`ghost`,children:a})]}),u]}),sq=e=>`Changed after this run started: ${e.map(e=>`\`${e}\``).join(`, `)}. The run may have read ${e.length===1?`an older version`:`older versions`}.`,cq=({answer:e,error:t})=>{let n=e?.changedSinceStart??[],r=e?.planned===!0?e.explanation:null;return(0,K.jsxs)(K.Fragment,{children:[n.length===0?null:(0,K.jsxs)(`p`,{className:rq.notice,"data-note":`changed`,children:[(0,K.jsx)(`span`,{className:rq.noticeIcon,children:(0,K.jsx)(My,{})}),(0,K.jsx)(`span`,{className:rq.noticeWords,children:(0,K.jsx)(J,{text:sq(n)})})]}),r?.template===void 0?null:(0,K.jsx)(`p`,{className:rq.notice,"data-note":`spawned`,children:(0,K.jsx)(`span`,{className:rq.noticeWords,children:(0,K.jsx)(J,{text:`\`${r.node}\` was spawned during the run, so it's planned as \`${r.template}\`, the node it was spawned from.`})})}),t===null?null:(0,K.jsxs)(`p`,{className:rq.notice,"data-note":`failed`,children:[(0,K.jsx)(`span`,{className:rq.noticeIcon,children:(0,K.jsx)($j,{})}),(0,K.jsx)(`span`,{className:rq.noticeWords,children:(0,K.jsx)(J,{text:$K(t,e!==null)})})]})]})},lq=({why:e})=>(0,K.jsxs)(`div`,{className:rq.card,children:[(0,K.jsx)(`p`,{className:rq.cardTitle,children:`No context to show.`}),(0,K.jsx)(`p`,{className:rq.description,children:(0,K.jsx)(J,{text:KK(e)})})]}),uq=({cli:e,draft:t,sized:n})=>(0,K.jsxs)(`footer`,{className:rq.foot,children:[t?(0,K.jsx)(`p`,{className:rq.description,children:`The CLI reads the saved file, not the draft.`}):null,(0,K.jsx)(lC,{command:e}),n?(0,K.jsx)(`p`,{className:rq.description,children:`Tokens are estimates, about four characters each.`}):null]}),dq=({target:e})=>e?.kind===`run`?(0,K.jsx)(dO,{title:`No node chosen in this run.`,children:`Choose one in the Monitor, Logs or Chats.`}):e?.kind===`builder`?(0,K.jsx)(dO,{title:`No node selected in the Builder.`,children:`Select a card to see what its session loads.`}):(0,K.jsx)(dO,{cli:`ork context explain <workflow> <node>`,title:`No node chosen.`,children:`Choose one in the Monitor or the Builder, or in a terminal:`}),fq=({words:e,more:t})=>{let n=`${e}${t?`, `:``}`;return n===``?null:(0,K.jsx)(`span`,{className:rq.visuallyHidden,children:n})},pq=({piece:e})=>{let t=[e.state,e.layer,e.source,e.tokens],n=e=>t.slice(e).some(e=>e!==void 0),r=e.state!==void 0||e.layer!==void 0||e.source!==void 0;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:rq.mark,"data-state":e.state,children:e.state===void 0?null:e.state===`live`?(0,K.jsx)(cy,{}):(0,K.jsx)(Xy,{})}),(0,K.jsxs)(`span`,{className:rq.name,children:[e.name,(0,K.jsx)(fq,{more:n(0),words:``})]}),r?(0,K.jsxs)(`span`,{className:rq.details,children:[e.state===void 0?null:(0,K.jsxs)(`span`,{className:rq.state,children:[e.state,(0,K.jsx)(fq,{more:n(1),words:``})]}),e.layer===void 0?null:(0,K.jsxs)(`span`,{className:rq.layer,children:[e.layer,(0,K.jsx)(fq,{more:n(2),words:` layer`})]}),e.source===void 0?null:(0,K.jsxs)(`span`,{className:rq.source,children:[e.source,(0,K.jsx)(fq,{more:n(3),words:``})]})]}):null,e.tokens===void 0?null:(0,K.jsxs)(`span`,{className:rq.tokens,children:[(0,K.jsx)(iq,{text:GK(e.tokens)}),(0,K.jsx)(fq,{more:!1,words:` tokens`})]})]})},mq=({piece:e,id:t})=>{let n=e.text??``,r=eq(n);return(0,K.jsxs)(`div`,{className:rq.well,id:t,children:[(0,K.jsxs)(`div`,{className:rq.wellBar,children:[(0,K.jsx)(`span`,{className:rq.wellPlace,children:e.place}),(0,K.jsx)(`span`,{children:(0,K.jsx)(iq,{text:`${r.toLocaleString(`en`)} ${r===1?`line`:`lines`}${e.tokens===void 0?``:` · ${GK(e.tokens)} tokens`}`})}),(0,K.jsx)(`span`,{className:rq.wellCopy,children:(0,K.jsx)(sC,{label:`Copy the text of ${e.name}`,resultClass:rq.copied,text:n})})]}),n===``?(0,K.jsx)(`p`,{className:rq.emptyText,children:e.key===`appended`?`Nothing is appended.`:`This file is empty.`}):(0,K.jsx)(`pre`,{className:rq.text,children:n})]})},hq=({piece:e,open:t,onToggle:n})=>{let r=(0,H.useId)(),i=`${r}-why`,a=`${r}-text`,o=e.state??`live`,s=e.why===void 0?null:(0,K.jsx)(`p`,{className:rq.why,id:i,children:(0,K.jsx)(J,{text:KK(e.why)})});return e.text===void 0?(0,K.jsxs)(`li`,{className:rq.item,children:[(0,K.jsxs)(`div`,{className:rq.row,"data-state":o,children:[(0,K.jsx)(`span`,{className:rq.toggle}),(0,K.jsx)(pq,{piece:e})]}),s]}):(0,K.jsxs)(`li`,{className:rq.item,children:[(0,K.jsxs)(`button`,{"aria-controls":t?a:void 0,"aria-describedby":e.why===void 0?void 0:i,"aria-expanded":t,className:rq.row,"data-piece":e.key,"data-state":o,onClick:()=>{n(e.key)},type:`button`,children:[(0,K.jsx)(`span`,{className:rq.toggle,children:t?(0,K.jsx)(ly,{}):(0,K.jsx)(uy,{})}),(0,K.jsx)(pq,{piece:e})]}),s,t?(0,K.jsx)(mq,{id:a,piece:e}):null]})},gq=({sections:e,opened:t,onToggle:n,busy:r})=>(0,K.jsx)(`div`,{"aria-busy":r,className:rq.stack,children:e.map(e=>(0,K.jsxs)(`section`,{className:rq.section,children:[(0,K.jsxs)(`div`,{className:rq.sectionHead,children:[(0,K.jsx)(`h3`,{className:rq.heading,children:e.title}),(0,K.jsx)(`span`,{className:rq.meta,children:(0,K.jsx)(iq,{text:e.meta})})]}),e.description===void 0?null:(0,K.jsx)(`p`,{className:rq.sectionNote,children:(0,K.jsx)(J,{text:e.description})}),e.pieces.length===0?(0,K.jsx)(`p`,{className:rq.sectionNote,children:(0,K.jsx)(J,{text:e.empty})}):(0,K.jsx)(`ul`,{className:rq.list,children:e.pieces.map(e=>(0,K.jsx)(hq,{onToggle:n,open:t.has(e.key),piece:e},e.key))})]},e.id))}),_q=e=>e.kind===`run`?`run/${e.run}/${e.node}`:`builder/${e.project}/${e.workflow}/${e.node}`,vq={answer:null,error:null,loading:!0},yq=e=>{let{client:t}=sb(),n=(0,H.use)(wU),[r,i]=(0,H.useState)(vq),a=(0,H.useRef)(!1);a.current=r.answer!==null;let[o,s]=(0,H.useState)(0),c=e.kind===`builder`?e.revision:0,l=_q(e);(0,H.useEffect)(()=>{let r=!0;i(e=>({...e,loading:!0}));let o=e.kind===`run`?t.call(`runContext`,{params:{id:e.run,node:e.node}}):t.call(`builderContext`,{params:{id:e.project,name:e.workflow,node:e.node}});return(async()=>{let e=await o;r&&(e.ok||n?.announce($K(e.error,a.current)),i(t=>e.ok?{answer:e.data,error:null,loading:!1}:{answer:t.answer,error:e.error,loading:!1}))})(),()=>{r=!1}},[t,n,l,c,o]);let u=(0,H.useCallback)(()=>{s(e=>e+1)},[]);return{...r,reload:u}},bq=e=>{let t=yb(sb().runs);if(e.kind===`builder`)return{from:`Builder · ${e.workflow}${e.draft?` · draft`:``}`,cli:nq(e.workflow,e.node),planned:e.draft?`Planned from the unsaved draft. It updates after each edit.`:`Planned from the saved file.`};let n=t?.find(({id:t})=>t===e.run);return{from:n===void 0?e.run:`${n.workflow} · ${e.run}`,cli:nq(n===void 0?`<workflow>`:tq(n.file,n.project),e.node),planned:`Planned from the project's files as they are now.`}},xq=({target:e,hadFocus:t})=>{let{answer:n,error:r,loading:i,reload:a}=yq(e),o=bq(e),[s,c]=(0,H.useState)(new Set),l=(0,H.useRef)(null),u=(0,H.useRef)(null),d=(0,H.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),f=n?.planned===!0?n.explanation:null,p=(0,H.useMemo)(()=>f===null?[]:QK(f),[f]),m=n===null?r===null?`loading`:`failed`:`shown`,h=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let e=document.activeElement,n=e!==null&&l.current?.contains(e)===!0,r=(e===null||e===document.body)&&t.current,i=h.current!==m;h.current=m,(r||i&&n)&&u.current?.focus()},[m,n]),(0,K.jsxs)(`div`,{className:rq.panel,ref:l,children:[(0,K.jsx)(oq,{appendedTokens:f?.appendedTokens,cli:o.cli,from:o.from,node:e.node,onReload:a,planned:n?.planned===!1?null:o.planned,reload:r===null?`Reload`:`Try again`,titleRef:u,type:f?.type,updating:i&&n!==null,children:(0,K.jsx)(cq,{answer:n,error:r})}),n?.planned===!1?(0,K.jsx)(lq,{why:n.why}):null,f===null?null:(0,K.jsx)(gq,{busy:i,onToggle:d,opened:s,sections:p}),n===null&&r===null?(0,K.jsx)(`p`,{"aria-busy":`true`,className:rq.card,children:(0,K.jsx)(`span`,{className:rq.description,children:`Planning ${e.node}…`})}):null,m===`loading`?null:(0,K.jsx)(uq,{cli:o.cli,draft:e.kind===`builder`&&e.draft,sized:f!==null})]})},Sq=({target:e,hadFocus:t})=>{let n=(0,H.useRef)(null);return(0,H.useEffect)(()=>{let e=document.activeElement;(e===null||e===document.body)&&t.current&&n.current?.focus()},[t]),(0,K.jsx)(`div`,{ref:n,tabIndex:-1,children:(0,K.jsx)(dq,{target:e})})},Cq=({target:e,hadFocus:t})=>{if(e===null||e.node===null)return(0,K.jsx)(Sq,{hadFocus:t,target:e});let n={...e,node:e.node};return(0,K.jsx)(xq,{hadFocus:t,target:n},_q(n))},wq=()=>{let e=yb(sb().contextTarget),t=(0,H.useRef)(!1);return(0,K.jsx)(`div`,{className:rq.host,onBlur:e=>{let n=e.relatedTarget;(n instanceof Node?!e.currentTarget.contains(n):e.target.isConnected)&&(t.current=!1)},onFocus:()=>{t.current=!0},children:(0,K.jsx)(Cq,{hadFocus:t,target:e})})},Tq=e=>e.slice(0,12),Eq={status:`open`},Dq=[{value:`all`,label:`All`},{value:`ork`,label:`ork`},{value:`workflow`,label:`workflow`},{value:`project`,label:`project`}],Oq=e=>({value:e,label:e}),kq=e=>({workflow:[...new Set(e.flatMap(e=>e.workflows))].toSorted((e,t)=>e.localeCompare(t)).map(e=>Oq(e)),run:[...new Set(e.flatMap(e=>e.runs))].map(e=>Oq(e))}),Aq=(e,t,n)=>e?n===null?`list`:t:`both`,jq=(e,{values:t,about:n})=>e.filter(e=>(t.status!==void 0||e.status!==`dismissed`&&e.status!==`resolved`)&&(n===`all`||e.target===n)),Mq=(e,t,n)=>e===1?`1 ${t}`:`${e.toLocaleString(`en`)} ${n}`,Nq=e=>Mq(e,`item`,`items`),Pq=e=>Mq(e,`time`,`times`),Fq=e=>Mq(e,`run`,`runs`),Iq={open:`No items`,all:`No items`,new:`No new items`,triaged:`No triaged items`,accepted:`No accepted items`,resolved:`Nothing resolved`,published:`Nothing published`,dismissed:`Nothing dismissed`},Lq=({status:e,about:t})=>{let n=Iq[e]??`No items`,r=e===`open`&&t===`all`?`Every item is dismissed or resolved.`:`${n}${t===`all`?``:` about ${t}`}.`,i=[e===`all`?[]:[`Status: All`],t===`all`?[]:[`About: All`]].flat();return{title:r,body:`${i.join(` and `)} ${i.length>1?`show`:`shows`} every item.`}},Rq=(e,t,n)=>{let r=e.findIndex(({id:e})=>e===n),i=t.filter(({id:e})=>e!==n);return i[Math.min(Math.max(r,0),i.length-1)]},zq=(e,t)=>e.find(e=>e.merged.includes(t)),Bq={ok:!1,why:`reading what it allows`},Vq=(e,...t)=>{if(!e.ok)return{ok:!1,why:e.why};let n=t.find(e=>e!==void 0);return n===void 0?{ok:!0}:{ok:!1,why:n}},Hq=e=>{let t=e.lessons,[n]=t;return t.every(e=>!e.ok)&&n!==void 0&&!n.ok?n.error:void 0},Uq=(e,t)=>{let n=Tq(e.id),r=e=>{if(t===null)return Bq;let{actions:n,project:r}=t;return e===`lesson`?Vq(n.lesson,Hq(t)):e===`apply`?Vq(n.apply,r.ok?void 0:r.error):Vq(n[e])},i={key:`accept`,word:`Accept`,cli:`ork feedback accept ${n}`,variant:`default`,check:r(`accept`)};return e.target===`ork`?[i,{key:`publish`,word:`Publish…`,cli:`ork feedback publish ${n}`,variant:`primary`,check:r(`publish`)}]:[i,{key:`lesson`,word:`Add lesson…`,cli:`ork feedback accept ${n} --lesson`,variant:`default`,check:r(`lesson`)},{key:`apply`,word:`Propose fix…`,cli:`ork feedback apply ${n}`,variant:`primary`,check:r(`apply`)}]},Wq=(e,t)=>t.ok?e:`${e}: ${t.why}`,Gq=e=>`Starts a run of \`ork:feedback-apply\` in \`${e}\`. It's a paid run, like any you start. A worker reads this item and that project's records of it, and Ork commits the smallest change that would stop it on a branch of its own, in a worktree. The worker reads and edits files and runs no commands. Then you're asked to keep or discard the branch, in Decisions.`,Kq=({item:e,id:t,root:n,acts:r,open:i,onOpenChange:a})=>{let[o,s]=(0,H.useState)(``),c=(0,H.useRef)(!1);return(0,K.jsx)(IC,{cli:`ork feedback apply ${t}${o===``?``:` --driver ${o}`}`,confirm:`Start run`,description:Gq(n??`its project`),finalFocus:()=>{let e=c.current;return c.current=!1,!e},onConfirm:async()=>{let t=await r.apply(e,o);return c.current=t===null,t},onOpenChange:a,open:i,pending:`Starting…`,title:`Propose a fix for ${t}?`,variant:`primary`,children:(0,K.jsx)(Fk,{onChange:s,value:o})})},qq=(e,t)=>`about ${e.toLocaleString(`en`)} of ${t.toLocaleString(`en`)} tokens`,Jq=(e,t,n)=>[`ork feedback accept ${Tq(e.id)} --lesson`,...t===null||e.workflows.length<2?[]:[`--workflow ${Yk(t)}`],...n===e.title||n.trim()===``?[]:[`-m ${Yk(n)}`]].join(` `),Yq=(e,t,n)=>e===null?`Choose a workflow.`:t.trim()===``?`Write the lesson first.`:n!==void 0&&!n.ok?n.error:null,Xq=({place:e,cap:t})=>e.ok?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:HW.place,children:[(0,K.jsx)(`span`,{className:HW.caption,children:`Goes to `}),(0,K.jsx)(J,{text:`\`${e.file}\` in \`${e.root}\``})]}),(0,K.jsx)(ZG,{label:`Now`,max:t,text:e.exists?qq(e.tokens,t):`no lessons file yet; this starts it`,value:e.tokens})]}):(0,K.jsx)(`p`,{className:HW.note,children:(0,K.jsx)(J,{text:e.error})}),Zq=({open:e,onOpenChange:t,item:n,detail:r,onAdd:i})=>{let a=n.workflows.length>1,[o,s]=(0,H.useState)(a?null:n.workflows[0]??null),[c,l]=(0,H.useState)(n.title),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),m=(0,H.useId)(),h=r.lessons.find(e=>e.workflow===o),g=Yq(o,c,h),_=async()=>{if(g!==null||u)return;d(!0),p(null);let e=await i({lesson:!0,...c===n.title?{}:{text:c},...a&&o!==null?{workflow:o}:{}});d(!1),p(e),e===null&&t(!1)};return(0,K.jsx)(PC,{description:o===null?`Every later session of the workflow you choose reads it, in the workflow layer of its context.`:`Every later session of \`${o}\` reads it, in the workflow layer of its context.`,onOpenChange:e=>{u||t(e)},open:e,title:o===null?`Add a lesson`:`Add a lesson for \`${o}\``,children:(0,K.jsxs)(WW,{onSend:()=>{_()},children:[a?(0,K.jsx)(Ok,{label:`Workflow (required)`,onChange:e=>{s(e===``?null:e)},options:[{value:``,label:`Choose one`},...n.workflows.map(e=>({value:e,label:e}))],value:o??``}):null,(0,K.jsx)(jk,{description:`Its first line is the entry; later lines sit under it.`,label:`Lesson`,multiline:!0,onChange:l,required:!0,value:c}),h===void 0?null:(0,K.jsx)(Xq,{cap:r.lessonCap,place:h}),(0,K.jsx)(lC,{command:Jq(n,o,c)}),(0,K.jsx)(GW,{id:m,why:g}),(0,K.jsx)(KW,{text:f}),(0,K.jsxs)(FC,{children:[(0,K.jsx)(Y,{disabled:u,onClick:()=>{t(!1)},type:`button`,variant:`ghost`,children:`Cancel`}),(0,K.jsx)(Y,{"aria-describedby":m,"aria-keyshortcuts":UW,disabled:g!==null||u,focusableWhenDisabled:!0,type:`submit`,variant:`primary`,children:u?`Adding…`:`Add lesson`})]})]})})},Qq={slot:`_slot_17gek_6`,alert:`_alert_17gek_17`},$q=({id:e,words:t,takeFocus:n,onTryAgain:r})=>{let i=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(t===null)return;let e=document.activeElement,r=e===null||e===document.body||e.getAttribute(`aria-disabled`)===`true`;(n===`always`||r)&&i.current?.querySelector(`button`)?.focus()},[t,n]),(0,K.jsxs)(`div`,{className:Qq.slot,ref:i,children:[(0,K.jsx)(`p`,{className:Qq.alert,id:e,role:`alert`,children:t===null?null:(0,K.jsx)(J,{text:t})}),t===null||r===void 0?null:(0,K.jsx)(Y,{onClick:r,variant:`ghost`,children:`Try again`})]})},eJ=({url:e})=>(0,K.jsxs)(`a`,{className:HW.link,href:e,rel:`noreferrer`,target:`_blank`,children:[e,(0,K.jsx)(Fy,{}),(0,K.jsx)(Dk,{children:` (opens in a new tab)`})]}),tJ=({preview:e})=>e.plan.kind===`create`?(0,K.jsx)(`p`,{className:HW.message,children:(0,K.jsx)(J,{text:`A new thread in the Agent feedback category of \`${e.repo}\`.`})}):(0,K.jsxs)(`p`,{className:HW.message,children:[`A thread for this exists, so this goes on it as a +1 comment:`,` `,(0,K.jsx)(eJ,{url:e.plan.url})]}),nJ="Reading Ork's Discussions with your `gh`…",rJ=`Nothing to show: the preview couldn't be read.`,iJ=({id:e})=>(0,K.jsx)(`span`,{className:HW.note,id:e,children:`From the last read`}),aJ=({preview:e,reading:t,region:n,stale:r,staleId:i})=>{let a=e?.plan.kind!==`comment`,o=e===void 0?``:a?e.post.body:e.post.comment,s=a?`Body`:`Comment`,c=r&&e!==void 0;return(0,K.jsxs)(K.Fragment,{children:[e===void 0||!a?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:HW.line,children:[(0,K.jsx)(`p`,{className:HW.caption,children:`Title`}),c?(0,K.jsx)(iJ,{}):null]}),(0,K.jsx)(`p`,{className:HW.preview,"data-stale":r?``:void 0,children:e.post.title})]}),(0,K.jsxs)(`div`,{className:HW.wellHead,children:[(0,K.jsxs)(`div`,{className:HW.line,children:[(0,K.jsx)(`p`,{className:HW.caption,children:s}),c?(0,K.jsx)(iJ,{id:i}):null]}),o===``?null:(0,K.jsx)(`span`,{className:HW.wellCopy,children:(0,K.jsx)(sC,{label:`Copy the ${s.toLowerCase()}`,text:o})})]}),(0,K.jsx)(`section`,{"aria-busy":t,"aria-describedby":c?i:void 0,"aria-label":`Text to post`,className:HW.preview,"data-scrolls":``,"data-stale":r?``:void 0,ref:n,tabIndex:0,children:o===``?(0,K.jsx)(J,{text:t?nJ:rJ}):o}),(0,K.jsx)(`p`,{className:HW.note,children:`This is the Markdown that is sent, as it is. Secrets, your projects' paths, your home folder, emails, host names and IP addresses are taken out.`})]})},oJ=({children:e})=>(0,K.jsxs)(`div`,{className:HW.dialogFoot,children:[(0,K.jsx)(`p`,{className:HW.note,children:(0,K.jsx)(J,{text:"It posts with your own `gh` login."})}),(0,K.jsx)(`div`,{className:HW.actions,children:e})]}),sJ=({id:e})=>(0,K.jsx)(`p`,{className:HW.note,id:e,children:(0,K.jsx)(J,{text:"Your workflows' and projects' folders' names become `<name>`."})}),cJ=({id:e,url:t,kind:n,onClose:r})=>{let i=(0,H.useRef)(null);return(0,H.useEffect)(()=>{i.current?.focus()},[]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{className:HW.result,ref:i,tabIndex:-1,children:n===`created`?`Posted`:`Added a +1`}),(0,K.jsx)(`p`,{className:HW.message,children:(0,K.jsx)(eJ,{url:t})}),(0,K.jsx)(`p`,{className:HW.message,children:`${e} is published.`}),(0,K.jsx)(`div`,{className:HW.actions,children:(0,K.jsx)(Y,{onClick:r,children:`Close`})})]})},lJ=e=>e.step===`reading`||e.step===`readFailed`?e.shown:`preview`in e?e.preview:void 0,uJ=e=>e.step===`reading`||e.step===`readFailed`,dJ=e=>/[.!?]$/u.test(e.trim())?e.trim():`${e.trim()}.`,fJ=(e,t,n)=>{let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)({step:`reading`}),s=(0,H.useRef)(0),c=(0,H.useCallback)(async n=>{s.current+=1;let r=s.current,i=await e.call(`publishPreview`,{params:{id:t},body:{hideNames:n}});r===s.current&&o(e=>{if(i.ok)return{step:`preview`,preview:i.data,changed:!1};let t=lJ(e);return t===void 0?{step:`readFailed`,error:i.error}:{step:`readFailed`,error:i.error,shown:t}})},[e,t]);(0,H.useEffect)(()=>{c(!1)},[c]);let l=(e,t)=>{o(t===void 0?{step:`reading`}:{step:`reading`,shown:t}),c(e)},u=async i=>{o({step:`posting`,preview:i});let a=await e.call(`publish`,{params:{id:t},body:{hideNames:r,digest:i.digest}});if(a.ok){o({step:`posted`,url:a.data.url,kind:a.data.kind}),n();return}if(a.status!==409){o({step:`postFailed`,preview:i,error:a.error});return}let s=await e.call(`publishPreview`,{params:{id:t},body:{hideNames:r}});s.ok?s.data.digest===i.digest?o({step:`postFailed`,preview:i,error:a.error}):o({step:`preview`,preview:s.data,changed:!0}):o({step:`readFailed`,error:s.error,shown:i})};return{step:a,hideNames:r,setHideNames:e=>{i(e),l(e,lJ(a))},tryAgain:()=>{a.step===`postFailed`?u(a.preview):l(r)},post:()=>{a.step===`preview`&&u(a.preview)}}},pJ=`The text to post changed since you read it. Read it again before posting.`,mJ=e=>e.step===`readFailed`?`Could not read Ork's Discussions: ${dJ(e.error)} Nothing was sent.`:e.step===`postFailed`?`Could not post: ${dJ(e.error)}`:null,hJ=()=>{let e=document.activeElement;return e===null||e===document.body||e.getAttribute(`role`)===`dialog`},gJ=e=>e.step===`reading`?`Reading the preview…`:null,_J=({client:e,item:t,id:n,region:r,onStep:i,onClose:a,onPosted:o})=>{let s=fJ(e,t,o),{step:c,hideNames:l}=s,u=(0,H.useId)(),d=(0,H.useId)(),f=(0,H.useId)(),p=(0,H.useId)();if((0,H.useEffect)(()=>{i(c),c.step!==`posted`&&hJ()&&r.current?.focus()},[c,i,r]),c.step===`posted`)return(0,K.jsx)(cJ,{id:n,kind:c.kind,onClose:a,url:c.url});let m=lJ(c),h=c.step===`posting`,g=m?.plan.kind===`comment`;return(0,K.jsxs)(K.Fragment,{children:[c.step===`preview`&&c.changed?(0,K.jsx)(`p`,{role:`alert`,children:pJ}):null,m===void 0?null:(0,K.jsx)(tJ,{preview:m}),(0,K.jsx)(aJ,{preview:m,reading:c.step===`reading`,region:r,stale:uJ(c),staleId:p}),(0,K.jsx)(FO,{checked:l,describedBy:u,disabled:h,label:`Hide repository and workflow names`,onChange:s.setHideNames}),(0,K.jsx)(sJ,{id:u}),(0,K.jsx)(lC,{command:`ork feedback publish ${n}${l?` --hide-names`:``}`}),(0,K.jsx)($q,{id:f,onTryAgain:s.tryAgain,takeFocus:c.step===`postFailed`?`always`:`ifLost`,words:mJ(c)}),(0,K.jsx)(GW,{id:d,why:gJ(c)}),(0,K.jsxs)(oJ,{children:[(0,K.jsx)(Y,{disabled:h,focusableWhenDisabled:!0,onClick:a,variant:`ghost`,children:`Cancel`}),(0,K.jsx)(Y,{"aria-describedby":`${d} ${f}`,disabled:c.step!==`preview`,focusableWhenDisabled:!0,onClick:s.post,type:`button`,variant:`primary`,children:h?`Posting…`:g?`Post +1 comment`:`Post thread`})]})]})},vJ=({open:e,onOpenChange:t,client:n,item:r,id:i,onPosted:a,onCancelled:o})=>{let s=(0,H.useRef)(null),c=(0,H.useRef)({busy:!1,tried:!1}),l=(0,H.useCallback)(e=>{let t=e.step===`posting`;c.current={busy:t,tried:c.current.tried||t||e.step===`posted`}},[]),u=()=>{c.current.busy||(c.current.tried||o(),c.current={busy:!1,tried:!1},t(!1))};return(0,K.jsx)(PC,{initialFocus:s,onOpenChange:e=>{e?t(!0):u()},open:e,size:`wide`,title:`Publish ${i} to Ork's Discussions`,children:(0,K.jsx)(_J,{client:n,id:i,item:r,onClose:u,onPosted:a,onStep:l,region:s})})},yJ=({item:e,detail:t,acts:n})=>{let r=sb(),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(0),c=Tq(e.id),l=e.status===`dismissed`,u=e=>{s(e=>e+1),a(e)},d=e=>{e||a(null)},f=t=>{t===`accept`?n.accept(e):u(t===`lesson`?`lesson`:t===`apply`?`apply`:`publish`)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-label":`Actions on ${c}`,className:HW.actions,role:`group`,children:[Uq(e,t).map(({key:e,word:t,cli:n,variant:r,check:i})=>(0,K.jsx)(Y,{"aria-label":Wq(t,i),cli:n,disabled:!i.ok,focusableWhenDisabled:!0,onClick:()=>{f(e)},tip:i.ok?void 0:i.why,variant:r,children:t},e)),(0,K.jsx)(Y,{cli:`ork feedback ${l?`restore`:`dismiss`} ${c}`,onClick:()=>{n.setStatus(e,l?`new`:`dismissed`)},variant:`ghost`,children:l?`Restore`:`Dismiss`},`status`)]}),e.target===`ork`?(0,K.jsx)(`p`,{className:HW.note,children:`About Ork itself: it has no lesson or fix in your projects. Publish shares it with Ork's maintainers.`}):null,t===null?null:(0,K.jsx)(Zq,{detail:t,item:e,onAdd:r=>n.addLesson(e,r,t.lessonCap),onOpenChange:d,open:i===`lesson`},`lesson-${String(o)}`),(0,K.jsx)(Kq,{acts:n,id:c,item:e,onOpenChange:d,open:i===`apply`,root:t?.project.ok===!0?t.project.root:null},`fix-${String(o)}`),e.target===`ork`?(0,K.jsx)(vJ,{client:r.client,id:c,item:e.id,onCancelled:()=>{n.announce(`Nothing was sent.`)},onOpenChange:d,onPosted:()=>{n.reloadAll()},open:i===`publish`},`publish-${String(o)}`):null]})},bJ=({name:e,children:t})=>(0,K.jsxs)(`div`,{className:HW.fact,children:[(0,K.jsx)(`dt`,{className:HW.factName,children:e}),(0,K.jsx)(`dd`,{className:HW.factValue,children:t})]}),xJ=({name:e,values:t})=>t.length===0?null:(0,K.jsx)(bJ,{name:e,children:t.join(`, `)}),SJ=({item:e,onSplit:t})=>{let n=Tq(e.id);return(0,K.jsxs)(`dl`,{className:HW.facts,children:[(0,K.jsx)(bJ,{name:`Item`,children:n}),(0,K.jsx)(bJ,{name:`About`,children:e.target}),(0,K.jsx)(bJ,{name:`Kind`,children:e.kind}),(0,K.jsx)(bJ,{name:`Severity`,children:e.severity}),(0,K.jsx)(bJ,{name:`Seen`,children:(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`${String(e.count)}×`}),(0,K.jsx)(Dk,{children:Pq(e.count)}),` in ${Fq(e.runs.length)}`]})}),(0,K.jsx)(bJ,{name:`First seen`,children:(0,K.jsx)(`time`,{dateTime:e.firstSeen,children:DK(e.firstSeen)})}),(0,K.jsx)(bJ,{name:`Last seen`,children:(0,K.jsx)(`time`,{dateTime:e.lastSeen,children:DK(e.lastSeen)})}),(0,K.jsx)(xJ,{name:`Workflows`,values:e.workflows}),(0,K.jsx)(xJ,{name:`Models`,values:e.models}),(0,K.jsx)(xJ,{name:`Sources`,values:e.sources}),e.merged.length===0?null:(0,K.jsxs)(bJ,{name:`Merged`,children:[e.merged.map(Tq).join(`, `),(0,K.jsx)(Y,{cli:`ork feedback split ${n}`,onClick:t,variant:`ghost`,children:`Split`})]})]})},CJ=({onBack:e})=>(0,K.jsxs)(Y,{onClick:e,variant:`ghost`,children:[(0,K.jsx)(dy,{}),`Back to items`]}),wJ=({run:e,onOpen:t})=>(0,K.jsxs)(`p`,{className:HW.line,children:[(0,K.jsx)(`span`,{className:HW.lineIcon,children:(0,K.jsx)(iy,{})}),(0,K.jsxs)(`span`,{className:HW.message,children:[`Run `,(0,K.jsx)(`code`,{children:e}),` is proposing a fix.`]}),(0,K.jsx)(Y,{"aria-label":`Open run ${e}`,onClick:()=>{t(e)},variant:`ghost`,children:`Open run`})]}),TJ=e=>[DK(e.at),e.feedback.source,...e.feedback.code===void 0?[]:[e.feedback.code],`run ${e.runId}`,...e.node===void 0?[]:[e.node]].join(` · `),EJ=({record:e,title:t,onOpenRun:n})=>{let{feedback:r,runId:i,node:a}=e;return(0,K.jsxs)(`li`,{className:HW.record,children:[(0,K.jsxs)(`p`,{className:HW.recordMeta,children:[(0,K.jsx)(`span`,{children:TJ(e)}),(0,K.jsxs)(Y,{onClick:()=>{n(i,a)},variant:`ghost`,children:[`Open run`,(0,K.jsx)(Dk,{children:` ${i}${a===void 0?``:` at ${a}`}, ${DK(e.at)}`})]})]}),r.title===t?null:(0,K.jsx)(`h4`,{className:HW.recordTitle,children:r.title}),r.body===``?null:(0,K.jsx)(`p`,{className:HW.recordBody,children:r.body}),r.evidence.length===0?null:(0,K.jsxs)(`p`,{className:HW.evidence,children:[(0,K.jsx)(`span`,{className:HW.caption,children:`Evidence `}),r.evidence.join(`, `)]})]})},DJ=({item:e,read:t,onOpenRun:n})=>{let r=Tq(e.id),i=t.detail?.records;return(0,K.jsxs)(`div`,{className:HW.section,children:[(0,K.jsx)(`h3`,{className:HW.caption,children:i===void 0?`Records`:`Records · ${String(i.length)}, newest first`}),i===void 0&&t.error!==null?(0,K.jsxs)(`div`,{className:HW.line,children:[(0,K.jsx)(`p`,{className:HW.alert,role:`alert`,children:(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Could not read the records: ${t.error}`})})}),(0,K.jsx)(Y,{onClick:t.reload,variant:`ghost`,children:`Try again`})]}):null,i===void 0&&t.error===null?(0,K.jsx)(`p`,{"aria-busy":`true`,className:HW.message,children:`Reading records…`}):null,i===void 0?null:(0,K.jsx)(`ol`,{"aria-label":`Records of ${r}, newest first`,className:HW.records,role:`list`,children:i.toReversed().map(t=>(0,K.jsx)(EJ,{onOpenRun:n,record:t,title:e.title},t.id))})]})},OJ=({item:e,read:t,acts:n,narrow:r,onBack:i,onLeave:a})=>{let o=(0,H.useId)(),s=t.detail?.fixRun;return(0,K.jsxs)(`section`,{"aria-labelledby":o,className:HW.detail,onKeyDown:e=>{let t=document.querySelector(`[data-modal]`)!==null;e.key===`Escape`&&!t&&a()},children:[r?(0,K.jsx)(CJ,{onBack:i}):null,(0,K.jsxs)(`div`,{className:HW.head,children:[(0,K.jsx)(`h2`,{className:HW.title,"data-feedback-heading":``,id:o,tabIndex:-1,children:e.title}),(0,K.jsx)(pM,{pill:!0,status:e.status})]}),(0,K.jsx)(SJ,{item:e,onSplit:()=>{n.split(e)}}),s===void 0?null:(0,K.jsx)(wJ,{onOpen:n.openRun,run:s}),(0,K.jsx)(yJ,{acts:n,detail:t.detail,item:e}),(0,K.jsx)(DJ,{item:e,onOpenRun:n.openRun,read:t}),(0,K.jsx)(lC,{command:`ork feedback show ${e.id.slice(0,12)}`})]})},kJ=e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r=t.length-1,i={ArrowDown:Math.min(n+1,r),ArrowUp:Math.max(n-1,0),Home:0,End:r}[e.key];i!==void 0&&(e.preventDefault(),t[i]?.focus())},AJ=()=>(0,K.jsx)(Dk,{children:`, `}),jJ=(0,H.memo)(({item:e,chosen:t,tabStop:n,onChoose:r})=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:HW.row,"data-item":e.id,onClick:()=>{r(e.id)},tabIndex:n?0:-1,type:`button`,children:[(0,K.jsxs)(`span`,{className:HW.rowTop,children:[(0,K.jsx)(`span`,{className:HW.rowTitle,children:e.title}),(0,K.jsx)(AJ,{}),(0,K.jsx)(pM,{status:e.status})]}),(0,K.jsx)(AJ,{}),(0,K.jsxs)(`span`,{className:HW.rowMeta,children:[(0,K.jsx)(`span`,{children:Tq(e.id)}),(0,K.jsx)(AJ,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`${String(e.count)}×`}),(0,K.jsx)(Dk,{children:Pq(e.count)})]}),(0,K.jsx)(AJ,{}),(0,K.jsx)(`span`,{children:`${e.target} · ${e.kind}`}),e.severity===`high`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(AJ,{}),(0,K.jsx)(`span`,{className:HW.high,children:`high`})]}):null,e.merged.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(AJ,{}),(0,K.jsx)(`span`,{children:`+${String(e.merged.length)} merged`})]}),(0,K.jsx)(AJ,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(Dk,{children:`last seen `}),(0,K.jsx)(`time`,{dateTime:e.lastSeen,children:DK(e.lastSeen)})]})]})]})}));jJ.displayName=`FeedbackRow`;var MJ=({items:e,chosen:t,onChoose:n})=>{let r=e.some(({id:e})=>e===t)?t:e[0]?.id;return(0,K.jsx)(`ul`,{"aria-label":`Feedback items`,className:HW.list,onKeyDown:kJ,role:`list`,children:e.map(e=>(0,K.jsx)(jJ,{chosen:e.id===t,item:e,onChoose:n,tabStop:e.id===r},e.id))})},NJ=({filter:e,items:t,count:n,updating:r,failed:i,refusal:a,onValues:o,onAbout:s,onReload:c})=>(0,K.jsx)(`div`,{className:HW.tools,children:(0,K.jsx)(xH,{busy:r,defaults:Eq,error:a,extra:(0,K.jsx)(Ok,{label:`About`,onChange:s,options:Dq,value:e.about}),list:`feedback`,onChange:o,shown:t===null?null:n,suggestions:kq(t??[]),summary:t===null?``:Nq(n),tools:(0,K.jsx)(Y,{cli:`ork feedback list`,onClick:c,variant:`ghost`,children:i?`Try again`:`Reload`}),values:e.values})}),PJ=({error:e})=>(0,K.jsxs)(`p`,{className:HW.alert,"data-tone":`failed`,role:`alert`,children:[(0,K.jsx)(`span`,{className:HW.lineIcon,children:(0,K.jsx)(My,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Could not read feedback: ${e}`})})]}),FJ=({anything:e,filter:t})=>{if(!e)return(0,K.jsx)(dO,{cli:`ork feedback list`,title:`No feedback yet.`,children:`What gets in your runs' way lands here: Ork's own signals, the agents' reports and your notes. In a terminal:`});let{title:n,body:r}=Lq({status:`open`,about:t.about});return(0,K.jsx)(dO,{title:n,children:r})},IJ=(e,t,n,r)=>{e.arriveAt(n),r!==void 0&&e.selectNode(r),t?.goTo(`monitor`),requestAnimationFrame(()=>{let t=document.querySelector(`[data-run-heading="${n}"]`);t!==null&&(e.takeArrival(n),t.focus())})},LJ=e=>{let{state:t,workspace:n,filter:r,narrow:i,choose:a,focus:o}=e,s=(0,H.useRef)(!1),c=()=>lU(t.feedback.state.getValue())?.data??[],l=(e,r)=>{IJ(t,n,e,r)},u=async()=>{await e.reloadList(),e.reloadDetail()};return{moving:s,setStatus:async(e,l)=>{let d=Tq(e.id),f=jq(c(),r),p=await t.client.call(`feedbackStatus`,{params:{id:e.id},body:{status:l}});if(!p.ok){let e=l===`new`?`restore`:`dismiss`;nb.add({title:`Could not ${e} ${d}`,description:p.error});return}s.current=!0,await u();let m=jq(c(),r);if(!m.some(({id:t})=>t===e.id)){let t=Rq(f,m,e.id);a(t?.id??null),o(t===void 0?`list`:i?`heading`:{row:t.id})}s.current=!1,n?.announce(l===`dismissed`?`Dismissed ${d}. It's listed under All and Dismissed.`:`Restored ${d} as new.`)},accept:async e=>{let r=Tq(e.id),i=await t.client.call(`accept`,{params:{id:e.id},body:{lesson:!1}});i.ok?(n?.announce(`Accepted ${r}.`),await u()):nb.add({title:`Could not accept ${r}`,description:i.error})},addLesson:async(e,n,r)=>{let i=await t.client.call(`accept`,{params:{id:e.id},body:n});if(!i.ok)return`Could not add the lesson: ${i.error}`;let{lesson:a}=i.data;return nb.add({title:`Lesson added`,description:a===void 0?`${Tq(e.id)} is accepted.`:`\`${a.file}\` in \`${a.root}\`, ${qq(a.tokens,r)}. Every session of \`${a.workflow}\` reads it from now on.`}),u(),null},apply:async(e,n=``)=>{let r=await t.client.call(`apply`,{params:{id:e.id},body:n===``?{}:{driver:n}});if(!r.ok)return`Could not start the run: ${r.error}`;let{runId:i}=r.data;return nb.add({title:`Run ${i} started`,description:`\`ork:feedback-apply\` is proposing a fix for ${Tq(e.id)}. Its question comes to Decisions.`}),l(i),u(),null},split:async e=>{let r=Tq(e.id),i=await t.client.call(`split`,{params:{id:e.id}});i.ok?(o(`heading`),n?.announce(`Split ${Nq(i.data.moved)} back out of ${r}.`),await u()):nb.add({title:`Could not split ${r}`,description:i.error})},openRun:(e,t)=>{l(e,t)},reloadAll:u,announce:e=>{n?.announce(e)}}},RJ=5e3,zJ=48,BJ=16,VJ=(e,t)=>{let n=yb(e.feedback.state),r=yb(e.runs),i=(0,H.useRef)(0),a=(0,H.useRef)(null),o=(0,H.useRef)(r),s=(0,H.useCallback)(async()=>{i.current=Date.now(),await e.feedback.load(QV(t))},[e,t]);return(0,H.useEffect)(()=>(s(),()=>{a.current!==null&&clearTimeout(a.current),a.current=null}),[s]),(0,H.useEffect)(()=>{if(o.current===r||(o.current=r,a.current!==null))return;let e=Math.max(0,i.current+RJ-Date.now());a.current=setTimeout(()=>{a.current=null,s()},e)},[r,s]),{read:n,load:s}},HJ=(e,t,n)=>{let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(0),d=`${t??``}|${n}|${String(l)}`;(0,H.useEffect)(()=>{if(t===null)return()=>{};let n=!0;return e.call(`feedbackItem`,{params:{id:t}}).then(e=>(n&&(c(d),e.ok?(i({id:t,value:e.data}),o(null)):o({id:t,value:e.error})),e)),()=>{n=!1}},[e,t,d]);let f=(0,H.useCallback)(()=>{u(e=>e+1)},[]);return{detail:r?.id===t?r.value:null,error:a?.id===t?a.value:null,loading:t!==null&&s!==d,reload:f}},UJ=e=>{let[t,n]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let t=e.current;if(t===null)return()=>{};let r=new ResizeObserver(([e])=>{let t=e?.contentRect.width??0;if(t===0)return;let r=getComputedStyle(document.documentElement).fontSize,i=Number(r.replace(`px`,``))||BJ;n(t<zJ*i)});return r.observe(t),()=>{r.disconnect()}},[e]),t},WJ=e=>e===void 0?``:[e.status,e.count,e.lastSeen,...e.merged].join(`|`),GJ={heading:`[data-feedback-heading]`,list:`[data-feedback-list]`},KJ=(e,t)=>e?.querySelector(typeof t==`string`?GJ[t]:`[data-item="${t.row}"]`)??null,qJ=e=>{let t=(0,H.useRef)(null),[,n]=(0,H.useState)(0);return(0,H.useEffect)(()=>{let n=t.current;if(n===null)return;let r=KJ(e.current,n);r!==null&&(t.current=null,r.focus())}),(0,H.useCallback)(e=>{t.current=e,n(e=>e+1)},[])},JJ=()=>{let e=(0,H.useRef)(!1);return{had:e,onFocus:()=>{e.current=!0},onBlur:t=>{let n=t.relatedTarget;(n instanceof Node?!t.currentTarget.contains(n):t.target.isConnected)&&(e.current=!1)}}},YJ=()=>{let e=sb(),t=(0,H.use)(wU),n=yb(e.feedbackFilter),{read:r,load:i}=VJ(e,n.values),a=(0,H.useRef)(null),o=UJ(a),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(`list`),d=lU(r)?.data??null,f=(0,H.useMemo)(()=>d??[],[d]),p=(0,H.useMemo)(()=>jq(f,n),[f,n]),m=p.find(({id:e})=>e===s),h=HJ(e.client,m?.id??null,WJ(m)),g=qJ(a),_=JJ(),v=(0,H.useCallback)(e=>{c(e),u(e===null?`list`:`detail`)},[]),y=LJ({state:e,workspace:t,filter:n,narrow:o,choose:v,focus:g,reloadList:i,reloadDetail:h.reload}),{moving:b}=y;return(0,H.useEffect)(()=>{if(s===null||d===null||b.current||p.some(({id:e})=>e===s))return;let e=zq(f,s);e!==void 0&&p.some(({id:t})=>t===e.id)?(c(e.id),t?.announce(`${Tq(s)} was merged into ${Tq(e.id)}.`)):o||(c(null),document.activeElement===document.body&&_.had.current&&g(`list`))},[s,d,f,p,o,t,g,b]),{root:a,narrow:o,read:r,refusal:r.status===`failed`?nH(`feedback`,r.error):null,all:d,items:f,shown:p,filter:n,chosen:s,item:m,detail:h,acts:y,focusWatch:_,showing:Aq(o,l,s),back:()=>{u(`list`);let e=s!==null&&p.some(({id:e})=>e===s);g(e?{row:s}:`list`)},choose:e=>{v(e),o&&g(`heading`)},setValues:t=>{e.feedbackFilter.setValue({...n,values:t})},setAbout:r=>{e.feedbackFilter.setValue({...n,about:r}),t?.announce(`${Nq(jq(f,{...n,about:r}).length)}.`)},reload:()=>{i(),h.reload()}}},XJ=({view:e})=>{let{read:t,all:n,items:r,shown:i,filter:a,chosen:o}=e;return(0,K.jsxs)(`div`,{"aria-label":`Items`,className:HW.card,"data-feedback-list":``,role:`group`,tabIndex:-1,children:[t.status===`failed`&&e.refusal===null?(0,K.jsx)(PJ,{error:t.error}):null,n===null&&t.status!==`failed`?(0,K.jsx)(`p`,{className:HW.message,children:`Reading feedback…`}):null,n!==null&&i.length===0&&ZV(a.values)?(0,K.jsx)(gH,{list:`feedback`,onClear:()=>{e.setValues({})},values:a.values}):null,n!==null&&i.length===0&&!ZV(a.values)?(0,K.jsx)(FJ,{anything:r.length>0,filter:a}):null,i.length===0?null:(0,K.jsx)(MJ,{chosen:o,items:i,onChoose:e.choose})]})},ZJ=({view:e})=>{let{item:t,chosen:n,narrow:r}=e;return(0,K.jsxs)(`div`,{className:HW.card,"data-feedback-detail":``,children:[t===void 0?null:(0,K.jsx)(OJ,{acts:e.acts,item:t,narrow:r,onBack:e.back,onLeave:e.back,read:e.detail}),t===void 0&&r&&n!==null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(CJ,{onBack:e.back}),(0,K.jsx)(`p`,{className:HW.message,children:`${Tq(n)} isn't in this list any more.`})]}):null,t===void 0&&!r?(0,K.jsx)(`p`,{className:HW.message,children:`Choose an item to read its records.`}):null]})},QJ=()=>{let e=YJ(),{read:t,all:n,filter:r,shown:i,showing:a,focusWatch:o,root:s}=e;return(0,K.jsxs)(`div`,{"aria-label":`Feedback`,className:HW.panel,"data-layout":e.narrow?`narrow`:`wide`,onBlur:o.onBlur,onFocus:o.onFocus,ref:s,role:`group`,tabIndex:-1,children:[(0,K.jsx)(NJ,{count:i.length,failed:t.status===`failed`&&e.refusal===null,filter:r,items:n,onAbout:e.setAbout,onReload:e.reload,onValues:e.setValues,refusal:e.refusal,updating:t.status===`loading`&&n!==null}),(0,K.jsxs)(`div`,{className:HW.body,children:[a===`detail`?null:(0,K.jsx)(XJ,{view:e}),a===`list`?null:(0,K.jsx)(ZJ,{view:e})]})]})},$J=e=>e.slice(0,6),eY=[`agent`,`project:`,`me`,`person:`],tY=e=>{let t=eY.findIndex(t=>e.startsWith(t));return t===-1?eY.length:t},nY=(e,t)=>tY(e)-tY(t)||e.localeCompare(t),rY=e=>[...new Set(e.map(e=>e.for))].filter(e=>e.includes(`:`)).toSorted((e,t)=>nY(e,t)).map(e=>({value:e,label:e})),iY=e=>{let t=tH(e);return t!==void 0&&aD[`follow-ups`].includes(t)?{message:e,field:t}:null},aY=e=>{let t=e.filter(e=>e.status===`due`).length,n=e.filter(e=>e.status===`waiting`).length;return t+n===0?`Nothing open`:`${t===0?`None`:String(t)} due, ${String(n)} waiting`},oY=/^\d{4}-\d{2}-\d{2}$/u,sY=e=>[String(e.getFullYear()),String(e.getMonth()+1).padStart(2,`0`),String(e.getDate()).padStart(2,`0`)].join(`-`),cY=(e,t)=>{if(e.due===`now`)return{key:`now`,label:`Now`,order:`0`};if(e.due===`after-merge`)return{key:`after-merge`,label:`After merge`,order:`1`};if(e.due===`after-deploy`)return{key:`after-deploy`,label:`After deploy`,order:`2`};let n=oY.test(e.due)&&e.due<t;return{key:e.due,label:n?`Overdue · ${e.due}`:`By ${e.due}`,order:`3${e.due}`}},lY={due:0,waiting:1,done:2,dropped:3},uY=(e,t)=>lY[e.status]-lY[t.status]||t.createdAt.localeCompare(e.createdAt),dY=(e,t)=>{let n=new Map;for(let r of e){let e=cY(r,t),i=n.get(e.key);i===void 0?n.set(e.key,{due:e,rows:[r]}):i.rows.push(r)}return[...n.values()].toSorted((e,t)=>e.due.order.localeCompare(t.due.order)).map(({due:e,rows:t})=>({key:e.key,label:e.label,order:e.order,groups:[...new Set(t.map(e=>e.for))].toSorted((e,t)=>nY(e,t)).map(e=>({for:e,rows:t.filter(t=>t.for===e).toSorted(uY)}))}))},fY=e=>e.flatMap(e=>e.groups.flatMap(e=>e.rows)),pY=e=>{let t=/\/pull\/(\d+)/u.exec(e);return t===null?e:`#${t[1]??``}`},mY=e=>{let t=/github\.com\/([^/]+\/[^/]+)\/(?:pull|issues)\/(\d+)/u.exec(e);return t===null?e:`${t[1]??``}#${t[2]??``}`},hY=864e5,gY=(e,t)=>{if(e.status!==`due`)return;let n=e.note??``;if(n.includes(`closed without merging`))return`closed unmerged`;if(n.endsWith(` merged`))return`PR merged`;if(!(oY.test(e.due)&&e.due<sY(t)))return;let r=Math.floor((Date.parse(`${sY(t)}T00:00:00Z`)-Date.parse(`${e.due}T00:00:00Z`))/hY);return`overdue ${String(r)} d`},_Y=e=>e.status===`done`&&e.kind===`message`,vY=e=>e.due===`after-merge`||e.due===`after-deploy`?e.due.replace(`-`,` `):e.due,yY=()=>Date.now(),bY={ok:!0},xY=(e,t)=>{let n=$J(e.id),r=e=>t?.[e]??bY,i=t=>({key:`done`,word:e.kind===`message`?`Mark sent`:`Mark done`,cli:`ork follow-ups done ${n}`,variant:t?`primary`:`default`,check:r(`done`)}),a={key:`drop`,word:`Drop`,cli:`ork follow-ups drop ${n}`,variant:`default`,check:r(`drop`)};return e.status===`waiting`?[{key:`due`,word:`Mark due`,cli:`ork follow-ups due ${n}`,variant:`default`,check:r(`due`)},i(!1),a]:e.status===`due`?[i(!0),a]:[{key:`reopen`,word:`Reopen`,cli:`ork follow-ups reopen ${n}`,variant:`default`,check:r(`reopen`)}]},SY=(e,t)=>t.ok?e:`${e}: ${t.why}`,CY=(e,t)=>{let n=t.title;return e===`done`?`${t.kind===`message`?`Marked sent`:`Marked done`}: ${n}.`:e===`drop`?`Dropped: ${n}.`:e===`due`?`Marked due: ${n}.`:`Reopened: ${n}, ${t.due===`now`?`due`:`waiting`}.`},wY=(e,t,n)=>{let r=e.findIndex(e=>e.id===n),i=t.filter(e=>e.id!==n);return i[Math.min(Math.max(r,0),i.length-1)]},TY=e=>`Can't check PRs: ${e.some(e=>e.includes(`gh`))?"`gh` isn't signed in":e[0]??`no reason given`}. After-merge follow-ups stay waiting. Run this in a terminal:`,EY={panel:`_panel_ve6gb_9`,tools:`_tools_ve6gb_28`,card:`_card_ve6gb_29`,body:`_body_ve6gb_57`,list:`_list_ve6gb_73`,row:`_row_ve6gb_84`,rowTop:`_rowTop_ve6gb_125`,rowTitle:`_rowTitle_ve6gb_135`,rowMeta:`_rowMeta_ve6gb_149`,high:`_high_ve6gb_166`,detail:`_detail_ve6gb_174`,head:`_head_ve6gb_183`,title:`_title_ve6gb_192`,facts:`_facts_ve6gb_205`,fact:`_fact_ve6gb_205`,factName:`_factName_ve6gb_222`,caption:`_caption_ve6gb_223`,factValue:`_factValue_ve6gb_240`,actions:`_actions_ve6gb_255`,line:`_line_ve6gb_256`,note:`_note_ve6gb_265`,message:`_message_ve6gb_266`,lineIcon:`_lineIcon_ve6gb_276`,alert:`_alert_ve6gb_285`,section:`_section_ve6gb_303`,place:`_place_ve6gb_316`,wellHead:`_wellHead_ve6gb_326`,wellCopy:`_wellCopy_ve6gb_335`,preview:`_preview_ve6gb_343`,link:`_link_ve6gb_390`,result:`_result_ve6gb_401`,dialogFoot:`_dialogFoot_ve6gb_410`,group:`_group_ve6gb_444`,groupCaption:`_groupCaption_ve6gb_452`,captionValue:`_captionValue_ve6gb_470`,forLine:`_forLine_ve6gb_476`,rowDone:`_rowDone_ve6gb_488`,steps:`_steps_ve6gb_492`,step:`_step_ve6gb_492`,draft:`_draft_ve6gb_510`,heading:`_heading_ve6gb_524`,tabCount:`_tabCount_ve6gb_533`,stale:`_stale_ve6gb_548`},DY=({row:e,actions:t,onAct:n})=>(0,K.jsx)(`div`,{"aria-label":`Actions on ${$J(e.id)}`,className:EY.actions,role:`group`,children:xY(e,t).map(({key:e,word:t,cli:r,variant:i,check:a})=>(0,K.jsx)(Y,{"aria-label":SY(t,a),cli:r,disabled:!a.ok,focusableWhenDisabled:!0,onClick:()=>{n(e)},tip:a.ok?void 0:a.why,variant:i,children:t},e))}),OY=({text:e})=>e===``?null:(0,K.jsx)(zV,{source:e,children:(0,K.jsx)(PV,{startLevel:4,text:e})}),kY=({id:e,error:t})=>t===null?null:(0,K.jsx)(`p`,{className:EY.alert,role:`alert`,children:(0,K.jsx)(J,{text:`Couldn't read ${e}: ${t}`})}),AY=({row:e})=>(0,K.jsx)(lC,{command:`ork follow-ups show ${$J(e.id)}`}),jY=({onBack:e})=>(0,K.jsxs)(Y,{onClick:e,variant:`ghost`,children:[(0,K.jsx)(dy,{}),`Back to follow-ups`]}),MY=({name:e,children:t})=>(0,K.jsxs)(`div`,{className:EY.fact,children:[(0,K.jsx)(`dt`,{className:EY.factName,children:e}),(0,K.jsx)(`dd`,{className:EY.factValue,children:t})]}),NY=e=>{let{place:t,url:n}=e.keptIn;return t===`store`?`Ork's store`:n??(t===`file`?`.ork/follow-ups.md`:`GitHub`)},PY=(e,t)=>{let{delivery:n}=e;if(n!==void 0)return n.registered?n.live===void 0?`In \`${n.project}\`'s list`:`Sent to its live run \`${$J(n.live.run)}\` through relay`:`Not delivered: \`${n.project}\` isn't registered. Registered: ${t.map(e=>`\`${e}\``).join(`, `)||`none`}.`},FY=({row:e,detail:t,projects:n,onOpenRun:r})=>{let i=t===null?void 0:PY(t,n);return(0,K.jsxs)(`dl`,{className:EY.facts,children:[(0,K.jsxs)(MY,{name:`Id`,children:[$J(e.id),(0,K.jsx)(sC,{label:`Copy id`,text:e.id})]}),(0,K.jsx)(MY,{name:`For`,children:e.for}),(0,K.jsx)(MY,{name:`Kind`,children:e.kind}),(0,K.jsx)(MY,{name:`Due`,children:e.due}),(0,K.jsx)(MY,{name:`Status`,children:_Y(e)?`sent`:e.status}),e.ref===void 0?null:(0,K.jsx)(MY,{name:`Ref`,children:/^https?:\/\//u.test(e.ref)?(0,K.jsxs)(`a`,{className:EY.link,href:e.ref,rel:`noreferrer`,target:`_blank`,children:[e.ref,(0,K.jsx)(Fy,{})]}):e.ref}),e.from.run===void 0?null:(0,K.jsxs)(MY,{name:`From`,children:[`run ${$J(e.from.run)}${e.from.node===void 0?``:`, node ${e.from.node}`}`,(0,K.jsx)(Y,{"aria-label":`Open run ${$J(e.from.run)}${e.from.node===void 0?``:`, node ${e.from.node}`}`,onClick:()=>{e.from.run!==void 0&&r(e.from.run,e.from.node)},variant:`ghost`,children:`Open run`})]}),e.where.length===0?null:(0,K.jsx)(MY,{name:`Where`,children:e.where.join(`, `)}),t===null?null:(0,K.jsxs)(MY,{name:`Kept in`,children:[NY(t),t.keptIn.fallback===void 0?null:(0,K.jsx)(`span`,{className:EY.note,children:t.keptIn.fallback})]}),i===void 0?null:(0,K.jsx)(MY,{name:`Delivery`,children:(0,K.jsx)(J,{text:i})}),(0,K.jsx)(MY,{name:`Added`,children:(0,K.jsx)(`time`,{dateTime:e.createdAt,children:DK(e.createdAt)})}),(0,K.jsx)(MY,{name:`Last changed`,children:(0,K.jsx)(`time`,{dateTime:e.updatedAt,children:DK(e.updatedAt)})})]})},IY={well:`_well_18f8h_7`},LY=({label:e,reading:t,describedBy:n,ref:r,steady:i=!1,short:a=!1,children:o})=>(0,K.jsx)(`section`,{"aria-busy":t!==void 0,"aria-describedby":n,"aria-label":e,className:IY.well,"data-short":a?``:void 0,"data-steady":i?``:void 0,ref:r,tabIndex:0,children:t===void 0?o:(0,K.jsx)(J,{text:t})}),RY=({row:e,detail:t,onPost:n,gh:r})=>{let{draft:i}=e;if(i===void 0)return null;let a=i.channel,o=t?.actions.post,s="`gh` isn't signed in",c=o?.ok===!1&&o.kind===`status`,l=o?.ok===!1?`Post to GitHub…: ${o.why}`:null;return(0,K.jsxs)(`div`,{className:EY.draft,children:[(0,K.jsx)(`h4`,{className:EY.heading,children:`Draft message`}),(0,K.jsxs)(`dl`,{className:EY.facts,children:[(0,K.jsx)(MY,{name:`To`,children:i.to}),a===void 0?null:(0,K.jsx)(MY,{name:`Channel`,children:a})]}),(0,K.jsx)(`div`,{className:EY.wellHead,children:(0,K.jsx)(`span`,{className:EY.wellCopy,children:(0,K.jsx)(sC,{label:`Copy message`,text:i.text})})}),(0,K.jsx)(LY,{label:`Message text`,children:(0,K.jsx)(`p`,{className:EY.preview,children:i.text})}),(0,K.jsx)(`p`,{className:EY.note,children:`Ork never sends this. Copy it, send it yourself, then mark it sent.`}),a===`github`?(0,K.jsx)(Y,{"aria-label":l??(r?`Post to GitHub…`:`Post to GitHub…: ${s}`),cli:`ork follow-ups post ${$J(e.id)}`,disabled:o?.ok!==!0||!r,focusableWhenDisabled:!0,onClick:n,tip:o?.ok===!1?`Can't post: ${o.why}.${c?``:` Copy the message and post it yourself.`}`:r?void 0:`${s}. Run gh auth login in a terminal.`,children:`Post to GitHub…`}):(0,K.jsx)(`p`,{className:EY.note,children:(0,K.jsx)(J,{text:`Ork can't send to \`${a??`that channel`}\`. Copy the message and send it yourself.`})})]})},zY=({row:e})=>e.steps===void 0?null:(0,K.jsxs)(`div`,{className:EY.section,children:[(0,K.jsx)(`p`,{className:EY.note,children:`Ork never runs these. Run each yourself, then mark this done.`}),(0,K.jsx)(`ol`,{className:EY.steps,children:e.steps.map((e,t)=>(0,K.jsxs)(`li`,{className:EY.step,children:[(0,K.jsx)(`span`,{children:e.text}),e.command===void 0?null:(0,K.jsx)(lC,{command:e.command})]},t))})]}),BY=({row:e})=>e.for===`agent`&&e.kind===`change`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:EY.note,children:e.takenBy===void 0?`Done when a run that takes it publishes.`:`Taken by run ${$J(e.takenBy)}; done when it publishes.`}),(0,K.jsx)(`p`,{className:EY.note,children:`Take it in a run:`}),(0,K.jsx)(lC,{command:`ork run start --follow-ups ${$J(e.id)}`})]}):null,VY=({row:e,detail:t})=>t?.cause===`closed-unmerged`?(0,K.jsxs)(`p`,{className:EY.alert,children:[(0,K.jsx)(`span`,{className:EY.lineIcon,children:(0,K.jsx)(My,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`\`${e.ref??`The ref`}\` was closed without merging, so this is due now. Check it still applies, then mark it done or drop it.`})})]}):null,HY=({row:e,detail:t,open:n,onOpenChange:r,onPost:i})=>{let a=t.followUp.draft;return(0,K.jsx)(IC,{cli:`ork follow-ups post ${$J(e.id)} --confirm`,confirm:`Post comment`,description:`This posts the comment below to \`${mY(a?.to??``)}\` as you, through your \`gh\`. Ork sends nothing else.`,onConfirm:i,onOpenChange:r,open:n,pending:`Posting…`,title:`Post to GitHub?`,variant:`primary`,children:(0,K.jsx)(LY,{label:`Comment to post`,children:(0,K.jsx)(`p`,{className:EY.preview,children:a?.text??``})})})},UY=({row:e,view:t})=>{let n=(0,H.useId)(),{detail:r}=t.detail,[i,a]=(0,H.useState)(!1),o=r?.draftDigest;return(0,K.jsxs)(`section`,{"aria-labelledby":n,className:EY.detail,onKeyDown:e=>{let n=document.querySelector(`[data-modal]`)!==null;e.key===`Escape`&&!n&&!e.defaultPrevented&&t.back()},children:[t.narrow?(0,K.jsx)(jY,{onBack:t.back}):null,(0,K.jsxs)(`div`,{className:EY.head,children:[(0,K.jsx)(`h3`,{className:EY.title,"data-followups-heading":``,id:n,tabIndex:-1,children:e.title}),(0,K.jsx)(_M,{pill:!0,sent:_Y(e),status:e.status})]}),(0,K.jsx)(DY,{actions:r?.actions,onAct:n=>{t.act(e,n)},row:e}),(0,K.jsx)(BY,{row:e}),(0,K.jsx)(VY,{detail:r,row:e}),(0,K.jsx)(FY,{detail:r,onOpenRun:t.openRun,projects:t.all?.projects??[],row:e}),(0,K.jsx)(OY,{text:e.body}),(0,K.jsx)(RY,{detail:r,gh:t.all?.checker.available??!0,onPost:()=>{a(!0)},row:e}),(0,K.jsx)(zY,{row:e}),(0,K.jsx)(kY,{error:t.detail.error,id:$J(e.id)}),(0,K.jsx)(AY,{row:e}),r===null||o===void 0?null:(0,K.jsx)(HY,{detail:r,onOpenChange:e=>{e||(a(!1),t.announce(`Cancelled. Nothing was posted.`))},onPost:()=>t.post(e,o),open:i,row:e})]})},WY=e=>{let t=[...e.currentTarget.querySelectorAll(`button`)],n=t.findIndex(e=>e===document.activeElement),r=t.length-1,i={ArrowDown:Math.min(n+1,r),ArrowUp:Math.max(n-1,0),Home:0,End:r}[e.key];i!==void 0&&(e.preventDefault(),t[i]?.focus())},GY=()=>(0,K.jsx)(Dk,{children:`, `}),KY=(0,H.memo)(({row:e,chosen:t,tabStop:n,showProject:r,today:i,onChoose:a})=>{let o=gY(e,new Date(i)),s=e.status===`done`||e.status===`dropped`;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{"aria-current":t?`true`:void 0,className:`${EY.row??``} ${s?EY.rowDone??``:``}`,"data-follow-up":e.id,onClick:()=>{a(e.id)},tabIndex:n?0:-1,type:`button`,children:[(0,K.jsxs)(`span`,{className:EY.rowTop,children:[(0,K.jsx)(`span`,{className:EY.rowTitle,children:e.title}),(0,K.jsx)(GY,{}),(0,K.jsx)(_M,{sent:_Y(e),status:e.status})]}),(0,K.jsx)(GY,{}),(0,K.jsxs)(`span`,{className:EY.rowMeta,children:[r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:e.projectId}),(0,K.jsx)(GY,{})]}):null,(0,K.jsx)(`span`,{children:$J(e.id)}),(0,K.jsx)(GY,{}),(0,K.jsxs)(Dk,{children:[`for `,e.for,`, `]}),(0,K.jsx)(`span`,{children:e.kind}),(0,K.jsx)(GY,{}),(0,K.jsx)(`span`,{children:vY(e)}),o===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(GY,{}),(0,K.jsx)(`span`,{children:o})]}),e.ref===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(GY,{}),(0,K.jsx)(`span`,{children:pY(e.ref)})]}),(0,K.jsx)(GY,{}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(Dk,{children:`added `}),(0,K.jsx)(`time`,{dateTime:e.createdAt,children:DK(e.createdAt)})]})]})]})})});KY.displayName=`FollowUpRowButton`;var qY=({group:e,count:t})=>(0,K.jsxs)(`h4`,{className:EY.groupCaption,children:[(0,K.jsx)(`span`,{className:EY.captionValue,children:e.label}),` · ${String(t)}`]}),JY=({rows:e,chosen:t,showProject:n,today:r,onChoose:i})=>{let a=dY(e,sY(new Date(r))),o=fY(a)[0]?.id,s=e.some(e=>e.id===t)?t:o;return(0,K.jsx)(`div`,{className:EY.list,onKeyDown:WY,children:a.map(e=>(0,K.jsxs)(`div`,{className:EY.group,children:[(0,K.jsx)(qY,{count:e.groups.reduce((e,t)=>e+t.rows.length,0),group:e}),e.groups.map(a=>(0,K.jsxs)(`div`,{className:EY.group,children:[(0,K.jsx)(`p`,{className:EY.forLine,children:a.for}),(0,K.jsx)(`ul`,{"aria-label":`${e.label}, for ${a.for}`,className:EY.list,role:`list`,children:a.rows.map(e=>(0,K.jsx)(KY,{chosen:e.id===t,onChoose:i,row:e,showProject:n,tabStop:e.id===s,today:r},e.id))})]},a.for))]},e.key))})},YY=e=>[...new Set(e.map(e=>e.projectId))],XY={status:`open`},ZY=({filter:e,read:t,updating:n,failed:r,refusal:i,onFilter:a,onReload:o})=>{let s=t?.rows??[],c=t?.projects??[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:EY.tools,children:(0,K.jsx)(xH,{busy:n,defaults:XY,error:i,list:`follow-ups`,onChange:a,shown:t===null?null:s.length,suggestions:{for:rY(s),project:c.map(e=>({value:e,label:e}))},summary:t===null?``:aY(s),tools:(0,K.jsx)(Y,{"aria-label":r?`Try again: reload follow-ups`:`Reload follow-ups`,cli:`ork follow-ups list`,onClick:o,variant:`ghost`,children:r?`Try again`:`Reload`}),values:e})}),t===null||t.checker.available?null:(0,K.jsxs)(`p`,{className:EY.alert,children:[(0,K.jsx)(`span`,{className:EY.lineIcon,children:(0,K.jsx)(My,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:TY(t.checker.errors)})})]}),t===null||t.checker.available?null:(0,K.jsx)(lC,{command:`gh auth login`})]})},QY=({error:e,onRetry:t})=>(0,K.jsxs)(`div`,{className:EY.alert,"data-tone":`failed`,role:`alert`,children:[(0,K.jsx)(`span`,{className:EY.lineIcon,children:(0,K.jsx)(My,{})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(J,{text:`Couldn't read follow-ups: ${e}. Reload, or in a terminal:`}),` `,(0,K.jsx)(lC,{command:`ork follow-ups list`}),(0,K.jsx)(Y,{onClick:t,variant:`ghost`,children:`Try again`})]})]}),$Y={heading:`[data-followups-heading]`,list:`[data-followups-list]`},eX=(e,t)=>e?.querySelector(typeof t==`string`?$Y[t]:`[data-follow-up="${t.row}"]`)??null,tX=e=>{let t=(0,H.useRef)(null),[,n]=(0,H.useState)(0);return(0,H.useEffect)(()=>{let n=t.current;if(n===null)return;let r=eX(e.current,n);r!==null&&(t.current=null,r.focus())}),(0,H.useCallback)(e=>{t.current=e,n(e=>e+1)},[])},nX=e=>{let{client:t}=sb(),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(0),c=e?.id??null,l=e?.projectId??``,u=`${c??``}|${l}|${e?.status??``}|${e?.updatedAt??``}|${String(o)}`;return(0,H.useEffect)(()=>{if(c===null)return()=>{};let e=!0;return t.call(`followUp`,{params:{id:l,followUp:c}}).then(t=>(e&&(t.ok?(r({id:c,asked:u,value:t.data}),a(null)):a({id:c,asked:u,value:t.error})),t)),()=>{e=!1}},[t,c,l,u]),{detail:n?.id===c?n.value:null,error:i?.id===c?i.value:null,reload:(0,H.useCallback)(()=>{s(e=>e+1)},[])}},rX=(e,t,n,r)=>{let i=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(e===null)return;let a=new Set(e.filter(e=>e.status===`due`).map(e=>e.id)),o=i.current;if(i.current={scope:t,due:a},o===null||o.scope!==t)return;let s=[...a].filter(e=>!o.due.has(e)),c=s.filter(e=>!r.current.has(e)).length;for(let e of s)r.current.delete(e);c>0&&n(`${String(c)} follow-up${c===1?``:`s`} came due.`)},[e,t,n,r])},iX=e=>{nb.add(e)},aX=3e4,oX={due:`mark due`,done:`mark done`,drop:`drop`,reopen:`reopen`},sX=()=>{let e=sb(),t=(0,H.use)(wU),n=yb(e.followUpsFilter),r=yb(e.followUps.state),i=(0,H.useRef)(null),a=UJ(i),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(`list`),u=lU(r)?.data??null,d=(0,H.useMemo)(()=>u?.rows??[],[u]),f=d.find(e=>e.id===o),p=nX(f),m=tX(i),h=(0,H.useCallback)(e=>{t?.announce(e)},[t]),g=(0,H.useCallback)(()=>e.followUps.load(n),[e,n]);(0,H.useEffect)(()=>{g();let e=setInterval(()=>{g()},aX);return()=>{clearInterval(e)}},[g]);let _=(0,H.useRef)(new Set);rX(u===null?null:d,JSON.stringify(lU(r)?.arg??{}),h,_);let v=(0,H.useCallback)(e=>{s(e),l(e===null?`list`:`detail`)},[]),y=()=>lU(e.followUps.state.getValue())?.data.rows??[],b=async e=>{let t=d;await g(),p.reload();let n=y();if(n.some(t=>t.id===e.id))m(`heading`);else{let r=wY(t,n,e.id);v(r?.id??null),m(r===void 0?`list`:a?`heading`:{row:r.id})}return y().find(t=>t.id===e.id)??e};return{root:i,narrow:a,read:r,refusal:r.status===`failed`?iY(r.error):null,all:u,rows:d,filter:n,chosen:o,row:f,detail:p,gone:o!==null&&u!==null&&f===void 0,act:async(t,n)=>{n===`due`&&_.current.add(t.id);let r=await e.client.call(`followUpChange`,{params:{id:t.projectId,followUp:t.id},body:{action:n}});r.ok?h(CY(n,await b(t))):iX({title:`Couldn't ${n===`done`&&t.kind===`message`?`mark sent`:oX[n]}`,description:r.error})},post:async(t,n)=>{let r=await e.client.call(`followUpPost`,{params:{id:t.projectId,followUp:t.id},body:{confirm:!0,digest:n}});if(!r.ok)return p.reload(),h(`Not posted.`),r.error.startsWith(`The draft is no longer`)?`The draft changed since you opened this. Read it again.`:`Not posted: ${r.error}. Copy the text and post it yourself, or fix \`gh\` and try again.`;let i=mY(t.draft?.to??``);return iX({title:`Posted to ${i}`,description:`Marked sent.`}),h(`Posted to ${i}. Marked sent.`),b(t),null},announce:h,showing:a?o===null?`list`:c:`both`,choose:e=>{v(e),a&&m(`heading`)},back:()=>{l(`list`),m(f===void 0?`list`:{row:f.id})},setFilter:t=>{e.followUpsFilter.setValue(t)},reload:()=>{g(),p.reload()},openRun:(n,r)=>{IJ(e,t,n,r)}}},cX=({filter:e,onClear:t})=>ZV(e)?(0,K.jsx)(gH,{list:`follow-ups`,onClear:t,values:e}):(0,K.jsx)(dO,{cli:`ork follow-ups add`,title:`No open follow-ups.`,children:`A run adds one when a change leaves work for later. Add one yourself:`}),lX=({view:e})=>{let{read:t,all:n,rows:r,chosen:i}=e,a=t.status===`failed`&&e.refusal===null;return(0,K.jsxs)(`div`,{"aria-label":`Follow-up list`,className:`${EY.card??``} ${a?EY.stale??``:``}`,"data-followups-list":``,role:`group`,tabIndex:-1,children:[a?(0,K.jsx)(QY,{error:t.error,onRetry:e.reload}):null,a&&r.length>0?(0,K.jsx)(`p`,{className:EY.note,children:`From the last read`}):null,n===null&&!a?(0,K.jsx)(`output`,{className:EY.message,children:`Reading follow-ups…`}):null,n!==null&&r.length===0?(0,K.jsx)(cX,{filter:e.filter,onClear:()=>{e.setFilter({})}}):null,r.length===0?null:(0,K.jsx)(JY,{chosen:i,onChoose:e.choose,rows:r,showProject:YY(r).length>1,today:yY()})]})},uX=({view:e})=>{let{row:t,narrow:n,gone:r}=e;return(0,K.jsxs)(`div`,{className:EY.card,"data-followups-detail":``,children:[t===void 0?null:(0,K.jsx)(UY,{row:t,view:e}),t===void 0&&r?(0,K.jsx)(`p`,{className:EY.message,children:`That follow-up is no longer in this list.`}):null,t===void 0&&!r&&!n?(0,K.jsx)(`p`,{className:EY.message,children:`Choose a follow-up to read it.`}):null]})},dX=()=>{let e=sX(),{read:t,all:n,filter:r,showing:i,root:a}=e;return(0,K.jsxs)(`div`,{"aria-label":`Follow-ups`,className:EY.panel,"data-layout":e.narrow?`narrow`:`wide`,ref:a,role:`group`,tabIndex:-1,children:[(0,K.jsx)(ZY,{failed:t.status===`failed`&&e.refusal===null,filter:r,onFilter:e.setFilter,onReload:e.reload,read:n,refusal:e.refusal,updating:t.status===`loading`&&n!==null}),(0,K.jsxs)(`div`,{className:EY.body,children:[i===`detail`?null:(0,K.jsx)(lX,{view:e}),i===`list`?null:(0,K.jsx)(uX,{view:e})]})]})},fX={panel:`_panel_16yxh_9`,tools:`_tools_16yxh_35`,filter:`_filter_16yxh_51`,body:`_body_16yxh_58`,overview:`_overview_16yxh_81`,breakdowns:`_breakdowns_16yxh_94`,totals:`_totals_16yxh_108`,total:`_total_16yxh_108`,section:`_section_16yxh_147`,heading:`_heading_16yxh_156`,hintsSection:`_hintsSection_16yxh_165`,chartArea:`_chartArea_16yxh_174`,hints:`_hints_16yxh_165`,chartHead:`_chartHead_16yxh_190`,readout:`_readout_16yxh_202`,chart:`_chart_16yxh_174`,column:`_column_16yxh_229`,bar:`_bar_16yxh_244`,axis:`_axis_16yxh_273`,axisEvery:`_axisEvery_16yxh_274`,details:`_details_16yxh_315`,table:`_table_16yxh_323`,number:`_number_16yxh_369`,name:`_name_16yxh_381`,path:`_path_16yxh_396`,retry:`_retry_16yxh_406`,note:`_note_16yxh_410`,refused:`_refused_16yxh_417`,limits:`_limits_16yxh_484`},pX=e=>e===void 0?`All projects`:`This project`,mX=e=>`$${e.toFixed(2)}`,hX=e=>new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}),gX=e=>`${e.project??`all`}-${e.window}`,_X=({cap:e})=>(0,K.jsx)(ZG,{label:`${pX(e.project)}, this ${e.window}, in tokens`,max:e.capTokens,text:`${SM(e.spentTokens)} of ${CM(e.capTokens)} tokens, resets ${hX(e.resetsAt)}${e.spentTokens>=e.capTokens?`, reached`:``}`,value:Math.min(e.spentTokens,e.capTokens)}),vX=({limits:e})=>{let t=e.tokenCaps??[],n=new Set(e.caps.map(gX));return e.problems.length===0&&e.caps.length===0&&t.length===0&&e.plan.length===0?null:(0,K.jsxs)(`section`,{"aria-label":`Limits`,className:fX.limits,children:[e.problems.map(e=>(0,K.jsx)(`p`,{className:fX.note,children:(0,K.jsx)(J,{text:e})},e)),e.caps.map(e=>(0,K.jsxs)(H.Fragment,{children:[(0,K.jsx)(ZG,{label:`${pX(e.project)}, this ${e.window}`,max:e.capUsd,text:`${mX(e.spentUsd)} of ${mX(e.capUsd)}, resets ${hX(e.resetsAt)}`,value:Math.min(e.spentUsd,e.capUsd)}),t.filter(t=>gX(t)===gX(e)).map(e=>(0,K.jsx)(_X,{cap:e},`${gX(e)}-tokens`))]},gX(e))),t.filter(e=>!n.has(gX(e))).map(e=>(0,K.jsx)(_X,{cap:e},`${gX(e)}-tokens`)),t.length===0?null:(0,K.jsx)(`p`,{className:fX.note,children:`Tokens counted: input, output and cache write. Cache reads are not counted.`}),e.plan.map(e=>(0,K.jsx)(`p`,{className:fX.note,children:`Your Claude plan's ${e.window.replaceAll(`_`,` `)} limit ${e.status===`rejected`?`was reached`:`is close`}${e.resetsAt===void 0?``:`; it resets ${hX(e.resetsAt)}`}.`},e.window))]})},yX=`all`,bX=e=>e===yX,xX=(e,t)=>{if(bX(e))return;let n=new Date(t);return new Date(n.getFullYear(),n.getMonth(),n.getDate()-(Number(e)-1)).toISOString()},SX=(e,t)=>{let n=/^(\d+)([dwh])$/u.exec(e),r=/^(\d{4})-(\d{2})-(\d{2})$/u.exec(e);if(!bX(e)){if(n!==null){let r=Number(n[1]);return r===0?e:n[2]===`h`?new Date(t-r*36e5).toISOString():xX(String(n[2]===`w`?r*7:r),t)}return r===null?e:new Date(Number(r[1]),Number(r[2])-1,Number(r[3])).toISOString()}},CX=(e,t,n)=>[`ork usage`,...e?[`--project`,`all`]:[],`--since ${t}`,...n===void 0?[]:[`--by ${n}`]].join(` `),wX=92,TX=e=>String(e).padStart(2,`0`),EX=e=>`${String(e.getFullYear())}-${TX(e.getMonth()+1)}-${TX(e.getDate())}`,DX=e=>{let[t=0,n=1,r=1]=e.split(`-`).map(Number);return new Date(t,n-1,r)},OX=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()-(e.getDay()+6)%7),kX=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),AX=(e,t,n,r)=>{let i=new Map(e.map(e=>[e.key,e])),a=[];for(let e=n;e<=r;e=new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)){let t=EX(e);a.push(i.get(t)??{key:t,costUsd:0,sessions:0})}return a},jX=(e,t,n)=>{let r=e.groups.day,i=t===void 0?r[0]?.key:void 0;if(t===void 0&&i===void 0)return{unit:`day`,bars:[],maxUsd:0};let a=t===void 0?DX(i??``):kX(new Date(t)),o=kX(new Date(n)),s=AX(r,1,a,o),c=s.length>wX?`week`:`day`,l=c===`day`?s:AX(e.groups.week,7,OX(a),o);return{unit:c,bars:l,maxUsd:Math.max(0,...l.map(e=>e.costUsd))}},MX=e=>xM(e),NX=e=>{let t=[...e];return e=>xM(e,t)},PX=SM,FX=(e,t)=>wM(MX(e),t),IX=e=>`${String(Math.round(e*100))}%`,LX=({period:e,limits:t,values:n,onClear:r})=>ZV(n)?(0,K.jsx)(gH,{list:`usage`,onClear:r,values:n}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(vX,{limits:t}),(0,K.jsx)(dO,{cli:`ork run <workflow>`,title:bX(e)?`Nothing spent yet.`:`Nothing spent in this period.`,children:`Claude sessions show here once they finish. Start one with Run workflow, or in a terminal:`})]}),RX=({error:e,command:t,retry:n})=>(0,K.jsxs)(`div`,{className:fX.section,children:[(0,K.jsxs)(`p`,{className:fX.refused,role:`alert`,children:[`Cannot read usage: `,(0,K.jsx)(J,{text:e})]}),(0,K.jsx)(`div`,{className:fX.retry,children:(0,K.jsx)(Y,{onClick:n,children:`Try again`})}),(0,K.jsx)(`p`,{className:fX.note,children:`On a terminal, the same report:`}),(0,K.jsx)(lC,{command:t})]}),zX=e=>e.toSorted((e,t)=>t.costUsd-e.costUsd)[0],BX=e=>`${String(e)} session${e===1?``:`s`}`,VX=2,HX=6,UX=14,WX=e=>e<=HX?`always`:e<=UX?`wide`:`never`,GX=({bars:e})=>{let t=WX(e.length);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"aria-hidden":!0,className:fX.axis,"data-labelled":t,children:[(0,K.jsx)(`span`,{children:e[0]?.key}),(0,K.jsx)(`span`,{children:e.at(-1)?.key})]}),(0,K.jsx)(`div`,{"aria-hidden":!0,className:fX.axisEvery,"data-labelled":t,children:e.map(e=>(0,K.jsx)(`span`,{children:e.key.slice(5)},e.key))})]})},KX=({series:e})=>{let{bars:t,unit:n}=e,r=t.filter(e=>e.costUsd>0||e.sessions>0).toReversed(),i=t.length-r.length,a=NX(r.map(e=>e.costUsd)),o=r.some(e=>(e.tokens??0)>0);return(0,K.jsxs)(`details`,{className:fX.details,children:[(0,K.jsx)(`summary`,{children:`Show as a table`}),(0,K.jsxs)(`table`,{className:fX.table,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`col`,children:n===`day`?`Day`:`Week of`}),(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Cost`}),o?(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Tokens`}):null,(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Sessions`})]})}),(0,K.jsx)(`tbody`,{children:r.map(e=>(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:fX.name,scope:`row`,children:e.key}),(0,K.jsx)(`td`,{className:fX.number,children:(0,K.jsx)(MM,{partial:e.partial===!0,text:a(e.costUsd)})}),o?(0,K.jsx)(`td`,{className:fX.number,children:SM(e.tokens??0)}):null,(0,K.jsx)(`td`,{className:fX.number,children:e.sessions})]},e.key))})]}),i===0?null:(0,K.jsxs)(`p`,{className:fX.note,children:[String(i),` `,n,i===1?``:`s`,` with no spend.`]})]})},qX=({series:e})=>{let[t,n]=(0,H.useState)(null),{bars:r,maxUsd:i,unit:a}=e,o=r.find(e=>e.key===t)??null,s=zX(r),c=o??s,l=r.at(-1)?.key,u=a===`day`?`Spend per day`:`Spend per week`,d=a===`day`?``:`week of `,f=s===void 0?u:`${u}, ${String(r.length)} ${a}s. The peak was ${FX(s.costUsd,s.partial===!0)} ${a===`day`?`on`:`in the week of`} ${s.key}${r.some(e=>e.partial===!0)?`, some ${a}s partial`:``}.`;return(0,K.jsxs)(`section`,{"aria-label":u,className:fX.section,children:[(0,K.jsxs)(`div`,{className:fX.chartHead,children:[(0,K.jsx)(`h3`,{className:fX.heading,children:u}),c===void 0?null:(0,K.jsxs)(`p`,{className:fX.readout,children:[o===null?`Peak: `:``,d,c.key,c.key===l?` so far`:``,` ·`,` `,(0,K.jsx)(MM,{partial:c.partial===!0,text:MX(c.costUsd)}),(c.tokens??0)>0?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(NM,{count:c.tokens??0})]}):null,` `,`· `,BX(c.sessions)]})]}),(0,K.jsx)(`div`,{"aria-label":f,className:fX.chart,onPointerLeave:()=>{n(null)},role:`img`,children:r.map(e=>(0,K.jsx)(`div`,{className:fX.column,"data-partial":e.key===l?``:void 0,"data-pointed":e.key===o?.key?``:void 0,onPointerEnter:()=>{n(e.key)},children:e.costUsd===0&&e.partial!==!0?null:(0,K.jsx)(`div`,{className:fX.bar,style:{height:`${String(Math.max(VX,i===0?0:e.costUsd/i*100))}%`}})},e.key))}),(0,K.jsx)(GX,{bars:r}),(0,K.jsx)(KX,{series:e})]})},JX=10,YX=({title:e,label:t,groups:n,total:r,nameOf:i,moreCommand:a})=>{let o=n.length-JX,s=n.slice(0,JX),c=NX(s.map(e=>e.costUsd)),l=s.some(e=>(e.tokens??0)>0);return(0,K.jsxs)(`section`,{"aria-label":e,className:fX.section,children:[(0,K.jsx)(`h3`,{className:fX.heading,children:e}),(0,K.jsxs)(`table`,{className:fX.table,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`col`,children:t}),(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Cost`}),l?(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Tokens`}):null,(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Share`}),(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`Sessions`}),(0,K.jsx)(`th`,{className:fX.number,scope:`col`,children:`From cache`})]})}),(0,K.jsx)(`tbody`,{children:s.map(e=>(0,K.jsxs)(`tr`,{children:[(0,K.jsxs)(`th`,{className:fX.name,scope:`row`,title:e.key,children:[i?.(e.key)??e.key,i===void 0?null:(0,K.jsx)(`span`,{className:fX.path,children:e.key})]}),(0,K.jsx)(`td`,{className:fX.number,children:(0,K.jsx)(MM,{partial:e.partial===!0,text:c(e.costUsd)})}),l?(0,K.jsx)(`td`,{className:fX.number,children:PX(e.tokens??0)}):null,(0,K.jsx)(`td`,{className:fX.number,children:IX(r===0?0:e.costUsd/r)}),(0,K.jsx)(`td`,{className:fX.number,children:e.sessions}),(0,K.jsx)(`td`,{className:fX.number,children:IX(e.cacheHitRate)})]},e.key))})]}),o>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:fX.note,children:[`And `,o,` more that cost less. This lists them all:`]}),(0,K.jsx)(lC,{command:a})]}):null]})},XX=({report:e})=>{let{totals:t}=e,n=t.inputTokens+t.cacheReadTokens+t.cacheWriteTokens,r=[[`Spend`,(0,K.jsx)(MM,{focusable:!0,partial:t.partial===!0,text:MX(t.costUsd)},`spend`)],[`Runs with sessions`,String(t.runs)],[`Sessions`,String(t.sessions)],[`Prompt tokens`,PX(n)],[`Output tokens`,PX(t.outputTokens)],[`From cache`,IX(t.cacheHitRate)],...t.tokens===void 0||t.tokens===0?[]:[[`Tokens counted`,PX(t.tokens)]]];return(0,K.jsx)(`dl`,{className:fX.totals,children:r.map(([e,t])=>(0,K.jsxs)(`div`,{className:fX.total,children:[(0,K.jsx)(`dt`,{children:e===`Tokens counted`?(0,K.jsx)(RM,{}):e===`Prompt tokens`?(0,K.jsx)(LM,{}):e}),(0,K.jsx)(`dd`,{children:t})]},e))})},ZX=({report:e,since:t,now:n,period:r,everyProject:i,projectName:a})=>{let o=(0,H.useMemo)(()=>jX(e,t,n),[e,t,n]),s=e.totals.costUsd,c=e=>CX(i,r,e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(vX,{limits:e.limits}),(0,K.jsxs)(`div`,{className:fX.overview,children:[(0,K.jsx)(XX,{report:e}),e.hints.length===0?null:(0,K.jsxs)(`section`,{"aria-label":`Worth a look`,className:fX.hintsSection,children:[(0,K.jsx)(`h3`,{className:fX.heading,children:`Worth a look`}),(0,K.jsx)(`ul`,{className:fX.hints,children:e.hints.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(J,{text:e.message})},e.code))})]}),(0,K.jsx)(`div`,{className:fX.chartArea,children:(0,K.jsx)(qX,{series:o})})]}),(0,K.jsxs)(`div`,{className:fX.breakdowns,children:[i?(0,K.jsx)(YX,{groups:e.groups.project,label:`Project`,moreCommand:c(`project`),nameOf:a,title:`By project`,total:s}):null,(0,K.jsx)(YX,{groups:e.groups.workflow,label:`Workflow`,moreCommand:c(`workflow`),title:`By workflow`,total:s}),(0,K.jsx)(YX,{groups:e.groups.model,label:`Model`,moreCommand:c(`model`),title:`By model`,total:s}),(0,K.jsx)(YX,{groups:e.groups.node,label:`Node`,moreCommand:c(`node`),title:`Costliest nodes`,total:s})]}),(0,K.jsxs)(`p`,{className:fX.note,children:[`Costs are Claude Code's own estimates. On a subscription they are not what you are billed.`,e.totals.partial===!0?` Dollars miss sessions on drivers with no price; tokens count all of them.`:``,` `,`On a terminal:`]}),(0,K.jsx)(lC,{command:c()})]})},QX=()=>{let e=sb(),t=yb(e.usage.state),n=yb(e.runs),r=yb(e.projects.state),i=yb(e.usageFilter),a=i.since??`30d`,{project:o,workflow:s,until:c}=i,[l,u]=(0,H.useState)(0),d=lU(t),f=(0,H.useRef)(null),p=vb(e.runs,e=>e?.filter(e=>e.live!==`running`&&e.live!==`paused`).length??0);(0,H.useEffect)(()=>{e.projects.load()},[e]),(0,H.useEffect)(()=>{let t=Date.now(),n=SX(a,t);e.usage.load({now:t,period:a,query:{...o===void 0?{}:{project:o},...s===void 0?{}:{workflow:s},...n===void 0?{}:{since:n},...c===void 0?{}:{until:c}}})},[e,o,s,a,c,p,l]);let m=(0,H.useMemo)(()=>DU(r.status===`ready`?r.data:[],n??[]),[r,n]),h=(0,H.useMemo)(()=>m.filter(e=>e.value!==`all`),[m]),g=o===void 0||o===`all`,_=t.status===`failed`&&t.code===400;return(0,K.jsxs)(`div`,{className:fX.panel,children:[(0,K.jsx)(`div`,{className:fX.tools,children:(0,K.jsx)(`div`,{className:fX.filter,children:(0,K.jsx)(xH,{busy:t.status===`loading`,defaults:{since:`30d`},error:t.status===`failed`&&_?{message:t.error}:null,list:`usage`,onChange:t=>{e.usageFilter.setValue(t)},shown:d?.data.totals.sessions??null,suggestions:{project:h},values:i})})}),(0,K.jsxs)(`section`,{"aria-busy":t.status===`loading`,"aria-label":`Usage report`,className:fX.body,ref:f,tabIndex:0,children:[t.status===`failed`&&!_?(0,K.jsx)(RX,{command:CX(g,a),error:t.error,retry:()=>{f.current?.focus(),u(l+1)}}):null,d===void 0?t.status===`failed`?null:(0,K.jsx)(`p`,{className:fX.note,children:`Reading usage…`}):d.data.totals.sessions===0?(0,K.jsx)(LX,{limits:d.data.limits,onClear:()=>{e.usageFilter.setValue({})},period:d.arg.period,values:i}):(0,K.jsx)(ZX,{everyProject:d.arg.query.project===void 0||d.arg.query.project===`all`,now:d.arg.now,period:d.arg.period,projectName:e=>m.find(t=>t.value===e)?.label??TU(e),report:d.data,since:d.arg.query.since})]})]})},$X=(e,t)=>`${String(e)} ${t}${e===1?``:t.endsWith(`h`)?`es`:`s`}`,eZ=e=>({worktrees:e.filter(e=>e.path!==null).length,branches:e.filter(e=>e.path===null).length}),tZ=` without a worktree`,nZ=e=>{let{worktrees:t,branches:n}=eZ(e);return[...t>0||n===0?[$X(t,`worktree`)]:[],...n>0?[`${$X(n,`branch`)}${t>0?tZ:``}`]:[]].join(` · `)},rZ=(e,t,n)=>e===null?n?`the worktrees couldn't be read`:`reading worktrees`:e.some(e=>e.items.some(e=>e.state===`merged`))?null:t?`nothing merged into the current branch`:`nothing merged in these projects`,iZ=e=>[e.root,...e.error===void 0?[e.head===null?`detached HEAD`:`current branch ${e.head}`]:[],...e.items.length===0?[]:[nZ(e.items)]],aZ=e=>[{text:`run ${e.runId}`,risk:!1},{text:e.nodeId,risk:!1},...e.path===null?[]:[{text:e.path,risk:!1}],...e.parts,...e.cleanKeeps===void 0?[]:[{text:`clean keeps it: ${e.cleanKeeps}`,risk:!1}]],oZ=e=>e.run.known?`Open run ${e.runId} at ${e.nodeId}`:`Open run ${e.runId}: it isn't in Ork's records`,sZ=e=>{let t=`${e.remove.label.replace(`…`,``)} ${e.label}…`;return e.remove.refusal===void 0?t:`${t}: ${e.remove.refusal}`},cZ=(e,t,n,r)=>`cd ${Yk(e)} && ork worktrees remove ${Yk(t)}${n?` --branch`:``}${r?` --force`:``}`,lZ=e=>e.path===null?`branch`:e.state===`detached`||e.branch===void 0?`detached`:`worktree`,uZ=e=>({branch:`Delete branch \`${e.label}\``,detached:`Remove the worktree of \`${e.label}\``,worktree:`Remove \`${e.label}\``})[lZ(e)],dZ=(e,t)=>{let n=lZ(e),r=n===`branch`?`It has no worktree. Deletes the branch from \`${t}\`.`:n===`detached`?`Removes the detached worktree. It has no branch of Ork's.`:e.missing?`Its folder is gone. Removing it drops git's record of the worktree. The branch stays unless you delete it too.`:`Removes its worktree. The branch stays unless you delete it too.`;return e.checkedOut===void 0?r:`${r} It's on \`${e.checkedOut}\`, the workflow's own branch, which Ork never deletes; removing the worktree loses nothing committed.`},fZ=(e,t)=>e.merged?`It's merged into \`${t}\`.`:`It has ${$X(e.ahead,`commit`)} not merged into \`${t}\`; deleting it loses them.`,pZ=e=>e.force?`Continue…`:e.removeWorktree&&e.deleteBranch?`Remove worktree and branch`:e.deleteBranch?`Delete branch`:e.prunes?`Prune`:`Remove worktree`,mZ=e=>{if(!e.force)return null;let{losing:t}=e;if(t.changes.length>0)return`It has uncommitted changes; the next step shows what's lost.`;let n=$X(t.commits.length+t.more.commits,`commit`);return t.commitsOn===`no branch`?`It holds ${n} on no branch; the next step shows them.`:`Deleting the branch loses ${n}; the next step shows them.`},hZ=(e,t)=>t.removeWorktree&&t.deleteBranch?`Removed ${e.label}'s worktree and deleted its branch.`:t.deleteBranch?`Deleted branch ${e.label}.`:t.prunes?`Pruned ${e.label}'s missing worktree.`:`Removed ${e.label}'s worktree.`,gZ=e=>[...e.losing.changes.length>0?[`Uncommitted changes can't be recovered.`]:[],...e.losing.commits.length>0?[`Deleted commits stay only in git's reflog, until it expires.`]:[]].join(` `),_Z=(e,t)=>`cd ${Yk(e)} && ork worktrees clean${t?` --branches`:``}`,vZ=`[data-worktree-row]`,yZ=(e,t)=>[...e?.querySelectorAll(vZ)??[]].findIndex(e=>e.dataset.worktreeRow===t),bZ=(e,t)=>{let n=sb(),r=(0,H.use)(wU),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(new Set),u=(0,H.useRef)(`back`),d=(0,H.useRef)(null),f=(0,H.useRef)(0),p=(0,H.useMemo)(()=>({openRun:e=>{IJ(n,r,e.runId,e.nodeId)},remove:(t,n)=>{u.current=`back`,a({kind:`remove`,row:t,project:n,target:{project:n.root,key:t.key},index:yZ(e.current,t.key),id:f.current+1}),f.current+=1,s(!0)}}),[n,r,e]),m=t=>{let n=e.current?.querySelectorAll(vZ)??[];return n[Math.min(t,n.length-1)]?.querySelector(`[data-act="remove"]`)??e.current?.querySelector(`[data-empty-title]`)??e.current??!1};return{opened:i,open:o,gone:c,rowActs:p,cleanButton:d,openClean:()=>{f.current+=1,a({kind:`clean`,id:f.current}),s(!0)},close:()=>{s(!1)},removed:(e,n,i,a)=>{r?.announce(hZ(e,i)),u.current=a,l(t=>new Set([...t,`${n.root}|${e.key}`])),s(!1),t().finally(()=>{l(new Set)})},removeFocus:()=>typeof u.current==`number`?m(u.current):u.current===`back`,cleanClosed:e=>{e||r?.announce(`Nothing was removed.`),s(!1)},cleanFocus:()=>d.current??!0,openRemovedRun:e=>{u.current=`run`,s(!1),IJ(n,r,e.runId,e.nodeId)}}},xZ=(e,t)=>({...e,name:t}),SZ=()=>{let e=sb(),t=yb(e.worktrees.state),n=yb(e.worktreesFilter),r=yb(e.runs),i=yb(e.projects.state),a=(0,H.useRef)(0),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(r),l=JSON.stringify(n),u=(0,H.useCallback)(()=>{if(o.current?.key===l)return o.current.reading;a.current=Date.now();let t=e.worktrees.load(QV(n)).finally(()=>{o.current?.reading===t&&(o.current=null)});return o.current={key:l,reading:t},t},[e,n,l]);(0,H.useEffect)(()=>(u(),e.projects.state.getValue().status===`idle`&&e.projects.load(),()=>{s.current!==null&&clearTimeout(s.current),s.current=null}),[u,e]),(0,H.useEffect)(()=>{if(c.current===r||(c.current=r,s.current!==null))return;let e=Math.max(0,a.current+RJ-Date.now());s.current=setTimeout(()=>{s.current=null,u()},e)},[r,u]);let d=lU(t)?.data.projects??null,f=DU(lU(i)?.data??[],[...r??[],...(d??[]).map(e=>({project:e.root}))]),p=e=>f.find(t=>t.value===e)?.label??e,m=(d??[]).map(e=>xZ(e,p(e.root))),h=f.flatMap(e=>m.filter(t=>t.root===e.value)),g=d===null?null:h,_=lU(i)?.data??[],v=f.filter(e=>e.value!==`all`).map(e=>({value:_.find(t=>t.root===e.value)?.id??e.value,label:e.label}));return{read:t,refusal:t.status===`failed`?nH(`worktrees`,t.error):null,known:Math.max(_.length,d?.length??0),shown:g,filter:n,projectSuggestions:v,load:u,setFilter:t=>{e.worktreesFilter.setValue(t)}}},CZ={panel:`_panel_d8l2g_10`,tools:`_tools_d8l2g_31`,card:`_card_d8l2g_32`,count:`_count_d8l2g_55`,head:`_head_d8l2g_65`,name:`_name_d8l2g_74`,headMeta:`_headMeta_d8l2g_83`,list:`_list_d8l2g_95`,row:`_row_d8l2g_101`,rowName:`_rowName_d8l2g_132`,badge:`_badge_d8l2g_144`,meta:`_meta_d8l2g_148`,risk:`_risk_d8l2g_166`,actions:`_actions_d8l2g_174`,note:`_note_d8l2g_184`,message:`_message_d8l2g_185`,alert:`_alert_d8l2g_194`,alertIcon:`_alertIcon_d8l2g_207`,facts:`_facts_d8l2g_214`,factName:`_factName_d8l2g_228`,caption:`_caption_d8l2g_229`,factValue:`_factValue_d8l2g_250`,step:`_step_d8l2g_266`,reason:`_reason_d8l2g_276`,section:`_section_d8l2g_282`,title:`_title_d8l2g_292`,result:`_result_d8l2g_301`,resultLine:`_resultLine_d8l2g_312`,foot:`_foot_d8l2g_324`},wZ={ArrowDown:e=>e+1,ArrowUp:e=>e-1,Home:()=>0,End:(e,t)=>t},TZ=e=>{let t=wZ[e.key],{target:n}=e;if(t===void 0||!(n instanceof HTMLElement))return;let r=n.dataset.act;if(r===void 0)return;let i=[...e.currentTarget.querySelectorAll(`[data-worktree-row] [data-act="${r}"]`)],a=i.length-1,o=i[Math.max(0,Math.min(a,t(i.indexOf(n),a)))];o!==void 0&&(e.preventDefault(),o.focus())},EZ=(0,H.memo)(({row:e,project:t,acts:n})=>{let r=(0,H.useId)(),i=(0,H.useId)(),a=cZ(t.root,e.key,e.path===null,!1),o=aZ(e),{refusal:s}=e.remove;return(0,K.jsxs)(`li`,{className:CZ.row,"data-worktree-row":e.key,children:[(0,K.jsxs)(`p`,{className:CZ.rowName,children:[e.label,(0,K.jsx)(Dk,{children:`, `})]}),(0,K.jsx)(`span`,{className:CZ.badge,children:(0,K.jsx)(hM,{state:e.state})}),(0,K.jsx)(`p`,{className:CZ.meta,id:r,children:o.map((e,t)=>(0,K.jsxs)(`span`,{className:e.risk?CZ.risk:void 0,children:[e.text,t<o.length-1?` ·`:``]},t))}),(0,K.jsx)(`span`,{hidden:!0,id:i,children:`CLI: ${a}`}),(0,K.jsxs)(`div`,{className:CZ.actions,children:[(0,K.jsx)(Y,{"aria-label":oZ(e),"data-act":`open`,disabled:!e.run.known,focusableWhenDisabled:!0,onClick:()=>{n.openRun(e)},tip:e.run.known?void 0:`It isn't in Ork's records.`,variant:`ghost`,children:`Open run`}),(0,K.jsx)(Y,{"aria-describedby":`${r} ${i}`,"aria-label":sZ(e),cli:a,"data-act":`remove`,disabled:s!==void 0,focusableWhenDisabled:!0,onClick:()=>{n.remove(e,t)},tip:s===void 0?void 0:`${s[0]?.toUpperCase()??``}${s.slice(1)}.`,children:e.remove.label})]})]})},(e,t)=>e.acts===t.acts&&e.project.root===t.project.root&&e.project.head===t.project.head&&JSON.stringify(e.row)===JSON.stringify(t.row)),DZ=({project:e,acts:t})=>{let n=(0,H.useId)();return(0,K.jsxs)(`section`,{"aria-labelledby":n,className:CZ.card,children:[(0,K.jsxs)(`div`,{className:CZ.head,children:[(0,K.jsx)(`h3`,{className:CZ.name,id:n,children:e.name}),(0,K.jsx)(`p`,{className:CZ.headMeta,children:iZ(e).join(` · `)})]}),e.error===void 0?(0,K.jsx)(`ul`,{"aria-label":`Worktrees in ${e.name}`,className:CZ.list,children:e.items.map(n=>(0,K.jsx)(EZ,{acts:t,project:e,row:n},n.key))}):(0,K.jsxs)(`p`,{className:CZ.alert,children:[(0,K.jsx)(`span`,{className:CZ.alertIcon,children:(0,K.jsx)($j,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Could not read ${e.name}'s worktrees: ${e.error}`})})]}),e.fix===void 0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:CZ.note,children:`If it moved, this points Ork at its new place:`}),(0,K.jsx)(lC,{command:e.fix})]})]})},OZ=e=>e.filter(e=>e.steps.length>0),kZ=e=>({worktrees:e.filter(e=>e.removeWorktree||e.prunes).length,branches:e.filter(e=>e.deleteBranch).length}),AZ=e=>e.removeWorktree||e.deleteBranch||e.prunes,jZ=e=>e.skip??`no worktree, branch kept`,MZ=e=>{let[t]=e;return e.length===1&&t!==void 0?`Clean merged worktrees in ${t.name}`:`Clean merged worktrees in ${$X(e.length,`project`)}`},NZ=e=>`Removes the worktrees of branches merged into ${e?`the project's current branch`:`each project's current branch`}, as the command below does. One with uncommitted changes, or checked out in the main checkout, is kept. Nothing is forced.`,PZ=e=>{let{worktrees:t,branches:n}=kZ(e),r=[...t>0?[`removes ${$X(t,`worktree`)}`]:[],...n>0?[`deletes ${$X(n,`branch`)}`]:[]].join(` and `),i=e.filter(e=>!AZ(e)||e.skip!==void 0),a=new Map;for(let e of i)a.set(jZ(e),(a.get(jZ(e))??0)+1);let o=i.length===0?``:`Keeps ${String(i.length)}: ${[...a].map(([e,t])=>`${e} (${String(t)})`).join(`; `)}.`;return[r===``?`Nothing to clean.`:`${r.charAt(0).toUpperCase()}${r.slice(1)}.`,o].filter(e=>e!==``).join(` `)},FZ=e=>{let{worktrees:t,branches:n}=kZ(e.flatMap(e=>e.steps));return t===0&&n===0?null:t===0?`Delete ${$X(n,`branch`)}`:n===0?`Remove ${$X(t,`worktree`)}`:`Remove ${$X(t,`worktree`)} and ${$X(n,`branch`)}`},IZ=e=>e.some(e=>e.error!==void 0)?`Cleaned in part`:`Cleaned`,LZ=`Reading the plan…`,RZ=`Nothing to show: the plan couldn't be read.`,zZ=({reading:e,failed:t,well:n})=>(0,K.jsx)(LY,{label:`Plan`,reading:e?LZ:void 0,ref:n,steady:!0,children:t?RZ:`Nothing to clean.`}),BZ=({checked:e,disabled:t,onChange:n})=>{let r=(0,H.useId)();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(FO,{checked:e,describedBy:r,disabled:t,label:`Also delete the merged branches`,onChange:n}),(0,K.jsx)(`p`,{className:CZ.note,id:r,children:`Only branches merged into the current branch, which git deletes without losing a commit.`})]})},VZ=({project:e,branches:t,reading:n,failed:r,well:i})=>{let a=(0,H.useId)(),o=e.head??`its detached HEAD`;return(0,K.jsxs)(`section`,{"aria-label":e.name,className:CZ.section,children:[(0,K.jsx)(`h3`,{className:CZ.name,children:e.name}),(0,K.jsx)(`p`,{className:CZ.headMeta,children:(0,K.jsx)(J,{text:`\`${e.root}\` · into \`${o}\``})}),(0,K.jsx)(`p`,{className:CZ.message,id:a,children:n||r?``:PZ(e.steps)}),(0,K.jsx)(`p`,{className:CZ.caption,children:`Plan`}),(0,K.jsxs)(LY,{describedBy:a,label:`Plan for ${e.name}`,reading:n?LZ:void 0,ref:i,steady:!0,children:[r?RZ:null,e.steps.map(e=>(0,K.jsxs)(`span`,{children:[e.line.text,e.line.reason===void 0?null:(0,K.jsx)(`span`,{className:CZ.reason,children:` (${e.line.reason})`}),`
108
+ `]},e.key))]}),(0,K.jsx)(`p`,{className:CZ.note,children:(0,K.jsx)(J,{text:`In \`${e.root}\`:`})}),(0,K.jsx)(lC,{command:_Z(e.root,t)})]})},HZ=({lines:e})=>(0,K.jsx)(`ul`,{className:CZ.result,children:e.map(e=>(0,K.jsxs)(`li`,{className:CZ.resultLine,children:[(0,K.jsx)(Xj,{}),e]},e))}),UZ=({results:e})=>{let t=(0,H.useRef)(null);return(0,H.useEffect)(()=>{t.current?.focus()},[]),(0,K.jsxs)(`div`,{className:CZ.step,children:[(0,K.jsx)(`h3`,{className:CZ.title,ref:t,tabIndex:-1,children:IZ(e)}),e.filter(e=>e.done.length>0||e.error!==void 0).map(e=>(0,K.jsxs)(`section`,{"aria-label":e.name,className:CZ.section,children:[(0,K.jsx)(`h4`,{className:CZ.name,children:e.name}),e.error===void 0?null:(0,K.jsxs)(`p`,{className:CZ.alert,children:[(0,K.jsx)(`span`,{className:CZ.alertIcon,children:(0,K.jsx)($j,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Stopped in ${e.name}: ${e.error}`})})]}),e.error===void 0||e.done.length===0?null:(0,K.jsx)(`p`,{className:CZ.note,children:`Done before it stopped:`}),(0,K.jsx)(HZ,{lines:e.done})]},e.root))]})},WZ=e=>{if(e.step!==`done`)return`plan`in e?e.plan:e.shown},GZ=(e,t,n)=>{let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)({step:`reading`}),s=(0,H.useRef)(0),c=(0,H.useCallback)(async n=>{s.current+=1;let r=s.current,i=await e.call(`worktreesCleanPlan`,{body:{...t===void 0?{}:{project:t},branches:n}});return r===s.current?i:null},[e,t]),l=(0,H.useCallback)(async(n,r)=>{s.current+=1;let i=s.current,a=await e.call(`worktreesCleanPlan`,{body:{...t===void 0?{}:{project:t},branches:n}});i===s.current&&o(a.ok?{step:`plan`,plan:a.data,changed:!1}:{step:`readFailed`,error:a.error,...r===void 0?{}:{shown:r}})},[e,t]);(0,H.useEffect)(()=>{l(!1)},[l]);let u=(e,t)=>{o(t===void 0?{step:`reading`}:{step:`reading`,shown:t}),l(e,t)},d=async i=>{o({step:`cleaning`,plan:i});let a=await e.call(`worktreesClean`,{body:{...t===void 0?{}:{project:t},branches:r,digest:i.digest}});if(a.ok){o({step:`done`,results:a.data.projects}),n();return}if(a.status!==409){o({step:`cleanFailed`,plan:i,error:a.error});return}let s=await c(r);s!==null&&(s.ok&&s.data.digest!==i.digest?o({step:`plan`,plan:s.data,changed:!0}):o({step:`cleanFailed`,plan:i,error:a.error}))};return{step:a,branches:r,setBranches:e=>{i(e),u(e,WZ(a))},clean:()=>{a.step===`plan`&&d(a.plan)},tryAgain:()=>{a.step===`cleanFailed`?d(a.plan):u(r,WZ(a))}}},KZ=e=>e.step===`readFailed`?`Could not read the plan: ${e.error}`:e.step===`cleanFailed`?`Could not clean: ${e.error}`:null,qZ=e=>e.step===`reading`?`Reading the plan…`:e.step===`readFailed`?`The plan couldn't be read; Try again reads it.`:null,JZ=e=>{let t=GZ(e.client,e.project,e.onCleaned),{step:n}=t,r=(0,H.useRef)(null),i=(0,H.useId)(),a=(0,H.useId)(),o=n.step===`cleaning`,s=n.step===`reading`,c=WZ(n),l=c===void 0?e.scope:OZ(c.projects),u=FZ(l),d=n.step===`plan`&&n.changed,f=c!==void 0&&!s&&u===null,p=n.step===`readFailed`&&c===void 0;(0,H.useEffect)(()=>{d&&r.current?.focus()},[d]),(0,H.useEffect)(()=>{if(s)return;let e=document.activeElement;(e===null||e===document.body||e.getAttribute(`role`)===`dialog`)&&r.current?.focus()},[s]);let m=()=>{o||e.onClose(n.step===`done`)};return(0,K.jsx)(PC,{description:NZ(e.project!==void 0),finalFocus:e.finalFocus,initialFocus:r,onOpenChange:e=>{e||m()},open:e.open,size:`wide`,title:MZ(l.length===0?e.scope:l),children:n.step===`done`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(UZ,{results:n.results}),(0,K.jsx)(FC,{children:(0,K.jsx)(Y,{onClick:m,children:`Close`})})]}):(0,K.jsxs)(K.Fragment,{children:[d?(0,K.jsx)(`p`,{role:`alert`,children:`The plan changed since you read it. Read it again before cleaning.`}):null,l.length===0?(0,K.jsx)(zZ,{failed:p,reading:s,well:r}):null,l.map((e,n)=>(0,K.jsx)(VZ,{branches:t.branches,failed:p,project:e,reading:s,well:n===0?r:void 0},e.root)),(0,K.jsx)(BZ,{checked:t.branches,disabled:o,onChange:t.setBranches}),(0,K.jsx)($q,{id:a,onTryAgain:t.tryAgain,takeFocus:n.step===`cleanFailed`?`always`:`ifLost`,words:KZ(n)}),(0,K.jsx)(GW,{id:i,why:qZ(n)}),(0,K.jsxs)(FC,{children:[(0,K.jsx)(Y,{disabled:o,focusableWhenDisabled:!0,onClick:m,variant:`ghost`,children:f?`Close`:`Cancel`}),f?null:(0,K.jsx)(Y,{"aria-describedby":`${i} ${a}`,disabled:n.step!==`plan`,focusableWhenDisabled:!0,onClick:t.clean,variant:`primary`,children:o?`Removing…`:u??`Remove worktrees`})]})]})})},YZ=(e,t,n)=>{let r=t?.parts.map(e=>e.text)??e.parts.map(e=>e.text.replace(/ not merged$/u,` not merged into ${n}`)),i=t?.merged??e.merged;return r.join(` · `)||(i?`merged into ${n}`:``)},XZ=`Nothing to show: its state couldn't be read.`,ZZ=({name:e,children:t})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:CZ.factName,children:e}),(0,K.jsx)(`dd`,{className:CZ.factValue,children:t})]}),QZ=({plan:e,label:t,reading:n})=>(0,K.jsx)(LY,{label:t,reading:n,steady:!0,children:e===void 0?XZ:(0,K.jsxs)(K.Fragment,{children:[e.line.text,e.line.reason===void 0?null:(0,K.jsx)(`span`,{className:CZ.reason,children:` (${e.line.reason})`})]})}),$Z=e=>{let{row:t,project:n,plan:r}=e,i=(0,H.useId)(),a=n.head??`the current branch`;return(0,K.jsxs)(`div`,{className:CZ.step,children:[(0,K.jsxs)(`dl`,{className:CZ.facts,children:[(0,K.jsx)(ZZ,{name:`Project`,children:`${n.name} ${n.root}`}),(0,K.jsxs)(ZZ,{name:`Run`,children:[`${t.runId} · ${t.nodeId}`,(0,K.jsx)(Y,{"aria-label":oZ(t),disabled:!t.run.known||e.busy,focusableWhenDisabled:!0,onClick:e.onOpenRun,tip:t.run.known?void 0:`It isn't in Ork's records.`,variant:`ghost`,children:`Open run`})]}),t.path===null?null:(0,K.jsx)(ZZ,{name:`Path`,children:t.path}),(0,K.jsx)(ZZ,{name:`State`,children:YZ(t,r,a)})]}),lZ(t)===`worktree`&&t.branch!==void 0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(FO,{checked:e.deleteBranch,describedBy:i,disabled:e.busy,label:`Also delete the branch ${t.branch}`,onChange:e.onDeleteBranch}),(0,K.jsx)(`p`,{className:CZ.note,id:i,children:(0,K.jsx)(J,{text:fZ(r??t,a)})})]}):null,(0,K.jsx)(`p`,{className:CZ.caption,children:`Plan`}),(0,K.jsx)(QZ,{label:`Plan`,plan:r,reading:e.reading?`Reading its state…`:void 0}),(0,K.jsx)(lC,{command:cZ(n.root,t.key,r?.deleteBranch??e.deleteBranch,r?.force??!1)})]})},eQ=({title:e,label:t,lines:n,more:r})=>(0,K.jsxs)(`div`,{className:CZ.section,children:[(0,K.jsx)(`p`,{className:CZ.caption,children:(0,K.jsx)(J,{text:`${e} · ${String(n.length+r)}`})}),(0,K.jsx)(LY,{label:t,short:!0,children:n.join(`
109
+ `)}),r>0?(0,K.jsx)(`p`,{className:CZ.note,children:`and ${String(r)} more`}):null]}),tQ=({row:e,plan:t,head:n,root:r})=>{let i=(0,H.useRef)(null);(0,H.useEffect)(()=>{i.current?.focus()},[]);let{losing:a}=t,o=`Commits not merged into ${n}`;return(0,K.jsxs)(`div`,{className:CZ.step,children:[(0,K.jsx)(`h3`,{className:CZ.title,ref:i,tabIndex:-1,children:`What's lost`}),a.changes.length===0?null:(0,K.jsx)(eQ,{label:`Uncommitted changes`,lines:a.changes,more:a.more.changes,title:`Uncommitted changes`}),a.commits.length===0?null:(0,K.jsx)(eQ,{label:a.commitsOn===`no branch`?`Commits on no branch`:o,lines:a.commits,more:a.more.commits,title:a.commitsOn===`no branch`?`Commits on no branch`:`Commits not merged into \`${n}\``}),(0,K.jsx)(`p`,{className:CZ.note,children:gZ(t)}),(0,K.jsx)(lC,{command:cZ(r,e.key,t.deleteBranch,!0)})]})},nQ=e=>`plan`in e?e.plan:e.shown,rQ=e=>e.step===`lost`||(e.step===`removing`||e.step===`removeFailed`)&&e.from===`lost`,iQ=(e,t,n)=>{let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)({step:`reading`}),s=(0,H.useRef)(0),c=(0,H.useCallback)(async n=>{s.current+=1;let r=s.current,i=await e.call(`worktreeRemovePlan`,{body:{...t,deleteBranch:n}});return r===s.current?i:null},[e,t]),l=(0,H.useCallback)(async(n,r)=>{s.current+=1;let i=s.current,a=await e.call(`worktreeRemovePlan`,{body:{...t,deleteBranch:n}});i===s.current&&o(a.ok?{step:`choice`,plan:a.data,changed:!1}:{step:`readFailed`,error:a.error,...r===void 0?{}:{shown:r}})},[e,t]);(0,H.useEffect)(()=>{l(!1)},[l]);let u=(e,t)=>{o(t===void 0?{step:`reading`}:{step:`reading`,shown:t}),l(e,t)},d=async(i,a)=>{o({step:`removing`,plan:i,from:a});let s=await e.call(`worktreeRemove`,{body:{...t,deleteBranch:r,force:i.force,digest:i.digest}});if(s.ok){n(i);return}if(s.status!==409){o({step:`removeFailed`,plan:i,from:a,error:s.error});return}let l=await c(r);l!==null&&(l.ok&&l.data.digest!==i.digest?o({step:`choice`,plan:l.data,changed:!0}):o({step:`removeFailed`,plan:i,from:a,error:s.error}))};return{step:a,deleteBranch:r,setDeleteBranch:e=>{i(e),u(e,nQ(a))},goOn:()=>{a.step===`choice`&&a.plan.force?o({step:`lost`,plan:a.plan}):a.step===`choice`&&d(a.plan,`choice`)},back:()=>{a.step===`lost`&&o({step:`choice`,plan:a.plan,changed:!1})},loseIt:()=>{a.step===`lost`&&d(a.plan,`lost`)},tryAgain:()=>{a.step===`removeFailed`?d(a.plan,a.from):u(r,nQ(a))}}},aQ=`It changed since you read it. Read it again before removing.`,oQ=(e,t)=>e.step===`readFailed`?`Could not read its state: ${e.error}`:e.step===`removeFailed`?`Could not remove ${t}: ${e.error}`:e.step===`choice`&&e.changed?aQ:null,sQ=e=>e.step===`reading`?`Reading its state…`:e.step===`readFailed`?`Its state couldn't be read; Try again reads it.`:e.step===`choice`?mZ(e.plan):null,cQ=({client:e,row:t,project:n,target:r,cancel:i,onBusy:a,onRemoved:o,onOpenRun:s,onClose:c})=>{let l=iQ(e,r,o),{step:u}=l,d=(0,H.useId)(),f=(0,H.useId)(),p=(0,H.useRef)(null),m=u.step===`removing`,h=nQ(u),g=rQ(u),_=u.step===`choice`&&u.changed;(0,H.useEffect)(()=>{a(m)},[m,a]);let v=(0,H.useRef)(!1);(0,H.useEffect)(()=>{let e=v.current&&!g;v.current=g,(_||e)&&p.current?.focus()},[_,g]);let y=oQ(u,t.label);return(0,K.jsxs)(K.Fragment,{children:[g&&h!==void 0?(0,K.jsx)(tQ,{head:n.head??`the current branch`,plan:h,root:n.root,row:t}):(0,K.jsx)($Z,{busy:m,deleteBranch:l.deleteBranch,onDeleteBranch:l.setDeleteBranch,onOpenRun:s,plan:h,project:n,reading:u.step===`reading`,row:t}),(0,K.jsx)($q,{id:f,onTryAgain:_?void 0:l.tryAgain,takeFocus:u.step===`removeFailed`?`always`:`ifLost`,words:y}),(0,K.jsx)(GW,{id:d,why:sQ(u)}),(0,K.jsxs)(`div`,{className:CZ.foot,children:[g?(0,K.jsx)(Y,{disabled:m,focusableWhenDisabled:!0,onClick:l.back,variant:`ghost`,children:`Back`}):null,(0,K.jsx)(Y,{disabled:m,focusableWhenDisabled:!0,onClick:c,ref:i,variant:`ghost`,children:`Cancel`}),g?(0,K.jsx)(Y,{"aria-describedby":f,disabled:u.step!==`lost`,focusableWhenDisabled:!0,onClick:l.loseIt,variant:`danger`,children:m?`Removing…`:`Remove and lose this work`}):(0,K.jsx)(Y,{"aria-describedby":`${d} ${f}`,disabled:u.step!==`choice`,focusableWhenDisabled:!0,onClick:l.goOn,ref:p,variant:h?.force===!0?`default`:`primary`,children:m?`Removing…`:h===void 0?`Remove worktree`:pZ(h)})]})]})},lQ=({open:e,client:t,row:n,project:r,target:i,finalFocus:a,onRemoved:o,onOpenRun:s,onClose:c})=>{let l=(0,H.useRef)(null),u=(0,H.useRef)(!1),d=()=>{u.current||c()};return(0,K.jsx)(PC,{description:dZ(n,r.root),finalFocus:a,initialFocus:l,onOpenChange:e=>{e||d()},open:e,size:`wide`,title:uZ(n),children:(0,K.jsx)(cQ,{cancel:l,client:t,onBusy:e=>{u.current=e},onClose:d,onOpenRun:s,onRemoved:o,project:r,row:n,target:i})})},uQ=({acts:e,project:t,merged:n,load:r})=>{let{client:i}=sb(),{opened:a,open:o}=e;return a?.kind===`remove`?(0,K.jsx)(lQ,{client:i,finalFocus:e.removeFocus,onClose:e.close,onOpenRun:()=>{e.openRemovedRun(a.row)},onRemoved:t=>{e.removed(a.row,a.project,t,a.index)},open:o,project:a.project,row:a.row,target:a.target},a.id):a?.kind===`clean`?(0,K.jsx)(JZ,{client:i,finalFocus:e.cleanFocus,onCleaned:()=>void r(),onClose:e.cleanClosed,open:o,project:t,scope:n.map(({root:e,name:t,head:n})=>({root:e,name:t,head:n,steps:[]}))},a.id):null},dQ=({filter:e,projects:t,items:n,updating:r,refusal:i,cleanBlocked:a,cleanButton:o,onFilter:s,onClean:c,onReload:l})=>(0,K.jsx)(`div`,{className:CZ.tools,children:(0,K.jsx)(xH,{busy:r,error:i,list:`worktrees`,onChange:s,shown:n===null?null:n.length,suggestions:{project:t},summary:n===null?``:nZ(n),tools:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Y,{"aria-label":a===null?void 0:`Clean merged…: ${a}`,cli:`ork worktrees clean`,disabled:a!==null,focusableWhenDisabled:!0,onClick:c,ref:o,tip:a===null?void 0:`Clean merged…: ${a}`,children:`Clean merged…`}),(0,K.jsx)(Y,{cli:`ork worktrees`,onClick:l,tip:`In the project's folder.`,variant:`ghost`,children:`Reload`})]}),values:e})}),fQ=({error:e})=>(0,K.jsxs)(`p`,{className:CZ.alert,role:`alert`,children:[(0,K.jsx)(`span`,{className:CZ.alertIcon,children:(0,K.jsx)(My,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Could not read worktrees: ${e}`})})]}),pQ=({projects:e})=>e===0?(0,K.jsxs)(dO,{cli:`ork register <path>`,focusable:!0,title:`No projects registered yet.`,children:[(0,K.jsx)(`p`,{children:`In a repository:`}),(0,K.jsx)(lC,{command:`ork init`}),(0,K.jsx)(`p`,{children:`Or from outside it:`})]}):(0,K.jsx)(dO,{cli:`ork worktrees`,focusable:!0,title:`No Ork worktrees or branches.`,children:(0,K.jsx)(J,{text:"A run with `worktree` nodes leaves a worktree and an `ork/` branch for each; they wait here until you remove them. In a terminal, in a project's folder:"})}),mQ=(e,t)=>({...e,items:e.items.filter(n=>!t.has(`${e.root}|${n.key}`))}),hQ={usage:{title:`Usage`,Icon:ky,Body:QX},context:{title:`Context`,Icon:jy,Body:wq},feedback:{title:`Feedback`,Icon:Ny,Body:QJ},worktrees:{title:`Worktrees`,Icon:Iy,Body:()=>{let e=SZ(),{read:t,shown:n,filter:r}=e,i=t.status===`failed`&&e.refusal===null,a=r.project!==void 0&&r.project!==`all`,{panel:o,onFocus:s}=zU((n??[]).flatMap(e=>e.items.map(t=>`${e.root}|${t.key}`)).join(`
110
+ `),`[data-worktree-row]`),c=bZ(o,e.load),l=(n??[]).map(e=>mQ(e,c.gone)),u=l.filter(e=>e.items.length>0||e.error!==void 0),d=l.length-u.length,f=l.filter(e=>e.items.some(e=>e.state===`merged`)),p=a?l[0]?.root??null:null;return(0,K.jsxs)(`div`,{"aria-label":`Worktrees`,className:CZ.panel,onFocus:s,onKeyDown:TZ,ref:o,role:`group`,tabIndex:-1,children:[(0,K.jsx)(dQ,{cleanBlocked:rZ(n===null?null:l,a,i),cleanButton:c.cleanButton,filter:r,items:n===null?null:l.flatMap(e=>e.items),onClean:c.openClean,onFilter:e.setFilter,onReload:()=>void e.load(),projects:e.projectSuggestions,refusal:e.refusal,updating:t.status===`loading`&&n!==null}),i?(0,K.jsx)(fQ,{error:t.error}):null,n===null&&!i?(0,K.jsx)(`p`,{className:CZ.message,children:`Reading worktrees…`}):null,n!==null&&u.length===0?ZV(r)?(0,K.jsx)(gH,{list:`worktrees`,onClear:()=>{e.setFilter({})},values:r}):(0,K.jsx)(pQ,{projects:e.known}):null,u.map(e=>(0,K.jsx)(DZ,{acts:c.rowActs,project:e},e.root)),!a&&u.length>0&&d>0?(0,K.jsx)(`p`,{className:CZ.note,children:`Nothing left in ${$X(d,`other project`)}.`}):null,(0,K.jsx)(uQ,{acts:c,load:e.load,merged:f,project:p??void 0})]})}},followups:{title:`Follow-ups`,Icon:Ly,Body:dX}},gQ={runs:{id:`runs`,title:`Runs`,Icon:Cy,Body:UK},monitor:{id:`monitor`,title:`Monitor`,Icon:wy,Body:SK},logs:{id:`logs`,title:`Logs`,Icon:Ty,Body:mW},decisions:{id:`decisions`,title:`Decisions`,Icon:Ey,Body:VU},chats:{id:`chats`,title:`Chats`,Icon:Dy,Body:GL},notifications:{id:`notifications`,title:`Notifications`,Icon:Oy,Body:FK},usage:{id:`usage`,...hQ.usage},builder:{id:`builder`,title:`Builder`,Icon:Ay,Body:rL},context:{id:`context`,...hQ.context},feedback:{id:`feedback`,...hQ.feedback},worktrees:{id:`worktrees`,...hQ.worktrees},followups:{id:`followups`,...hQ.followups}},_Q=Object.values(gQ),vQ=e=>e in gQ,yQ=e=>gQ[e],bQ=(e,t)=>e===void 0?void 0:sA(e,t).join(t?``:`+`),xQ=(e,t)=>{if(e.wide&&!e.open.includes(t))return e.minimized.includes(t)?`minimized`:`closed`},SQ=({workspace:e})=>{let t=yb(e.view),n=mA(),r=[..._Q.map(({id:r,title:i},a)=>({label:i,detail:xQ(t,r),hint:bQ(pA(a+1),n),onSelect:()=>{e.goTo(r)}})),`separator`,{label:`Reset layout`,onSelect:()=>{e.resetLayout()}}];return(0,K.jsx)(vj,{entries:r,trigger:(0,K.jsxs)(Y,{variant:`ghost`,children:[`Window`,(0,K.jsx)(ly,{})]})})},CQ=({workspace:e})=>(0,K.jsxs)(`header`,{className:_A.bar,children:[(0,K.jsxs)(`h1`,{className:_A.name,children:[(0,K.jsx)(`img`,{alt:`Ork`,className:_A.logoOnDark,src:`/ork-wordmark-small.svg`}),(0,K.jsx)(`img`,{alt:`Ork`,className:_A.logoOnLight,src:`/ork-wordmark-small-on-light.svg`})]}),(0,K.jsx)(SQ,{workspace:e}),(0,K.jsx)(`div`,{className:_A.spacer}),(0,K.jsx)(vA,{workspace:e}),(0,K.jsxs)(Y,{onClick:()=>{e.palette.setValue(!0)},variant:`ghost`,children:[(0,K.jsx)(gy,{}),`Commands`,(0,K.jsx)(i_,{keys:sA(dA.palette,mA())})]})]}),wQ,TQ=class{constructor(){}},EQ=class extends TQ{constructor(e,t,n,r){super(),this.viewId=e,this.groupId=t,this.panelId=n,this.tabGroupId=r}},DQ=class extends TQ{constructor(e,t){super(),this.viewId=e,this.paneId=t}},OQ=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)}};wQ=OQ,OQ.INSTANCE=new wQ;function kQ(){let e=OQ.getInstance();if(e.hasData(EQ.prototype))return e.getData(EQ.prototype)[0]}function AQ(){let e=OQ.getInstance();if(e.hasData(DQ.prototype))return e.getData(DQ.prototype)[0]}var jQ;(function(e){e.NONE={dispose:()=>{}};function t(e){return{dispose:()=>{e()}}}e.from=t})(jQ||={});var X=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())}},MQ=class{constructor(){this._disposable=jQ.NONE}get value(){return this._disposable===jQ.NONE?void 0:this._disposable}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&=(this._disposable.dispose(),jQ.NONE)}},NQ;(function(e){e.map=(e,t)=>n=>e(e=>n(t(e))),e.any=(...e)=>t=>{let n=e.map(e=>e(t));return{dispose:()=>{n.forEach(e=>{e.dispose()})}}}})(NQ||={});var PQ=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},FQ=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},IQ=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()}},LQ=class e{static create(){return new e(Error(`listener stacktrace`).stack??``)}constructor(e){this.value=e}print(){console.warn(`dockview: stacktrace`,this.value)}},RQ=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 RQ(t,e.ENABLE_TRACKING?LQ.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,LQ.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);else for(let n of t.slice())n.callback(e)}}pause(){let e={};return this._pauseTokens??=new Set,this._pauseTokens.add(e),jQ.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 IQ;function Q(e,t,n,r){return e.addEventListener(t,n,r),{dispose:()=>{e.removeEventListener(t,n,r)}}}var zQ=class{constructor(){this._onFired=new Z,this._currentFireCount=0,this._pending=new Set,this._queued=!1,this.onEvent=e=>{let t=this._currentFireCount;return this._onFired.event(n=>{this._currentFireCount>t&&e(n)})}}fire(e){this._currentFireCount++,this._pending.add(e),!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1;let e=this._pending;this._pending=new Set,this._onFired.fire(e)}))}dispose(){this._onFired.dispose()}},BQ=class extends X{constructor(e){super(),this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,VQ(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 VQ(e,t){let n=new Set,r=new ResizeObserver(e=>{let r=!1,i;i=requestAnimationFrame(()=>{r=!0,i!==void 0&&n.delete(i);let a=e[0];t(a)}),r||n.add(i)});return r.observe(e),{dispose:()=>{r.unobserve(e),r.disconnect();for(let e of n)cancelAnimationFrame(e);n.clear()}}}var HQ=(e,...t)=>{for(let n of t)e.classList.contains(n)&&e.classList.remove(n)},UQ=(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 WQ(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function GQ(e){return new KQ(e)}var KQ=class extends X{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=WQ(g$(e),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=()=>{WQ(g$(e),e)!==t&&(t?i():r())},this.addDisposables(Q(e,`focus`,r,!0)),this.addDisposables(Q(e,`blur`,i,!0))}refreshState(){this._refreshStateHandler()}},qQ=`dv-quasiPreventDefault`;function JQ(e){e[qQ]=!0}function YQ(e){return e[qQ]}function XQ(e,t){let n=e.composedPath?.call(e)??[];if(n.length>0)return t.some(e=>n.includes(e));let r=e.target;return r instanceof Node&&t.some(e=>e.contains(r))}function ZQ(e){let t=[],n=e.getRootNode();for(;n$(n);)t.push(n),n=n.host.getRootNode();return t}function QQ(e,t){let n=t?.getRootNode(),r=e,i=r.getRootNode();for(;i!==n&&n$(i);)r=i.host,i=r.getRootNode();return r}function $Q(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`,a&&n.setAttribute(`nonce`,a),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 e$(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 t$(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 n$(e){return!!e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&`host`in e&&!!e.host}function r$(e){let t=e.getRootNode();return t!==e&&typeof t.elementsFromPoint==`function`?t:e.ownerDocument??document}function i$(e,t){e.dataset.testid=t}function a$(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 o$(e=document){let t=a$([`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 s$(e=document){let t=e instanceof Document?e:e.ownerDocument,n=t?.documentElement;if(!t||!n)return{release:()=>void 0};let r=[`user-select`,`-webkit-user-select`],i=r.map(e=>[e,n.style.getPropertyValue(e)]);for(let e of r)n.style.setProperty(e,`none`);let a=e=>e.preventDefault();return t.addEventListener(`selectstart`,a),{release:()=>{t.removeEventListener(`selectstart`,a);for(let[e,t]of i)t?n.style.setProperty(e,t):n.style.removeProperty(e)}}}function c$(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`);)if(r.parentElement===null){let e=r.getRootNode();r=n$(e)?e.host:null}else r=r.parentElement;return n}var l$=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)}},u$=100;function d$(e,t){let n=e$(e),r=e$(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 f$(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()},u$),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 p$(e,t){let n;return new X(Q(e,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>{t()},u$)}),jQ.from(()=>clearTimeout(n)))}function m$(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 h$(e){let t=e;for(;t&&(t.style.zIndex===`auto`||t.style.zIndex===``);)t=t.parentElement;return t}function g$(e){let t=e.getRootNode(),n=t.nodeType===Node.DOCUMENT_NODE?t:e.ownerDocument;return n&&typeof n.hasFocus==`function`&&!n.hasFocus()?null:t.activeElement??null}function _$(e){let t=e.getRootNode();return n$(t)?t:(e.ownerDocument??document).body}function v$(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 y$(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){v$(a,r,i,o,s,`next`,e)}function s(e){v$(a,r,i,o,s,`throw`,e)}o(void 0)})}}function b$(e){let t=C$(e);if(t)throw t}var x$=new Set([`javascript:`,`data:`,`blob:`,`vbscript:`,`file:`]),S$=250;function C$(e,t=globalThis.location){let n;try{n=new URL(e,t.href)}catch{return Error(`dockview: invalid popout URL: ${e}`)}if(x$.has(n.protocol))return Error(`dockview: popout URL must not use the "${n.protocol}" protocol, which would run in the opener's context; got: ${e}`);if(n.protocol!==t.protocol||n.host!==t.host)return Error(`dockview: popout URL must be same-origin with the page (${t.protocol}//${t.host}); got: ${e}`)}var w$=class extends X{get window(){return this._window?.value??null}get failure(){return this._failure}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(),super.dispose()}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(){var e,t;let n=this._window;n&&(this._window=null,this._onWillClose.fire(),(e=(t=this.options).onWillClose)==null||e.call(t,{id:this.target,window:n.value}),n.disposable.dispose(),this._onDidClose.fire())}open(){var e=this;return y$(function*(){var t,n;if(e._window)throw Error(`instance of popout window is already open`);let r=`${e.options.url}`;b$(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 e._failure={reason:`blocked`},null;let o=new X;e._window={value:a,disposable:o},o.addDisposables(jQ.from(()=>{a.close()}),e.watchForClose(a),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=>{let n=n=>{e._failure={reason:`unscriptable`,error:n instanceof Error?n:Error(String(n))},e.close(),t(null)};try{a.addEventListener(`unload`,()=>{})}catch(e){n(e);return}o.addDisposables(e.onWillClose(()=>{e._failure??={reason:`closed`},t(null)})),a.addEventListener(`load`,()=>{try{var r;let n=a.document;n.title=document.title,n.body.appendChild(s),$Q(n,[...Array.from(globalThis.document.styleSheets),...globalThis.document.adoptedStyleSheets??[]],{nonce:e.options.nonce});let i=[];for(let t=(r=e.options).styleRoot?.call(r);n$(t);t=t.host.getRootNode())i.push(...Array.from(t.styleSheets??[]),...t.adoptedStyleSheets??[]);i.length>0&&$Q(n,i,{nonce:e.options.nonce}),Q(a,`beforeunload`,()=>{e.close()}),t(s)}catch(e){n(e)}})})})()}watchForClose(e){if(typeof e.closed!=`boolean`)return jQ.NONE;let t=setInterval(()=>{e.closed&&this.close()},S$);return jQ.from(()=>{clearInterval(t)})}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}};function T$(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function E$(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 D$(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function O$(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function k$(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return n}return-1}function A$(e,t){let n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)}var j$=(e,t,n)=>t>n?t:Math.min(n,Math.max(e,t)),M$=()=>{let e=1;return{next:()=>(e++).toString()}},N$=(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},P$=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){if(e!==this.visible){if(e){let e=this._cachedVisibleSize??0;this._cachedVisibleSize=void 0,this.size=j$(e,this.viewMinimumSize,this.viewMaximumSize)}else this._cachedVisibleSize=typeof t==`number`?t:this.size,this.size=0;this.container.classList.toggle(`visible`,e),this.view.setVisible&&this.view.setVisible(e)}}scale(e){this._cachedVisibleSize===void 0?this.size=j$(Math.round(this.size*e),this.minimumSize,this.maximumSize):this._cachedVisibleSize=Math.round(this._cachedVisibleSize*e)}dispose(){return this.disposable.dispose(),this.view}},F$=function(e){return e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`,e}({});function I$(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 L$;(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})(L$||={});var R$=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 proportionalLayout(){return this._proportionalLayout}set proportionalLayout(e){this._proportionalLayout!==e&&(this._proportionalLayout=e,e?this.saveProportions():this._proportions=void 0)}get orientation(){return this._orientation}set orientation(e){if(this._orientation===e)return;this._orientation=e;let t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,this.rescaleViews(this.size),HQ(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}get marginShare(){let e=0;for(let t of this.viewItems)t.visible&&e++;return this.marginShareFor(e)}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=N$(e,-1),u=N$(e+1,this.viewItems.length);if(i)for(let e of i)D$(l,e),D$(u,e);if(r)for(let e of r)O$(l,e),O$(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=j$(t,h,g),y=0,b=v;for(let e of l){let t=this.viewItems[e],r=n[e],i=j$(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=j$(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`?(HQ(this.element,`dv-separator-border`),this.element.style.removeProperty(`--dv-separator-border`)):(UQ(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=N$(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=j$(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=j$(t,e.minimumSize,e.maximumSize),e.size=t;let r=N$(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=L$.Distribute,n=this.viewItems.length,r){let i=document.createElement(`div`);i.className=`dv-view`,i.appendChild(e.element);let a;if(typeof t==`number`)a=t;else if(t.type===`split`){let e=this.viewItems[t.index];if(e){let t=Math.floor(e.size/2);a=e.size-t,e.size=t}else a=this.getViewSize(t.index)/2}else a=t.type===`invisible`?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;let o=e.onDidChange(e=>this.onDidChange(s,e.size)),s=new P$(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=o$(n),i=this._orientation===`HORIZONTAL`?t.clientX:t.clientY,a=k$(this.sashes,t=>t.container===e),o=this.viewItems.map(e=>e.size),s,c,l=N$(a,-1),u=N$(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=j$(n,t.minimumSize,t.maximumSize);let r=N$(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):L$.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||this.saveProportions(),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=j$(Math.round(i*e/t),r.minimumSize,r.maximumSize))}}else{let t=N$(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=N$(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)D$(r,e);for(let t of e)O$(r,t)}typeof e==`number`&&O$(r,e);for(let e=0;n!==0&&e<r.length;e++){let t=this.viewItems[r[e]],i=j$(t.size+n,t.minimumSize,t.maximumSize),a=i-t.size;n-=a,t.size=i}}rescaleViews(e){let t=0;for(let e of this.viewItems)t+=e.size;if(e<=0||t<=0)return;let n=e/t,r=0;for(let e of this.viewItems)e.scale(n),r+=e.size;this._contentSize=r}saveProportions(){if(!this.proportionalLayout)return;let e=0;for(let t of this.viewItems)e+=t.size;e>0&&(this._proportions=this.viewItems.map(t=>t.visible?t.size/e: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.marginShareFor(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`&&I$(r,`${n}px`,`0px`),this._orientation===`VERTICAL`&&I$(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(s,this._orthogonalSize)})}marginShareFor(e){let t=Math.max(0,e-1);return this._margin*t/Math.max(1,e)}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=N$(e,-1),a=N$(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()}},z$=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0}),B$=class extends X{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._orientation=t.orientation??`VERTICAL`,this.element=document.createElement(`div`),this.element.className=`dv-pane-container`,e.appendChild(this.element),this.splitview=new R$(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{let t=new X(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),n={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(n),e.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,n=this.splitview.length,r=!1){let i=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),a={pane:e,disposable:{dispose:()=>{i.dispose()}}};this.paneItems.splice(n,0,a),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,n,r)}getViewSize(e){return this.splitview.getViewSize(e)}getViewCachedVisibleSize(e){return this.splitview.getViewCachedVisibleSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t){if(e<0||e>=this.paneItems.length)throw Error(`Index out of bounds`);let n=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t?.skipDispose||(n.disposable.dispose(),n.pane.dispose()),n}moveView(e,t){if(e===t)return;let n=this.getViewCachedVisibleSize(e),r=this.removePane(e,{skipDispose:!0}),i=n===void 0?r.pane.size:L$.Invisible(n);r.disposable.dispose(),this.skipAnimation=!0;try{this.addPane(r.pane,i,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),UQ(this.element,`dv-animated`),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,HQ(this.element,`dv-animated`)},200))}dispose(){super.dispose(),this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},V$=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()}},H$=class e extends X{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,this._onDidInvalidateSizes.fire()}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)})}get proportionalLayout(){return this.splitview.proportionalLayout}set proportionalLayout(t){this.splitview.proportionalLayout=t,this.children.forEach(n=>{n instanceof e&&(n.proportionalLayout=t)})}constructor(e,t,n,r,i,a,o,s){if(super(),this.orientation=e,this.styles=n,this._childrenDisposable=jQ.NONE,this.children=[],this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new Z,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onDidInvalidateSizes=new Z,this.onDidInvalidateSizes=this._onDidInvalidateSizes.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 R$(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:n,margin:o})}else this.splitview=new R$(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._onDidInvalidateSizes,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 X(NQ.any(...this.children.map(e=>e.onDidChange))(e=>{this.invalidateCachedSizes(),this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,n)=>t instanceof e?new X(t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(n,e)}),t.onDidInvalidateSizes(()=>{this.invalidateCachedSizes()})):jQ.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}};function U$(e,t){if(e instanceof V$)return e;if(e instanceof H$)return U$(e.children[t?e.children.length-1:0],t);throw Error(`invalid node`)}function W$(e,t,n,r=1){let i=e.getChildCachedVisibleSize(t);return i===void 0?n:L$.Invisible(Math.round(i*r))}function G$(e,t,n){if(e instanceof H$){let r=new H$(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],i=n instanceof H$?n.orthogonalSize:n.size;r.addChild(G$(n,n.size,n.orthogonalSize),W$(e,t,i),0,!0)}return r}return new V$(e.view,e.orientation,n)}function K$(e,t,n){if(e instanceof H$){let r=new H$(Q$(e.orientation),e.proportionalLayout,e.styles,t,n,e.disabled,e.margin),i=0,a=e.size===0?1:t/e.size;for(let o=e.children.length-1;o>=0;o--){let s=e.children[o],c=s instanceof H$?s.orthogonalSize:s.size,l=e.size===0?0:Math.round(t*c/e.size);i+=l,o===0&&(l+=t-i),r.addChild(K$(s,n,l),W$(e,o,l,a),0,!0)}return r}return new V$(e.view,Q$(e.orientation),n)}function q$(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 J$(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);if(/\bdv-grid-view\b/.test(t.className))return[];let n=q$(t),r=t.parentElement.parentElement.parentElement;return[...J$(r),n]}function Y$(e,t,n){if(Z$(e,t)===X$(n)){let[e,r]=T$(t),i=r;return(n===`right`||n===`bottom`)&&(i+=1),[...e,i]}{let e=+(n===`right`||n===`bottom`);return[...t,e]}}function X$(e){return e===`top`||e===`bottom`?`VERTICAL`:`HORIZONTAL`}function Z$(e,t){return t.length%2==0?Q$(e):e}var Q$=e=>e===`HORIZONTAL`?`VERTICAL`:`HORIZONTAL`;function $$(e){return!!e.children}var e1=(e,t)=>{let n=t===`VERTICAL`?e.box.width:e.box.height;if(!$$(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=>e1(e,Q$(t)));return typeof e.cachedVisibleSize==`number`?{type:`branch`,data:r,size:e.cachedVisibleSize,visible:!1}:{type:`branch`,data:r,size:n}},t1=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=K$(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 H$&&(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=J$(e.element),[n,r]=this.getNode(t);if(!(r instanceof V$)||this._maximizedNode?.leaf===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),e1(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 V$?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 V$?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=J$(e.element));let n=this._onDidMaximizedNodeChange.pause();try{this.hasMaximizedView()&&this.exitMaximizedView();let n={root:e1(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 H$(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 V$))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,Q$(t),n,e.size),visible:r.visible}));i=new H$(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 V$(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 V$)return;e.element.remove();let n=e.removeChild(0);e.dispose(),n.dispose(),this._root=G$(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 H$(Q$(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(K$(t,t.orthogonalSize,t.size),L$.Distribute,0)}else this._root.addChild(e,L$.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 V$)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,Q$(t),a))}return{box:r,children:i,cachedVisibleSize:n}}progmaticSelect(e,t=!1){let[n,r]=this.getNode(e);if(!(r instanceof V$))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 U$(i.children[t?a-1:a+1],t)}return U$(this.root,t)}get proportionalLayout(){return this.root.proportionalLayout}set proportionalLayout(e){this.root.proportionalLayout=e}constructor(e,t,n,r,i){this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new MQ,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 H$(n,e,t,0,0,this.locked,this.margin)}isViewVisible(e){let[t,n]=T$(e),[,r]=this.getNode(t);if(!(r instanceof H$))throw TypeError(`Invalid from location`);return r.isChildVisible(n)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=T$(e),[,i]=this.getNode(n);if(!(i instanceof H$))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 H$))throw TypeError(`Invalid location`);r.moveChild(t,n)}addView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[r,i]=T$(n),[a,o]=this.getNode(r);if(o instanceof H$){let n=new V$(e,Q$(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=L$.Invisible(d)),n.removeChild(c).dispose();let f=new H$(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);n.addChild(f,o.size,c);let p=new V$(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 V$(e,n.orientation,o.size);f.addChild(m,t,i)}}remove(e,t){let n=J$(e.element);return this.removeView(n,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=T$(e),[i,a]=this.getNode(n);if(!(a instanceof H$))throw TypeError(`Invalid location`);let o=a.children[r];if(!(o instanceof V$))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 V$||(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 H$){let e=s.children.map(e=>e instanceof H$?e.orthogonalSize:e.size);p.splice(u,1,...e);for(let t=0;t<s.children.length;t++){let n=s.children[t],r=W$(s,t,e[t]);c.addChild(n,!f&&typeof r==`number`?L$.Invisible(r):r,u+t)}for(;s.children.length>0;)s.removeChild(0)}else{let e=new V$(s.view,Q$(s.orientation),s.size),t=f?s.orthogonalSize:L$.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 H$))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)}},n1=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0}),r1=class extends X{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(VQ(this._element,e=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!t$(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))}))}layoutFromElement(){if(this.disableResizing||!this._element.offsetParent||!t$(this._element))return;let e=Math.round(this._element.clientWidth),t=Math.round(this._element.clientHeight);e!==0&&t!==0&&this.layout(e,t)}},i1=M$();function a1(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`above`:return`top`;case`below`:return`bottom`;default:return`center`}}var o1=class extends r1{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=i1.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 zQ,this.onDidLayoutChange=NQ.map(this._bufferOnDidLayoutChange.onEvent,e=>({reasons:e})),this._onDidViewVisibilityChangeMicroTaskQueue=new zQ,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new l$(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this.gridview=new t1(!!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()}),jQ.from(()=>{this.element.remove()}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire(`geometry`)}),NQ.any(this.onDidAdd,this.onDidRemove)(()=>{this._bufferOnDidLayoutChange.fire(`structure`)}),this.onDidActiveChange(()=>{this._bufferOnDidLayoutChange.fire(`activePanel`)}),this.onDidMaximizedChange(()=>{this._bufferOnDidLayoutChange.fire(`geometry`)}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(J$(e.element),t),this._bufferOnDidLayoutChange.fire(`geometry`)}isVisible(e){return this.gridview.isViewVisible(J$(e.element))}updateOptions(e){`proportionalLayout`in e&&(this.gridview.proportionalLayout=e.proportionalLayout??!0),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??L$.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,L$.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=J$(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=J$(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 s1(e){"@babel/helpers - typeof";return s1=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},s1(e)}function c1(e,t){if(s1(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(s1(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l1(e){var t=c1(e,`string`);return s1(t)==`symbol`?t:t+``}function u1(e,t,n){return(t=l1(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d1(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 f1(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d1(Object(n),!0).forEach(function(t){u1(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d1(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function p1(e,t){return e===`center`?`Tab into ${t}`:`Split ${e} of ${t}`}function m1(e,t){return e===`center`?`docked into ${t}`:`split ${e} of ${t}`}var h1={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)=>`${p1(e,t)}. Arrows to change, Enter to confirm, Escape to go back.`,moveCommitted:(e,t,n)=>`${e} ${m1(n,t)}.`,moveCancelled:()=>`Move cancelled.`,moveNotAllowed:()=>`That move is not allowed.`,moveFloated:e=>`${e} floated.`};function g1(e){return e?f1(f1({},h1),e):h1}var _1=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},v1=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOver(){return this.component.onUnhandledDragOver}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},y1=class{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 onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},b1=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 dndCapabilities(){return this.component.dndCapabilities}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}get onWillClosePopoutWindow(){return this.component.onWillClosePopoutWindow}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 g1(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,t){this.component.withOrigin(`api`,()=>this.component.removePanel(e,t))}addGroup(e){return this.component.withOrigin(`api`,()=>this.component.addGroup(e))}serializeGroup(e){return this.component.serializeGroup(e)}addGroupFromJSON(e,t){return this.component.withOrigin(`api`,()=>this.component.addGroupFromJSON(e,t))}addPanelFromJSON(e,t){return this.component.withOrigin(`api`,()=>this.component.addPanelFromJSON(e,t))}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()}},x1=class extends X{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)}))}},S1={value:50,type:`percentage`},C1=100,w1=100;function T1(){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 E1(e,t,n,r){let i=r?.smallWidthBoundary??C1,a=r?.smallHeightBoundary??w1,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??S1;return _.type===`percentage`?g=j$(_.value,0,100)/100:((f||p)&&(g=j$(_.value,0,t)/t),(m||h)&&(g=j$(_.value,0,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 D1(e,t,n,r,i){let a=E1(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 O1(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 k1(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 A1(e){let t=E1(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),O1(u,m)?(k1(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 j1=class extends PQ{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 M1(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 N1(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 P1={value:20,type:`percentage`},F1=class e extends X{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 x1(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 j1({nativeEvent:t,position:f,edge:d.edge,edgeGroup:d.edgeGroup});if(this._onWillShowOverlay.fire(p),p.defaultPrevented)this.clearOwnOverlay();else if(this.markAsUsed(t),d.edge)this.clearOwnOverlay(),this._state=f,this._edge=!0;else{if(this._edge=!1,!i&&!this.targetElement){let e=T1();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)}else 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;A1({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})}else this.overlayElement&&D1(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??P1;return a.type===`percentage`?I1(e,t,n,r,i,a.value):L1(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=T1();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}};F1.USED_EVENT_ID=`__dockview_droptarget_event_is_used__`;function I1(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 L1(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 R1(e,t,n){UQ(t,`dv-dragged`),t.style.top=`-9999px`,t.style.position=`absolute`,(n?.owner?_$(n.owner):(n?.ownerDocument??document).body).appendChild(t),e.setDragImage(t,n?.x??0,n?.y??0),setTimeout(()=>{HQ(t,`dv-dragged`),t.remove()},0)}var z1=class e extends X{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=o$(n.ownerDocument??document),this._selectionShield=s$(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?r$(this._active.source):document).elementsFromPoint(e,t);for(let e of n){let t=e;for(;t;){let e=this._targetByElement.get(t);if(e&&!e.isHitTestTransparent?.call(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};try{if(t&&this._currentTarget)this._currentTarget.handleDrop(n);else{var r;(r=this._currentTarget)==null||r.handleDragLeave()}}finally{let e=this._onDragEndCallback,r=this._dataDisposable;this._teardown(),this._dataDisposable=void 0,setTimeout(()=>r?.dispose(),0),e?.(n,t),this._onDragEnd.fire(n)}}_teardown(){var e,t,n,r,i,a;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._selectionShield)==null||n.release(),this._selectionShield=void 0,(r=this._moveListener)==null||r.dispose(),(i=this._upListener)==null||i.dispose(),(a=this._cancelListener)==null||a.dispose(),this._moveListener=void 0,this._upListener=void 0,this._cancelListener=void 0}},B1={value:20,type:`percentage`},V1=class extends X{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),isHitTestTransparent:t.isHitTestTransparent};this.addDisposables(this._onDrop,this._onWillShowOverlay,z1.getInstance().registerTarget(n))}clearOverlay(){this._clearOwnOverlay()}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 j1({nativeEvent:e.pointerEvent,position:d,edge:u.edge,edgeGroup:u.edgeGroup});if(this._onWillShowOverlay.fire(f),f.defaultPrevented)this._clearOwnOverlay();else if(u.edge)this._clearOwnOverlay(),this._state=d,this._edge=!0;else if(this._edge=!1,r)A1({outlineElement:i,targetModel:r,quadrant:d,width:a,height:o,overlayModel:this.options.overlayModel,className:this.options.className}),this._state=d;else{if(!this._targetElement){let e=T1();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&&D1(this._overlayElement,d,a,o,this.options.overlayModel),this._state=d}}_onDragLeave(){var e;let t=(e=this.options).getOverrideTarget?.call(e);t?(this._state=void 0,t.clear()):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,edgeGroup:!!a.edgeGroup}:null}let s=this._calculateQuadrant(e,t,n,r);return s?{position:s,edge:!1,edgeGroup:!1}:null}_calculateQuadrant(e,t,n,r){let i=this.options.overlayModel?.activationSize??B1;return i.type===`percentage`?I1(this._acceptedTargetZonesSet,e,t,n,r,i.value):L1(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}},H1=5,U1=250,W1=8,G1=class extends X{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`||e.pointerType===`mouse`&&e.button!==0||(t=this.options).isCancelled?.call(t,e))}_onPointerDown(e){if(!this._shouldHandle(e))return;this._cancelPending(),this._selectionShield=s$(this.element.ownerDocument??document),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)??U1;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??H1,a=this.options.pressTolerance,o=(typeof a==`function`?a():a)??W1,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);this._armed?r>=i&&this._beginDrag(e):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,r;(e=this._selectionShield)==null||e.release(),this._selectionShield=void 0,this._pendingPointerId=void 0,this._armTimer!==void 0&&(clearTimeout(this._armTimer),this._armTimer=void 0),this._armed=!1,(t=this._pendingMoveListener)==null||t.dispose(),(n=this._pendingUpListener)==null||n.dispose(),(r=this._pendingCancelListener)==null||r.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();let a=i.defaultPrevented;if((t=(n=this.options).onDragStart)==null||t.call(n,i),i.defaultPrevented&&!a)return;let o=(r=this.options).createGhost?.call(r,i);z1.getInstance().beginDrag({pointerEvent:e,source:this.element,getData:()=>this.options.getData(i),ghost:o,onDragMove:this.options.onDragMove,onDragEnd:this.options.onDragEnd})}dispose(){this._cancelPending(),super.dispose()}},K1=class{constructor(e){this._disposed=!1,this.element=e.element,this.offsetX=e.offsetX??0,this.offsetY=e.offsetY??0;let t=e.owner?_$(e.owner):document.body,n;n$(t)&&typeof this.element.showPopover==`function`&&(n=this.element.ownerDocument.createElement(`div`),n.popover=`manual`,Object.assign(n.style,{inset:`auto`,margin:`0`,padding:`0`,border:`0`,background:`transparent`,color:`inherit`,overflow:`visible`}),n.appendChild(this.element),this.element.style.pointerEvents=`none`,this.element.style.transform=`none`),this.container=n??this.element;let r=this.container.style;r.position=`fixed`,r.left=`0px`,r.top=`0px`,r.pointerEvents=`none`,r.zIndex=`99999`,r.opacity=String(e.opacity??.8),r.willChange=`transform`,r.transform=`translate3d(${e.initialX-this.offsetX}px, ${e.initialY-this.offsetY}px, 0)`,t.appendChild(this.container),n?.showPopover()}update(e,t){this._disposed||(this.container.style.transform=`translate3d(${e-this.offsetX}px, ${t-this.offsetY}px, 0)`)}dispose(){this._disposed||(this._disposed=!0,this.element.remove(),this.container!==this.element&&this.container.remove())}},q1=class extends X{constructor(e,t){super(),this.el=e,this.opts=t,this._dataDisposable=new MQ,this._pointerEventsDisposable=new MQ,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}if((n=(r=this.opts).onDragStart)==null||n.call(r,e),e.defaultPrevented)return;let a=o$(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=(i=this.opts).createGhost?.call(i,e);if(o&&e.dataTransfer&&(R1(e.dataTransfer,o.element,{x:o.offsetX??0,y:o.offsetY??0,ownerDocument:this.el.ownerDocument??void 0,owner:this.el}),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`,``))}),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(){}},J1=class{constructor(){this.kind=`html5`}createDropTarget(e,t){return new F1(e,t)}createDragSource(e,t){return new q1(e,t)}},Y1=class{constructor(){this.kind=`pointer`}createDropTarget(e,t){return new V1(e,t)}createDragSource(e,t){let n=t.createGhost?n=>{let r=t.createGhost(n);if(!r)return;let i=new K1({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 G1(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}},X1=new J1,Z1=new Y1,Q1=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0}),$1=class extends FQ{constructor(e,t,n,r){super(),this.nativeEvent=e,this.position=t,this.getData=n,this.panel=r}},e0=class extends PQ{constructor(){super()}},t0=class extends X{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 MQ,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)}},n0=class extends t0{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new Z,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new Z({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new Z,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},r0=class extends n0{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new Z({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new Z({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new Z({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)==null||t.setExpanded(e)}get isExpanded(){return!!this._pane?.isExpanded()}},i0=class extends X{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=GQ(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 e0;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({params:this._params.params})}init(e){this._params=e,this.part=this.getComponent()}update(e){var t;this._params=f1(f1({},this._params),{},{params:f1(f1({},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()}},a0=class extends i0{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e==`number`?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e==`number`?e:1/0}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?``:`none`}constructor(e){super(e.id,e.component,new r0(e.id,e.component)),this._onDidChangeExpansionState=new Z({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add(`dv-pane`),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),Q(this.element,`mouseenter`,e=>{this.api._onMouseEnter.fire(e)}),Q(this.element,`mouseleave`,e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?UQ(this.header,`focused`):HQ(this.header,`focused`))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):(this._expandedSize=this._size,this.animationTimer=setTimeout(()=>{var e;(e=this.body)==null||e.remove()},200)),this._onDidChange.fire(e?{size:this._expandedSize??this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;let[n,r]=this.orientation===`HORIZONTAL`?[e,t]:[t,e];super.layout(n,r)}init(e){var t,n;super.init(e),typeof e.minimumBodySize==`number`&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize==`number`&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(f1(f1({},e),{},{api:this.api})),this.headerPart.init(f1(f1({},e),{},{api:this.api})),(t=this.body)==null||t.append(this.bodyPart.element),(n=this.header)==null||n.append(this.headerPart.element),typeof e.isExpanded==`boolean`&&this.setExpanded(e.isExpanded)}toJSON(){let e=this._params;return f1(f1({},super.toJSON()),{},{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement(`div`),this.header.tabIndex=0,this.header.className=`dv-pane-header`,this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement(`div`),this.body.className=`dv-pane-body`,this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,n;(t=this.bodyPart)==null||t.update(e),(n=this.headerPart)==null||n.update(e)},dispose:()=>{var e,t;(e=this.bodyPart)==null||e.dispose(),(t=this.headerPart)==null||t.dispose()}}}},o0=class extends a0{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new Z,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOver=new Z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOver),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;let e=this.id,t=this.accessor.id;this.header.draggable=!0;let n={getData:()=>(OQ.getInstance().setData([new DQ(t,e)],DQ.prototype),{dispose:()=>{OQ.getInstance().clearData(DQ.prototype)}})};this.html5DragSource=X1.createDragSource(this.header,n),this.pointerDragSource=Z1.createDragSource(this.header,n);let r={acceptedTargetZones:[`top`,`bottom`],overlayModel:{activationSize:{type:`percentage`,value:50}},canDisplayOverlay:(e,t)=>{let n=AQ();if(n&&n.paneId!==this.id&&n.viewId===this.accessor.id)return!0;let r=new $1(e,t,AQ,this);return this._onUnhandledDragOver.fire(r),r.isAccepted}};this.target=X1.createDropTarget(this.element,r),this.pointerTarget=Z1.createDropTarget(this.element,r),this.addDisposables(this._onDidDrop,this.html5DragSource,this.pointerDragSource,this.target,this.pointerTarget,this.target.onDrop(e=>{this.onDrop(e)}),this.pointerTarget.onDrop(e=>{this.onDrop(e)}))}onDrop(e){let t=AQ();if(t?.viewId!==this.accessor.id){this._onDidDrop.fire(f1(f1({},e),{},{panel:this,api:new v1(this.accessor),getData:AQ}));return}let n=this._params.containerApi,r=t.paneId,i=n.getPanel(r);if(!i){this._onDidDrop.fire(f1(f1({},e),{},{panel:this,getData:AQ,api:new v1(this.accessor)}));return}let a=n.panels,o=a.indexOf(i),s=n.panels.indexOf(this);(e.position===`left`||e.position===`top`)&&o<s&&s--,(e.position===`right`||e.position===`bottom`)&&(o>s&&s++,s=Math.min(a.length-1,s)),n.movePanel(o,s)}},s0=0,c0=()=>`dv-tabpanel-${s0++}`,l0=class extends X{get element(){return this._element}get dimensions(){return this._dimensions}constructor(e,t){var n,r,i;super(),this.accessor=e,this.group=t,this.disposable=new MQ,this._onDidFocus=new Z,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new Z,this.onDidBlur=this._onDidBlur.event,this._onDidDimensionsChange=new Z,this.onDidDimensionsChange=this._onDidDimensionsChange.event,this._element=document.createElement(`div`),this._element.className=`dv-content-container`,this._element.tabIndex=-1,this._element.id=c0(),this._element.setAttribute(`role`,`tabpanel`),this.addDisposables(this._onDidFocus,this._onDidBlur,this._onDidDimensionsChange);let a=()=>t.dropTargetContainer?.model,o=(e,t)=>this.group.canDisplayContentOverlay(e,t);this.dropTarget=new F1(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=Z1.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)})??jQ.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.group.isPanelActive(e);if(n||this.panel===e){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),n){var o,s;this._element.appendChild(e.view.content.element),(o=(s=e.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=GQ(a);this.focusTracker=e;let t=new X;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){(this._dimensions?.width!==e||this._dimensions.height!==t)&&(this._dimensions={width:e,height:t},this._onDidDimensionsChange.fire(this._dimensions))}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()}},u0=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},d0=()=>u0({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`}),f0=()=>u0({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`}),p0=()=>u0({width:`11`,height:`11`,viewbox:`0 0 24 15`,path:`M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z`}),m0=()=>u0({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`}),h0=500,g0=8,_0=class extends X{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??h0,n=this.options.tolerance??g0,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=>{XQ(e,[this.element])&&(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 v0(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 y0()?{html5:!1,pointer:!0,pointerHandlesMouse:!0}:{html5:!0,pointer:!0,pointerHandlesMouse:!1}}}function y0(){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 b0=0,x0=()=>`dv-tab-${b0++}`,S0=class extends X{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=OQ.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=v0(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=x0(),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=kQ();return this.accessor.id===n?.viewId?!(this.accessor.options.theme?.tabAnimation===`smooth`||n.tabGroupId&&n.groupId===this.group.id&&this.group.model.getTabGroupForPanel(this.panel.id)):this.group.model.canDisplayOverlay(e,t,`tab`)};this.dropTarget=X1.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:u,getOverrideTarget:()=>n.model.dropTargetContainer?.model}),this.pointerDropTarget=Z1.createDropTarget(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:this._buildOverlayModel(),canDisplayOverlay:u,getOverrideTarget:()=>n.model.dropTargetContainer?.model});let d={getData:()=>(this.panelTransfer.setData([new EQ(this.accessor.id,this.group.id,this.panel.id)],EQ.prototype),{dispose:()=>{this.panelTransfer.clearData(EQ.prototype)}}),createGhost:()=>({element:this._buildGhostElement(),offsetX:30,offsetY:-10}),onDragStart:e=>{this._onDragStart.fire(e),!e.defaultPrevented&&!(e instanceof PointerEvent)&&this.accessor.options.theme?.tabAnimation===`smooth`&&requestAnimationFrame(()=>{$(this.element,`dv-tab--dragging`,!0)})},onDragEnd:e=>{this._onDragEnd.fire(e)}};this.html5DragSource=X1.createDragSource(this._element,f1(f1({},d),{},{disabled:!c.html5})),this.pointerDragSource=Z1.createDragSource(this._element,f1(f1({},d),{},{disabled:!c.pointer,touchOnly:!c.pointerHandlesMouse,isCancelled:()=>!v0(this.accessor.options).pointer})),this.onWillShowOverlay=NQ.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 _0(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(f0()),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=v0(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}},C0=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}},w0=class extends X{get group(){return this.groupAccessor()}constructor(e){var t;super(),this.panelTransfer=OQ.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=v0(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 EQ(this.accessor.id,this.group.id,null)],EQ.prototype),{dispose:()=>{this.panelTransfer.clearData(EQ.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=X1.createDragSource(this._element,f1(f1({},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=Z1.createDragSource(this._element,f1(f1({},a),{},{disabled:!r.pointer,touchOnly:!r.pointerHandlesMouse,touchInitiationDelay:()=>o()?500:250,pressTolerance:()=>o()?1/0:8,isCancelled:()=>!v0(this.accessor.options).pointer||this.group.api.location.type===`edge`&&this.group.size===0,onDragStart:e=>{var t;let n=e.defaultPrevented;this._onDragStart.fire(e),e.defaultPrevented&&!n||(t=this.getFloatingOverlay())==null||t.cancelPendingDrag()}}));let s=new MQ,c=()=>{let e=this.getFloatingOverlay();s.value=e?e.onDidStartMoving(()=>{this.pointerDragSource.cancelPending()}):jQ.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=v0(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}},T0=class extends X{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&&JQ(e)},!0)),this.dragSource=new w0({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=kQ();return this.accessor.id===r?.viewId||t.model.canDisplayOverlay(e,n,`header_space`)};this.dropTarget=X1.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=Z1.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=NQ.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)})??jQ.NONE)}updateDragAndDropState(){this.dragSource.updateDragAndDropState()}},E0=class e extends X{get element(){return this._element}get orientation(){return this._orientation}set orientation(e){this._orientation!==e&&(this._scrollOffset=0,this._orientation=e,HQ(this._scrollbar,`dv-scrollbar-vertical`,`dv-scrollbar-horizontal`),e===`vertical`?UQ(this._scrollbar,`dv-scrollbar-vertical`):UQ(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()}),VQ(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()}),jQ.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=j$(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}};E0.MouseWheelSpeed=1;var D0=`dv-tabs-container--wrap`;function O0(e,t){return typeof e==`boolean`?e:!!e?.[t]}function k0(e){return typeof e==`boolean`?e:e?Object.values(e).some(Boolean):!1}var A0=class extends FQ{constructor(e,t,n,r,i){super(),this.nativeEvent=e,this.target=t,this.position=n,this.getData=r,this.group=i}},j0=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,transformFloatingGroupDrag:void 0,smartGuides:void 0,floatingGroupDragHandle:void 0,popoutUrl:void 0,nonce:void 0,defaultRenderer:void 0,defaultHeaderPosition:void 0,debug:void 0,locked:void 0,disableDnd:void 0,dndStrategy:void 0,className:void 0,noPanelsOverlay:void 0,closeEmptyGroups:void 0,groupIdGenerator:void 0,dndEdges:void 0,dropPositionResolver:void 0,dndCompass:void 0,dropSizing:void 0,theme:void 0,disableTabsOverflowList:void 0,overflow:void 0,scrollbars:void 0,getTabContextMenuItems:void 0,getTabGroupChipContextMenuItems:void 0,createTabGroupChipComponent:void 0,createGroupDragGhostComponent:void 0,dropOverlayModel:void 0,announcements:void 0,getAnnouncement:void 0,announcer:void 0,messages:void 0,keyboardNavigation:void 0,layoutHistory:void 0,autoHideEdgeGroups:void 0,dockToEdgeGroups:void 0,edgeGroupPeek:void 0,tabGroupColors:void 0,tabGroupAccent:void 0,pinnedTabs:void 0});function M0(e){return!!e.referencePanel}function N0(e){return!!e.referenceGroup}function P0(e){return!!e.referencePanel}function F0(e){return!!e.referenceGroup}var I0=[{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`}],L0=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}},R0;function z0(){return R0??=new L0(I0,!0),R0}function B0(e,t,n){let r=(n??z0()).resolveValue(t);r===void 0?e.style.removeProperty(`--dv-tab-group-color`):e.style.setProperty(`--dv-tab-group-color`,r)}function V0(e,t){return(t??z0()).resolveValue(e)}var H0=class extends X{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 _0(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){B0(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)}},U0=`dv-tab-group-chip-continuation`,W0=8,G0=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=U0,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(D0);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=V0(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-W0/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-W0/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}}},K0=class extends G0{_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=V0(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)}}},q0=class extends G0{applyShape(e,t,n,r,i,a,o,s){let c=V0(t.color,this._ctx.getColorPalette());r<=0||c===void 0?e.style.display=`none`:(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`))}},J0=new Map,Y0=class{get chipRenderers(){return this._chipRenderers}get groupUnderlines(){return this._indicator?.underlines??J0}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){let n=e?[`top`]:[`left`];t.dropTarget.setTargetZones(n),t.pointerDropTarget.setTargetZones(n)}}clearChipDropOverlays(){for(let[,n]of this._chipRenderers){var e,t;(e=n.dropTarget)==null||e.clearOverlay(),(t=n.pointerDropTarget)==null||t.clearOverlay()}}snapshotChipSizes(){let e=this._ctx.getDirection()===`vertical`,t=new Map;for(let[n,r]of this._chipRenderers){let i=r.chip.element.getBoundingClientRect();t.set(n,e?i.height:i.width)}return t}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=v0(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`?q0:K0;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=v0(this._ctx.accessor.options);e.element.draggable=n.html5;let r=OQ.getInstance(),i=()=>(r.setData([new EQ(this._ctx.accessor.id,this._ctx.group.id,null,t.id)],EQ.prototype),{dispose:()=>{r.clearData(EQ.prototype)}}),a=X1.createDragSource(e.element,{getData:i,disabled:!n.html5,isCancelled:()=>!v0(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(EQ.prototype)};e.element.addEventListener(`dragend`,o,{once:!0});let s=Z1.createDragSource(e.element,{getData:i,disabled:!n.pointer,touchOnly:!n.pointerHandlesMouse,isCancelled:()=>!v0(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 H0(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 H0?a.push(r.onContextMenu(o)):a.push(new _0(r.element,{onLongPress:o}),Q(r.element,`contextmenu`,o));let s={acceptedTargetZones:this._ctx.getDirection()===`vertical`?[`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=kQ();return this._ctx.accessor.id===n?.viewId?!(this._ctx.accessor.options.theme?.tabAnimation===`smooth`&&!n.tabGroupId):this._ctx.group.model.canDisplayOverlay(e,t,`tab`)}},c=X1.createDropTarget(r.element,s),l=Z1.createDropTarget(r.element,s),u=t=>{this._callbacks.onChipDrop(e,t)};a.push(c,c.onDrop(u),l,l.onDrop(u));let d=new X(...a);this._chipRenderers.set(e.id,{chip:r,html5DragSource:i.html5DragSource,pointerDragSource:i.pointerDragSource,dragSourcesDisposable:i.disposable,disposable:d,dropTarget:c,pointerDropTarget:l}),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),B0(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())}};function X0(e,t){return t===`vertical`?e.height:e.width}function Z0(e,t){return t===`vertical`?e.top:e.left}function Q0(e,t){return t===`vertical`?e.clientY:e.clientX}var $0=class extends X{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(D0)}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}_mainAxisSize(e){return X0(e,this._direction)}_mainAxisStart(e){return Z0(e,this._direction)}_mainAxisCoord(e,t){return Q0({clientX:e,clientY:t},this._direction)}get _gapMarginProperty(){return this._direction===`vertical`?`margin-top`:`margin-left`}getAverageTabSize(){if(this._tabs.length===0)return 0;let e=0;for(let t of this._tabs)e+=this._mainAxisSize(t.value.element.getBoundingClientRect());return e/this._tabs.length}handlePointerDragMove(e,t){let n=r$(this._tabsList).elementFromPoint(e,t);n&&(this._tabsList.contains(n)||this._extendedDropZone&&this._extendedDropZone.contains(n))?(this._pointerInsideTabsList=!0,this.processDragOver(e,t)):this._pointerInsideTabsList&&(this._pointerInsideTabsList=!1,this.processDragLeave(n))}handlePointerDragEnd(e){if(e&&this._animState&&this._animState.sourceIndex!==-1&&this._animState.currentInsertionIndex!==null&&this.isPointInsideTabsList(e.clientX,e.clientY)){let t=this._animState.sourceTabGroupId;if(t){let e=this._animState.currentInsertionIndex;this._animState=null,this.commitGroupMove(t,e)}else this.commitPointerReorder(e.pointerEvent)}this._pointerInsideTabsList=!1,this.resetDragAnimation()}isPointInsideTabsList(e,t){let n=r$(this._tabsList).elementFromPoint(e,t);return!!n&&this._tabsList.contains(n)}resolveTabDrop(e){let t=e.currentInsertionIndex;if(t===null)return null;let{sourceIndex:n,targetTabGroupId:r}=e,i=t-+(n!==-1&&n<t);return i===n&&r===(this.group.model.getTabGroupForPanel(e.sourceTabId)?.id??null)?null:{index:i,targetTabGroupId:r}}commitPointerReorder(e){let t=this._animState;if(t?.currentInsertionIndex==null)return;let n=this.resolveTabDrop(t);this._animState=null,this.clearWrapDropIndicator(),this.uncollapseSourceTab(t.sourceTabId),n&&this.host.fireDrop(f1({event:e},n))}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=kQ();e?.tabGroupId&&e.groupId!==this.group.id&&this._animState.sourceTabGroupId!==e.tabGroupId&&(this._animState=null)}_initAnimStateForExternalDrag(){let e=kQ();if(this.accessor.options.theme?.tabAnimation==="default"&&!e?.tabGroupId||!e||!(e.panelId||e.tabGroupId)||e.groupId===this.group.id)return!1;let t=this.getAverageTabSize();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(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.tabGroupId,sourceGroupPanelIds:n?new Set(n.panelIds):new Set,sourceChipSize:t,cursorOffsetFromDragStart:r/2,sourceGapSize:r,containerStart:this._mainAxisStart(this._tabsList.getBoundingClientRect())}}_makeTabDragAnimState(e,t){return{sourceTabId:e.panelId,sourceIndex:-1,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipSize:0,cursorOffsetFromDragStart:t/2,sourceGapSize:t,containerStart:this._mainAxisStart(this._tabsList.getBoundingClientRect())}}processDragLeave(e){this._animState&&(e&&this._tabsList.contains(e)||(e&&this._extendedDropZone?.contains(e)?(this.resetTabTransforms(),this._animState.currentInsertionIndex=null):this._voidContainer&&e&&(e===this._voidContainer||this._voidContainer.contains(e))||(this.resetTabTransforms(),this._animState.sourceIndex===-1?(this.clearHeaderAnchorOverlay(),this._animState=null):this._animState.currentInsertionIndex=null)))}clearHeaderAnchorOverlay(){var e;let t=this.group.model.dropTargetContainer,n=t?.renderedOutline;n&&![this._tabsList,this._voidContainer,this._extendedDropZone].some(e=>e?.contains(n))||t==null||(e=t.model)==null||e.clear()}handleDragOver(e){if(!this._animState)return;if(this._wrapMode&&!this._animState.sourceTabGroupId){this.handleWrappedDragOver(e.clientX,e.clientY??0);return}let t=this._mainAxisCoord(e.clientX,e.clientY??0),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.cursorOffsetFromDragStart-n.containerStart,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.chipSizes.get(c)??0;if(a+t>i){o??=e;break}a+=t}let l=n.tabPositions.get(s.panel.id),u=this._mainAxisSize(l??s.element.getBoundingClientRect());if(a+u/2<=i)a+=u,o=e+1;else{o??=e;break}}return o}_accumulatedSizeUpTo(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.chipSizes.get(s)??0);let c=n.tabPositions.get(o.panel.id);i+=this._mainAxisSize(c??o.element.getBoundingClientRect())}return i}_resolveInsertionAgainstTabGroups(e,t,n){let r=!!this._animState.sourceTabGroupId,i=this._accumulatedSizeUpTo(t,n);for(let n of this.group.model.getTabGroups()){let a=this._evaluateTabGroupForInsertion(n,e,t,i,r);if(a)return a.targetTabGroupId?a:this._keepSourceGroupAtOwnSlot(e,a.insertionIndex,i)??a}return this._keepSourceGroupAtOwnSlot(e,t,i)??{insertionIndex:t,targetTabGroupId:null}}_keepSourceGroupAtOwnSlot(e,t,n){let r=this._animState,i=r.sourceIndex;if(r.sourceGroupPanelIds||i===-1||t!==i&&t!==i+1)return null;let a=this.group.model.getTabGroups().find(e=>e.panelIds.includes(r.sourceTabId));if(!a)return null;if(a.panelIds[0]===r.sourceTabId){let t=r.chipSizes.get(a.id)??0;if(e<r.containerStart+n+t)return null}return{insertionIndex:t,targetTabGroupId:a.id}}_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.chipSizes.get(e.id)??0;if(a)return this._onlySourceBetween(n,i)?t>=(e.collapsed?o.containerStart+r+s/2:o.containerStart+r+s)?{insertionIndex:i,targetTabGroupId:e.id}:{insertionIndex:n,targetTabGroupId:null}:null;let c=o.containerStart+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._computeGapSize(),r=this._computeChipToShift(t);this._applyGapMargins(t,n,r,e)}_computeGapSize(){let e=this._animState;if(e.sourceTabGroupId&&e.sourceGroupPanelIds)return e.sourceGapSize;let t=e.tabPositions.get(e.sourceTabId);return t?this._mainAxisSize(t):this.getAverageTabSize()}_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){let r=this._gapMarginProperty;n?(e.style.transition=`none`,e.style.setProperty(r,t),e.getBoundingClientRect(),e.style.removeProperty(`transition`)):e.style.setProperty(r,t),$(e,this._shiftingClass(e),!0)}_clearMargin(e,t){let n=this._shiftingClass(e),r=this._gapMarginProperty,i=this._pendingMarginCleanups.get(e);if(i&&i(),t||!e.style.getPropertyValue(r))e.style.removeProperty(r),$(e,n,!1);else{e.style.setProperty(r,`0px`),$(e,n,!0);let t=()=>{e.style.removeProperty(r),$(e,n,!1),e.removeEventListener(`transitionend`,t),clearTimeout(i),this._pendingMarginCleanups.delete(e)},i=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.style.removeProperty(`margin-top`),$(e.chip.element,`dv-tab-group-chip--shifting`,!1);this._tabGroupManager.positionUnderlines()}commitGroupMove(e,t){let n=kQ();if(this._tabGroupManager.disposeChipDrag(e),this._tabGroupManager.clearChipDropOverlays(),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)})}},e2=class extends X{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 BQ(this._tabsList);this._observerDisposable.value=new X(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=jQ.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 X(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),HQ(this._tabsList,`dv-horizontal`,`dv-vertical`),e===`vertical`?UQ(this._tabsList,`dv-tabs-container-vertical`,`dv-vertical`):(HQ(this._tabsList,`dv-tabs-container-vertical`),UQ(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 MQ,this._pointerActivation=new MQ,this._scrollbar=null,this._tabs=[],this._overflowRefreshPending=!1,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 E0(this._tabsList),this._scrollbar.orientation=this.direction,this._element=this._scrollbar.element,this.addDisposables(this._scrollbar)),this._tabGroupManager=new Y0({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 $0(this);let r=Z1.createDropTarget(this._tabsList,{acceptedTargetZones:[`center`],canDisplayOverlay:()=>!1,isHitTestTransparent:()=>{let e=kQ();return e?.viewId!==this.accessor.id||e.groupId!==this.group.id||e.panelId===null&&!e.tabGroupId}});this.addDisposables(r,this._onOverflowTabsChange,this._observerDisposable,this._pointerActivation,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,this._reorder,z1.getInstance().onDragEnd(e=>{this._reorder.handlePointerDragEnd(e)}),z1.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=this._reorder.resolveTabDrop(n);if(this._reorder.uncollapseSourceTab(n.sourceTabId),!r){this.resetTabTransforms();return}let i=n.sourceIndex,a=this.snapshotTabPositions();this.resetTabTransforms(),this._onDrop.fire(f1({event:e},r)),this.runFlipAnimation(a,n.sourceTabId,i===-1,{from:Math.min(i,r.index),to:Math.max(i,r.index)})},!0),jQ.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(!v0(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 S0(e,this.accessor,this.group);n.setContent(e.view.tab),this._direction!==`horizontal`&&n.setDirection(this._direction);let r={value:n,disposable:new X(n.onDragStart(t=>{let r=t.defaultPrevented;if(this._onTabDragStart.fire({nativeEvent:t,panel:e}),(!t.defaultPrevented||r)&&this.accessor.options.theme?.tabAnimation===`smooth`){let t=X0(n.element.getBoundingClientRect(),this._direction),r=this._tabs.findIndex(e=>e.value===n);this._animState={sourceTabId:e.id,sourceIndex:r,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:null,sourceGroupPanelIds:null,sourceChipSize:0,cursorOffsetFromDragStart:t/2,sourceGapSize:t,containerStart:Z0(this._tabsList.getBoundingClientRect(),this._direction)},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})}else 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=kQ(),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 C0(e,{kind:`tab`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:kQ}))}))};this.addTab(r,t),this._scheduleOverflowRefresh(),this._tabGroupManager.positionAllChips(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipSizes=this._tabGroupManager.snapshotChipSizes(),this.applyDragOverTransforms())}delete(e){let t=this.indexOf(e);if(t===-1)return;this._animState?.sourceTabId===e&&(this.resetTabTransforms(),this._animState=null),this._tabGroupManager.cleanupTransition(e);let{value:n,disposable:r}=this._tabs.splice(t,1)[0];this._tabMap.delete(e),r.dispose(),n.dispose(),n.element.remove(),this._scheduleOverflowRefresh(),this._animState&&(this._animState.tabPositions=this.snapshotTabPositions(),this._animState.chipSizes=this._tabGroupManager.snapshotChipSizes(),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)}_scheduleOverflowRefresh(){!this._overflowRefreshPending&&this._showTabsOverflowControl&&(this._overflowRefreshPending=!0,queueMicrotask(()=>{if(this._overflowRefreshPending=!1,this.isDisposed||!this._showTabsOverflowControl)return;let e=this._tabsList,t=e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight;this.toggleDropdown({reset:!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&&!d$(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&&!d$(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&&!d$(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=X0(a,this._direction);for(let t of e.panelIds){let e=this._tabMap.get(t);e&&(o+=X0(e.value.element.getBoundingClientRect(),this._direction))}if(this._animState={sourceTabId:``,sourceIndex:i,tabPositions:this.snapshotTabPositions(),chipSizes:this._tabGroupManager.snapshotChipSizes(),currentInsertionIndex:null,targetTabGroupId:null,sourceTabGroupId:e.id,sourceGroupPanelIds:new Set(e.panelIds),sourceChipSize:X0(a,this._direction),cursorOffsetFromDragStart:Q0(n,this._direction)-Z0(a,this._direction),sourceGapSize:o,containerStart:Z0(this._tabsList.getBoundingClientRect(),this._direction)},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=kQ();if(i?.tabGroupId){let e=this._animState;this._animState=null,this._pendingCollapse=!1,this._commitGroupMove(i.tabGroupId,e?.currentInsertionIndex??r);return}let 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 t2(){let e=document.createElement(`div`);e.className=`dv-tabs-overflow-dropdown-default`;let t=document.createElement(`span`);t.textContent=``;let n=m0();return e.appendChild(n),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}var n2=class extends X{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`?(UQ(this._element,`dv-groupview-header-vertical`),UQ(this.rightActionsContainer,`dv-right-actions-container-vertical`),this.tabs.direction=e):(HQ(this._element,`dv-groupview-header-vertical`),HQ(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 MQ,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 e2(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new T0(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 C0(e,{kind:`header_space`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:kQ}))}),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=t2();o.update({tabs:i}),this.dropdownPart=o,a.appendChild(o.element),this.rightActionsContainer.prepend(a),this._dropdownDisposable.value=new X(jQ.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=h$(a),n={x:e.clientX,y:e.clientY,zIndex:t?.style.zIndex?`calc(${t.style.zIndex} * 2)`:void 0},{context:r,rowRenderers:i}=this.createOverflowRenderContext(a,n),o=this.accessor.advancedOverflowService;try{o?o.renderOverflow({group:this.group,overflowTabs:[...this._overflowTabs],overflowTabGroups:[...this._overflowTabGroups],pinnedOverflowTabs:[...this._overflowPinnedTabs],context:r}):r.open(this.renderFreeOverflowList(r))}catch(e){throw i.dispose(),e}}))}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=new X,c=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`,B0(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{context:{overflowGroupIdForPanel:e=>i.get(e)?.id,buildGroupHeader:e=>{let t=a.get(e);if(t&&n.has(t.id))return c(t)},buildPinnedHeader:()=>{let e=document.createElement(`div`);e.className=`dv-tabs-overflow-group-header dv-tabs-overflow-pinned-header`;let t=f0();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`),c=!1,l=jQ.from(()=>{if(!c){var e;c=!0,(e=a.dispose)==null||e.call(a)}});s.isDisposed?l.dispose():s.addDisposables(l);let u=a.element,d=document.createElement(`div`);$(d,`dv-tab`,!0),$(d,`dv-active-tab`,t.api.isActive),$(d,`dv-inactive-tab`,!t.api.isActive),r&&$(d,`dv-tab--grouped`,!0);let f=()=>{r?.collapsed&&r.expand(),n?.element.scrollIntoView({block:`nearest`,inline:`nearest`}),this.accessor.withOrigin(`user`,()=>t.api.setActive())};return d.addEventListener(`click`,e=>{o().close(),!e.defaultPrevented&&f()}),d.appendChild(u),{element:d,panel:t,activate:()=>{o().close(),f()},dispose:()=>{s.removeDisposable(l),l.dispose()}}},open:e=>{o().openPopover(e,t,{onClose:()=>s.dispose()})},close:()=>o().close(),focusTrigger:()=>{e.tabIndex=-1,e.focus()}},rowRenderers:s}}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()}},r2=class extends X{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()}},i2=class extends PQ{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get index(){return this.options.index}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},a2=class extends i2{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},o2=class extends X{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(){let e=this.contentContainer.element,t=g$(e);return t?WQ(t,e):!1}get headerPosition(){return this._headerPosition??`top`}set headerPosition(e){this._headerPosition=e,this.invalidateHeaderSize(),HQ(this.container,`dv-groupview-header-top`,`dv-groupview-header-bottom`,`dv-groupview-header-left`,`dv-groupview-header-right`),UQ(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.panels.length>0&&this.layoutContent(),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 b1(this.accessor),this.tabsContainer=new n2(this.accessor,this.groupPanel),this.contentContainer=new l0(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(VQ(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=kQ()?.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 C0(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:kQ}))}),this.contentContainer.pointerDropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new C0(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:kQ}))}),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 r2(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 X(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._moveOutOfGroupSpan(r,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._syncActiveTab(),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._reinsertTab(n,o)}_reinsertTab(e,t){this.tabsContainer.delete(e.id),this.tabsContainer.openPanel(e,t),e===this._activePanel&&this._syncActiveTab()}_syncActiveTab(){this._activePanel&&(this.tabsContainer.setActivePanel(this._activePanel),this.contentContainer.setLabelledBy(this.tabsContainer.getTabId(this._activePanel.id)))}_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._moveOutOfGroupSpan(t,e),this._onDidRemovePanelFromTabGroup.fire({tabGroup:t,panelId:e}),t.isEmpty&&t.dispose()})}_moveOutOfGroupSpan(e,t){let n=this._panels.findIndex(e=>e.id===t);if(n===-1||e.isEmpty)return;let r=e.panelIds,i=this._panels.findIndex(e=>e.id===r[0]),a=this._panels.findIndex(e=>e.id===r[r.length-1]);if(i===-1||a===-1||n<i||n>a)return;let[o]=this._panels.splice(n,1);this._panels.splice(a,0,o),this._reinsertTab(o,a)}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){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)}),this.panels.length>0&&this.layoutContent()}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:t.index<0&&(t.index=0);let n=!!t.skipSetActive;e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:n}),this.invalidateHeaderSize(),this._activePanel===e?this.contentContainer.openPanel(e):(n||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive?e.runEvents():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.isLastGridGroup(this.groupPanel);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(!this.isDisposed&&(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,this.layoutContent()}layoutContent(){let{width:e,height:t}=this.contentDimensions();this.contentContainer.layout(e,t),this._activePanel?.layout&&this._activePanel.layout(e,t)}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 X(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._syncActiveTab(),this.contentContainer.openPanel(e),this.layoutContent(),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 A0(e,n,t,kQ,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=kQ();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 a2({nativeEvent:t,position:n,panel:o,index:r,getData:()=>kQ(),kind:a(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(s),s.defaultPrevented)return;let c=kQ();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&&this.accessor.options.closeEmptyGroups!==!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 i2({nativeEvent:t,position:n,panel:o,index:r,getData:()=>kQ(),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()}},s2=class extends t0{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)}},c2=class extends i0{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 s2(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=>this.applyConstraints(e)),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)}applyConstraints(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.notifyConstraintsChanged()}notifyConstraintsChanged(){this._onDidChange.fire(void 0)}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 f1(f1({},e),{},{minimumHeight:n(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:n(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}},l2=`dockview: DockviewGroupPanelApiImpl not initialized`,u2=class extends s2{get location(){if(!this._group)throw Error(l2);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(l2);return this._group.locked}set locked(e){if(!this._group)throw Error(l2);this._group.locked=e}constructor(e,t){super(e,`__dockviewgroup__`),this.accessor=t,this._isApplyingSize=!1,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=>{if(e.isVisible&&this._pendingSize){let e=this._pendingSize;this._pendingSize=void 0,super.setSize(e)}}),this.onDidDimensionsChange(e=>{let t=e.width!==this._reportedSize?.width||e.height!==this._reportedSize?.height;this._reportedSize={width:e.width,height:e.height},t&&this.isVisible&&!this._isApplyingSize&&(this._pendingSize=void 0)}))}setSize(e){(typeof e.width==`number`||typeof e.height==`number`)&&(this._pendingSize=f1({},e));let t=this._isApplyingSize;this._isApplyingSize=!0;try{super.setSize(e)}finally{this._isApplyingSize=t}}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(l2);this._group.model.headerPosition=e}getHeaderPosition(){if(!this._group)throw Error(l2);return this._group.model.headerPosition}moveTo(e){if(!this._group)throw Error(l2);this.accessor.withOrigin(`api`,()=>{let t=e.group??this.accessor.addGroup({direction:N1(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(l2);this.location.type===`grid`&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw Error(l2);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw Error(l2);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}},d2=100,f2=100,p2=class extends c2{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??f2,minimumWidth:n.constraints?.minimumWidth??d2,maximumHeight:n.constraints?.maximumHeight,maximumWidth:n.constraints?.maximumWidth},new u2(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new o2(this.element,e,t,n,this),this._lastConstraints=this.currentConstraints(),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e),this.notifyIfConstraintsChanged()}))}applyConstraints(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),super.applyConstraints(e),this._lastConstraints=this.currentConstraints()}currentConstraints(){return{minimumWidth:this.minimumWidth,maximumWidth:this.maximumWidth,minimumHeight:this.minimumHeight,maximumHeight:this.maximumHeight}}notifyIfConstraintsChanged(){let e=this._lastConstraints,t=this.currentConstraints();(e.minimumWidth!==t.minimumWidth||e.maximumWidth!==t.maximumWidth||e.minimumHeight!==t.minimumHeight||e.maximumHeight!==t.maximumHeight)&&(this._lastConstraints=t,this.notifyConstraintsChanged())}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()}},m2={name:`abyss`,className:`dockview-theme-abyss`,colorScheme:`dark`,tabGroupIndicator:`none`},h2=class extends s2{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){if(this._group!==e){let t=this._group.isActive;this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(),t!==this.isGroupActive&&this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}),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 MQ,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(){let e=this.isGroupActive;this.groupEventsDisposable.value=new X(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&&e!==this.isGroupActive&&(e=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},g2=class extends X{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 h2(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(f1(f1({},e),{},{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){let e=new e0;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=f1(f1({},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()}},_2=class extends X{get element(){return this._element}constructor(){super(),this._messages=h1,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=d0();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??h1,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())}},v2=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(f1(f1({},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(f1(f1({},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 _2;console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new _2}},y2=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 v2(this.accessor,n,o,s),l=new g2(n,o,s,this.accessor,new b1(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}},b2=class extends X{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-watermark`}init(e){}},x2=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})`}};function S2(e){return e.width>0&&e.height>0}var C2=class e extends X{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 MQ,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(f1(f1(f1(f1({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})),x2.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,$(this.element,`dv-hidden`,!this.isVisible))}bringToFront(){x2.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();if(!S2(t)||!S2(n)){this._onDidChange.fire();return}let r=Math.max(0,this.getMinimumWidth(n.width)),i=Math.max(0,this.getMinimumHeight(n.height));if(this.verticalAlignment===`top`){let e=j$(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=j$(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=j$(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=j$(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,S2(t)?(n.width=t.width,n.height=t.height):(n.width=Number.parseFloat(this._element.style.width)||0,n.height=Number.parseFloat(this._element.style.height)||0),n}cancelPendingDrag(){this._dragMove.value&&(this._dragCancelled=!0,$(this._element,`dv-resize-container-dragging`,!1),this._dragMove.value=jQ.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=o$();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=jQ.NONE,this._onDidChangeEnd.fire()};this._dragMove.value=new X({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=j$(u,-l,f),h=j$(t.height-s.height-u,-l,f),g=j$(d,-c,p),_=j$(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=>{t.defaultPrevented?t.preventDefault():YQ(t)||n(e,t.pointerId)}),Q(this.options.content,`pointerdown`,e=>{e.defaultPrevented||YQ(e)||e.shiftKey&&n(this.options.content,e.pointerId)}),Q(this.options.content,`pointerdown`,()=>{x2.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 MQ;this.addDisposables(r,Q(n,`pointerdown`,i=>{i.preventDefault();let a=null,o=o$(),s=i.pointerId;if(typeof n.setPointerCapture==`function`)try{n.setPointerCapture(s)}catch{}let c=()=>{r.dispose(),this._onDidChangeEnd.fire()};r.value=new X(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=j$(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=j$(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=j$(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=j$(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(){x2.destroy(this._element),this._element.remove(),super.dispose()}};C2.MINIMUM_HEIGHT=20,C2.MINIMUM_WIDTH=20;var w2=class extends X{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&&JQ(e)},!0)),this.dragSource=new w0({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 T2(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 E2=new Set([`AdvancedOverflow`,`AutoEdgeGroup`,`AutoHideEdgeGroup`,`DndCompass`,`KeyboardDocking`,`KeyboardNavigation`,`LayoutHistory`,`License`,`MultiRowTabs`,`PinnedTabs`,`SmartGuides`]),D2=new Set;function O2(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 E2.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 k2(e,t){let n=`${e}|${(t===void 0?[]:[].concat(t)).join(`|`)}`;D2.has(n)||(D2.add(n),console.error(O2(e,t)))}function A2(e,t,n){if(e!==void 0)return e;k2(t,n)}var j2=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()}},M2=[];function N2(){return[...M2]}var P2=[{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=>k0(e.autoHideEdgeGroups)},{optionKey:`dockToEdgeGroups`,reason:`dockToEdgeGroups`,moduleName:`AutoEdgeGroup`,when:e=>k0(e.dockToEdgeGroups)},{optionKey:`dndCompass`,reason:`dndCompass`,moduleName:`DndCompass`,when:e=>!!e.dndCompass},{optionKey:`keyboardNavigation`,reason:`keyboardNavigation`,moduleName:`KeyboardNavigation`,when:e=>!!e.keyboardNavigation}];function F2(e,t){let n=new Map;for(let r of P2){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)k2(e,t)}var I2={left:100,top:100,width:300,height:300},L2=class extends X{get group(){return this._group}setTitleBar(e){this._titleBar=e}setAnchorGroup(e){var t;this._group=e,(t=this._titleBar)==null||t.setGroup(e),this._onDidChangeAnchorGroup.fire(e)}constructor(e,t,n){super(),this.overlay=t,this.gridview=n,this._onDidChangeAnchorGroup=new Z,this.onDidChangeAnchorGroup=this._onDidChangeAnchorGroup.event,this._group=e,this.addDisposables(this._onDidChangeAnchorGroup,t,{dispose:()=>this.gridview.dispose()})}position(e){this.overlay.setBounds(e)}},R2=class{get floatingGroups(){return this._floatingGroups}constructor(e){this._floatingGroups=[],this._host=e}add(e,t,n){let r=new L2(e,t,n),i=new X((()=>{let e=-1,t=-1;return VQ(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=e=>{let n=e.activePanel?.title;n?t.element.setAttribute(`aria-label`,n):t.element.removeAttribute(`aria-label`)},o=new MQ,s=e=>{a(e),o.value=new X(e.api.onDidActiveChange(e=>{e.isActive&&t.bringToFront()}),e.api.onDidActivePanelChange(()=>a(e)),e.onDidChange(e=>{t.setBounds({height:typeof e?.height==`number`?e.height+t.headerHeight:e?.height,width:e?.width})}))};return s(e),r.addDisposables(o,r.onDidChangeAnchorGroup(e=>s(e)),t.onDidChange(()=>{n.layout(n.width,n.height)}),t.onDidChangeEnd(()=>{this._host.fireLayoutChange(`geometry`)}),{dispose:()=>{i.dispose(),A$(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()}},z2=T2({name:`FloatingGroup`,serviceKey:`floatingGroupService`,create:e=>new R2(e)}),B2=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){A$(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(()=>{this._restorationCleanups.delete(i),this._host.isDisposed?r():Promise.resolve(t()).then(()=>r(),()=>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`?f1(f1({},i),{},{data:n.data[0].data}):f1(f1({},i),{},{grid:t})})}disposeAll(){for(let e of[...this._entries])e.disposable.dispose()}dispose(){this.cancelPendingRestorations(),this.disposeAll(),this._onDidRemove.dispose()}},V2=T2({name:`PopoutWindow`,serviceKey:`popoutWindowService`,create:e=>new B2(e)}),H2=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`,i$(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()}},U2=T2({name:`Watermark`,serviceKey:`watermarkService`,create:e=>new H2(e),init:(e,t)=>(t.update(),new X(NQ.any(e.onDidAdd,e.onDidRemove)(()=>{t.update()}),e.onDidViewVisibilityChangeMicroTaskQueue(()=>{t.update()})))}),W2=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()}},G2=T2({name:`EdgeGroup`,serviceKey:`edgeGroupService`,create:()=>new W2}),K2={activationSize:{type:`pixels`,value:10},size:{type:`pixels`,value:20}},q2={activationSize:{type:`pixels`,value:32},size:{type:`pixels`,value:20}};function J2(e,t){return typeof e.dndEdges==`object`&&e.dndEdges!==null?e.dndEdges:t&&k0(e.dockToEdgeGroups)?q2:K2}var Y2=class{constructor(e){this._host=e;let t=(t,n)=>{let r=kQ();return r?r.viewId===e.id?n!==`center`||e.isGridEmpty():!1:n===`center`&&!e.isGridEmpty()?!1:e.dispatchUnhandledDragOver(t,n)},n=J2(e.options,!1);this._html5Target=X1.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=Z1.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=NQ.any(this._html5Target.onWillShowOverlay,this._pointerTarget.onWillShowOverlay),this.onDrop=NQ.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=J2({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()}},X2=T2({name:`RootDropTarget`,serviceKey:`rootDropTargetService`,create:e=>new Y2(e),init:(e,t)=>(t.setOptions(e.options),jQ.NONE)}),Z2={left:`createLeftHeaderActionComponent`,right:`createRightHeaderActionComponent`,prefix:`createPrefixHeaderActionComponent`},Q2=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 MQ,right:new MQ,prefix:new MQ},this._perGroup.set(e,t)),t}_refreshSlot(e,t,n){let r=this._host.options[Z2[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)}},$2=T2({name:`HeaderActions`,serviceKey:`headerActionsService`,create:e=>new Q2(e),init:(e,t)=>new X(e.onDidRemoveGroup(e=>{t.disposeGroup(e)}))}),e4=e=>e===`load`||e===`clear`;function t4(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 n4=class extends X{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:t4(t,`polite`),assertive:t4(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=>{e4(e.kind)&&this._suppressDepth++}),e.onDidMutateLayout(e=>{e4(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:t4(r,`polite`),assertive:t4(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=g1(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)}}},r4=T2({name:`LiveRegion`,serviceKey:`liveRegionService`,create:e=>new n4(e)}),i4=30,a4=-10,o4=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:i4,offsetY:a4,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),jQ.from(()=>n.clearOverlay())}dispose(){}},s4=T2({name:`AdvancedDnD`,serviceKey:`advancedDnDService`,create:e=>new o4(e)}),c4=class{constructor(e){this._host=e}attachToGroup(e){return new X(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(){}},l4=T2({name:`TabGroupChips`,serviceKey:`tabGroupChipsService`,create:e=>new c4(e),init:(e,t)=>{let n=new Map;return new X(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()}})}});function u4(e,t){var n,r;if((n=t.api)!=null&&(r=n.isPeeking)!=null&&r.call(n))return`calc(var(--dv-overlay-z-index, 999) + 100)`;if(!(e instanceof HTMLElement))return;let i=h$(e);return i?.style.zIndex?`calc(${i.style.zIndex} * 2)`:void 0}var d4=0,f4=()=>`dv-ctx-menu-item-${d4++}`;function p4(e){return typeof e==`object`}function m4(e,t,n,r){let i=document.createElement(`div`);return i.className=`dv-context-menu-item`,i.setAttribute(`role`,`menuitem`),r&&(i.classList.add(`dv-context-menu-item--disabled`),i.setAttribute(`aria-disabled`,`true`)),i.textContent=e,r||i.addEventListener(`click`,()=>{n(),t()}),i}function h4(){let e=document.createElement(`div`);return e.className=`dv-context-menu-separator`,e.setAttribute(`role`,`separator`),e}function g4(){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}function _4(e){let t=document.createElement(`div`);t.className=`dv-context-menu-rename`;let n=document.createElement(`input`);return n.className=`dv-context-menu-rename-input`,n.type=`text`,n.placeholder=`Name This Group`,n.value=e.label,n.addEventListener(`input`,()=>{e.setLabel(n.value)}),n.addEventListener(`keydown`,e=>{e.key!==`Escape`&&e.key!==`Enter`&&e.stopPropagation()}),n.addEventListener(`click`,e=>{e.stopPropagation()}),t.appendChild(n),g4()||requestAnimationFrame(()=>{n.focus(),n.select()}),t}function v4(e,t){let n=document.createElement(`div`);if(n.className=`dv-context-menu-color-picker`,!t.enabled)return n;for(let r of t.entries()){let t=document.createElement(`div`);t.className=`dv-context-menu-color-swatch`,t.style.setProperty(`--dv-tab-group-color`,r.value),r.label&&(t.title=r.label),e.color===r.id&&t.classList.add(`dv-context-menu-color-swatch--selected`),t.addEventListener(`click`,()=>{e.setColor(r.id)}),n.appendChild(t)}return n}var y4=class{constructor(e){this.accessor=e}buildMaximizeItem(e,t){let n=e.api.isMaximized();return m4(n?`Restore`:`Maximize`,t,n?()=>e.api.exitMaximized():()=>e.api.maximize(),!n&&e.api.location.type!==`grid`)}buildCollapseItem(e,t){return m4(e.collapsed?`Expand`:`Collapse`,t,()=>e.toggle())}_shouldInjectPin(){let e=this.accessor.options.pinnedTabs;return!!this.accessor.pinnedTabsService&&!!e?.enabled&&e.contextMenuItem!==!1}_resolveTabItems(e,t,n){var r;let i=(r=this.accessor.options).getTabContextMenuItems?.call(r,{panel:e,group:t,api:this.accessor.api,event:n})??[];return this._shouldInjectPin()?[`pin`,...i]:i}appendComponentItem(e,t,n,r,i,a){var o;let s=(o=this.accessor.options).createContextMenuItemComponent?.call(o,{id:f4(),component:t.component});s&&(a.addDisposables(s),s.init(f1(f1({},n),{},{group:r,api:this.accessor.api,close:i,componentProps:t.componentProps})),e.appendChild(s.element))}buildBuiltInTabItem(e,t,n,r){switch(e){case`separator`:return h4();case`close`:return m4(`Close`,r,()=>t.api.close());case`closeOthers`:return m4(`Close Others`,r,()=>{n.panels.filter(e=>e!==t).forEach(e=>e.api.close())});case`closeAll`:return m4(`Close All`,r,()=>{[...n.panels].forEach(e=>e.api.close())});case`closeLeft`:{let e=n.panels.indexOf(t);return m4(`Close to the Left`,r,()=>{n.panels.filter((t,n)=>n<e).forEach(e=>e.api.close())},e<=0)}case`closeRight`:{let e=n.panels.indexOf(t);return m4(`Close to the Right`,r,()=>{n.panels.filter((t,n)=>n>e).forEach(e=>e.api.close())},e===-1||e>=n.panels.length-1)}case`maximize`:return this.buildMaximizeItem(t,r);case`float`:return m4(`Float`,r,()=>this.accessor.api.addFloatingGroup(t),t.api.location.type===`floating`);case`popout`:return m4(`Open in New Window`,r,()=>{this.accessor.api.addPopoutGroup(t)},t.api.location.type===`popout`);case`pin`:return m4(t.api.isPinned?`Unpin tab`:`Pin tab`,r,()=>t.api.setPinned(!t.api.isPinned));default:return}}appendConfigItem(e,t,n,r,i,a){t.element?e.appendChild(t.element):t.component?this.appendComponentItem(e,t,n,r,i,a):t.label&&e.appendChild(m4(t.label,i,()=>t.action?.call(t),t.disabled))}show(e,t,n){let r=this._resolveTabItems(e,t,n);if(r.length===0)return;n.preventDefault();let i=this.accessor.getPopupServiceForGroup(t),a=()=>i.close(),o=new X,s=document.createElement(`div`);s.className=`dv-context-menu`,s.setAttribute(`role`,`menu`);try{for(let n of r){if(p4(n)){this.appendConfigItem(s,n,{panel:e},t,a,o);continue}let r=this.buildBuiltInTabItem(n,e,t,a);r&&s.appendChild(r)}}catch(e){throw o.dispose(),e}i.openPopover(s,{x:n.clientX,y:n.clientY,zIndex:u4(n.target,t)},{onClose:()=>o.dispose()})}showForChip(e,t,n){if(!this.accessor.options.getTabGroupChipContextMenuItems)return;let r=this.accessor.options.getTabGroupChipContextMenuItems({tabGroup:e,group:t,api:this.accessor.api,event:n});if(r.length===0)return;n.preventDefault();let i=this.accessor.getPopupServiceForGroup(t),a=()=>i.close(),o=new X,s=document.createElement(`div`);s.className=`dv-context-menu`,s.setAttribute(`role`,`menu`);try{for(let n of r)n===`separator`?s.appendChild(h4()):n===`rename`?s.appendChild(_4(e)):n===`colorPicker`?s.appendChild(v4(e,this.accessor.tabGroupColorPalette)):n===`collapse`?s.appendChild(this.buildCollapseItem(e,a)):n===`close`?s.appendChild(m4(`Close All`,a,()=>{t.panels.filter(t=>e.containsPanel(t.id)).forEach(e=>e.api.close())})):p4(n)&&this.appendConfigItem(s,n,{tabGroup:e},t,a,o)}catch(e){throw o.dispose(),e}i.openPopover(s,{x:n.clientX,y:n.clientY,zIndex:u4(n.target,t)},{onClose:()=>o.dispose()})}},b4=[z2,V2,U2,G2,X2,$2,r4,s4,l4,T2({name:`ContextMenu`,serviceKey:`contextMenuService`,create:e=>new y4(e)})],x4=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=e$(e);return this.cache.set(e,{rect:n,frameId:this.currentFrameId}),n}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null})}},S4=-1;function C4(e){let t=e.group.api;return t.location.type===`edge`&&t.isCollapsed()}function w4(){let e=document.createElement(`div`);return e.tabIndex=-1,e}function T4(e,t,n){let r=`${n}px`;e[t]!==r&&(e[t]=r)}var E4=class extends X{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this._generation=0,this.positionCache=new x4,this.addDisposables(jQ.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){var t;let{panel:n,referenceContainer:r}=e;if(!this.map[n.api.id]){let e=w4();e.className=`dv-render-overlay`,e.style.visibility=`hidden`,this.map[n.api.id]={panel:n,disposable:jQ.NONE,destroy:jQ.NONE,element:e,retainPreviousGeometry:!1,positioned:!1,generation:++this._generation}}let i=this.map[n.api.id];if(i.referenceContainer!==r){i.generation=++this._generation,this.cancelPendingUpdate(i),i.referenceContainer=r;let e=C4(n);i.retainPreviousGeometry=i.positioned&&!e,e&&!i.forceVisible&&(i.element.style.visibility=`hidden`,i.element.style.pointerEvents=`none`)}let a=i.generation,o=i.element,s=n.view.content.element,c=e=>{if(!e||e.width<=0||e.height<=0)return;let t=this.map[n.api.id];!t||t.forceVisible||t.positioned&&n.api.isVisible||(T4(o.style,`width`,e.width),T4(o.style,`height`,e.height))};c(r.dimensions),s.parentElement!==o&&o.appendChild(s),o.parentElement!==this.element&&this.element.appendChild(o);let l=()=>{let e=n.api.id,t=this.map[e];if(t?.generation!==a||t.pendingUpdate!==void 0)return;t.pendingUpdate=S4;let i=requestAnimationFrame(()=>{let t=this.map[e];if(t&&(t.pendingUpdate=void 0),this.isDisposed||t?.generation!==a)return;let i=t.forceVisible??!1,s=t.clip,c=C4(n),l=!i&&(!n.api.isVisible||c),u=this.positionCache.getPosition(r.element),d=this.positionCache.getPosition(this.element),f=u.left-d.left,p=u.top-d.top,m=u.width,h=u.height;if(m===0||h===0){if(c&&!i){t.retainPreviousGeometry=!1,o.style.visibility=`hidden`,o.style.pointerEvents=`none`,o.style.clipPath=``,o.style.zIndex=``;return}if(t.retainPreviousGeometry){l&&(o.style.visibility=`hidden`,o.style.pointerEvents=`none`);return}}if(t.retainPreviousGeometry=!1,t.positioned=!0,T4(o.style,`left`,f),T4(o.style,`top`,p),T4(o.style,`width`,m),T4(o.style,`height`,h),l?(o.style.visibility=`hidden`,o.style.pointerEvents=`none`):(o.style.visibility=``,o.style.pointerEvents=``),i?o.style.zIndex=`1000`:n.api.location.type!==`floating`&&(o.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,a=Math.max(0,r-u.top),c=Math.max(0,i-u.left),l=Math.max(0,u.left+m-(s.right+t)),d=Math.max(0,u.top+h-(s.bottom+n));o.style.clipPath=`inset(${a}px ${l}px ${d}px ${c}px)`}else o.style.clipPath=``;$(o,`dv-render-overlay-float`,n.group.api.location.type===`floating`)});t.pendingUpdate===S4&&(t.pendingUpdate=i)},u=()=>{let e=!this.map[n.api.id]?.forceVisible&&C4(n);n.api.isVisible&&!e?(this.positionCache.invalidate(),l(),this.map[n.api.id]?.retainPreviousGeometry&&(o.style.visibility=``),o.style.pointerEvents=``):(o.style.visibility=`hidden`,o.style.pointerEvents=`none`)},d=new MQ,f=()=>{n.api.location.type===`floating`?queueMicrotask(()=>{if(p.isDisposed)return;let e=this.accessor.getFloatingWindowForGroup(n.api.group);if(!e)return;let t=e.overlay.element,r=()=>{let e=Number(t.getAttribute(`aria-level`));o.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2+1})`},i=new MutationObserver(()=>{r()});d.value=jQ.from(()=>i.disconnect()),i.observe(t,{attributeFilter:[`aria-level`],attributes:!0}),r()}):o.style.zIndex=``},p=new X(d,new x1(o,{onDragEnd:e=>{r.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{r.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{r.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{r.dropTarget.dnd.onDrop(e)},onDragOver:e=>{r.dropTarget.dnd.onDragOver(e)}}),n.api.onDidVisibilityChange(()=>{u()}),n.api.onDidDimensionsChange(()=>{n.api.isVisible&&l()}),(t=n.group.api).onDidCollapsedChange?.call(t,()=>{this.positionCache.invalidate(),l()})??jQ.NONE,r.onDidDimensionsChange(e=>{c(e)}),n.api.onDidLocationChange(()=>{f()}));return this.map[n.api.id].destroy=jQ.from(()=>{s.parentElement===o&&s.remove(),o.remove()}),f(),queueMicrotask(()=>{this.isDisposed||u()}),this.map[n.api.id].disposable.dispose(),this.map[n.api.id].disposable=p,this.map[n.api.id].resize=l,o}},D4=class extends X{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 O4(e){if(!e.matchMedia)return!1;let t=e.matchMedia(`(pointer: coarse)`).matches,n=e.matchMedia(`(pointer: fine)`).matches;return t&&!n}function k4(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 X,u=t=>e.isInside?e.isInside(t):XQ(t,e.elements?.call(e)??[]);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)}else!a||s()-c<o||e.onDismiss()},n)),e.resize&&l.addDisposables(Q(t,`resize`,()=>{O4(t)||e.onDismiss()})),e.focusOut){let r=()=>e.anchor?.call(e)??e.elements?.call(e)[0],i=new WeakSet,a=t=>{if(i.has(t))return;i.add(t);let n=t.target;n instanceof Element&&((e.isFocusInside?e.isFocusInside(QQ(n,r())):XQ(t,e.elements?.call(e)??[]))||e.onDismiss())},o=new Map,s=()=>{let t=new Set,r=e.anchor?.call(e),i=[...e.elements?.call(e)??[],...r?[r]:[]];for(let e of i)for(let n of ZQ(e))t.add(n);for(let[e,n]of o)t.has(e)||(n.dispose(),o.delete(e));for(let e of t)o.has(e)||o.set(e,Q(e,`focusin`,a,n))};l.addDisposables(Q(t,`focusin`,e=>{s(),a(e)},n),{dispose:()=>{for(let[,e]of o)e.dispose();o.clear()}}),s()}return l}var A4=class extends X{constructor(e,t=globalThis.window){super(),this._active=null,this._activeDisposable=new MQ,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(jQ.from(()=>{this.close()}),this._activeDisposable)}updateRoot(e){e.prepend(this._element),this._root=e}openPopover(e,t,n){this.close();let r=this._window.document.createElement(`div`);r.style.position=`absolute`,r.style.zIndex=t.zIndex??`var(--dv-overlay-z-index)`,r.appendChild(e);let i=this._element.getBoundingClientRect(),a=i.left,o=i.top;r.style.top=`${t.y-o}px`,r.style.left=`${t.x-a}px`,this._element.appendChild(r),this._active=r,this._activeDisposable.value=new X(k4({window:this._window,onDismiss:()=>this.close(),elements:()=>this._active?[this._active]:[],keys:[`Enter`],pointerDownGraceMs:200,resize:!0}),n?.onClose?jQ.from(n.onClose):jQ.NONE),this._window.requestAnimationFrame(()=>{m$(r,this._root)})}close(){this._active&&=(this._active.remove(),this._activeDisposable.dispose(),null)}},j4=class extends X{get renderedOutline(){return this._model?this._outline:void 0}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(jQ.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}},M4=[`left`,`right`,`top`,`bottom`];function N4(e){return e===`left`||e===`right`}var P4={marginShare:0,size:1/0},F4=class{get _effectiveBaseCollapsed(){return this._measuredTabSize??this._baseCollapsedSize}get minimumSize(){return this._isCollapsed?this.collapsedSize:this._baseMinimumSize===void 0?this._effectiveBaseCollapsed+50+this._axis.marginShare:this._baseMinimumSize+this._axis.marginShare}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 lastExpandedContentSize(){return this._lastExpandedSize-this._axis.marginShare}get collapsedSize(){return this._effectiveBaseCollapsed+this._axis.marginShare}get configuredMinimumSize(){return this._baseMinimumSize}get configuredMaximumSize(){return this._expandedMaximumSize}get configuredCollapsedSize(){return this._baseCollapsedSize}constructor(e,t,n,r=P4){this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this.snap=!1,this.priority=`low`,this._isCollapsed=!1,this._isVisible=!0,this._tabSizeDisposables=new X,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._axis=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(VQ(e,()=>{let{headerPosition:t}=this._group;(t===`left`||t===`right`)==(this._orientation===`horizontal`)&&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._isVisible&&this._axis.size>0&&(this._lastExpandedSize=e+this._axis.marginShare),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){this._isVisible=e}restoreExpandedSize(e){this._lastExpandedSize=e}updateSizing(e,t){this._baseCollapsedSize=e,this._baseMinimumSize=t}dispose(){this._tabSizeDisposables.dispose(),this._onDidChange.dispose()}},I4=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()}},L4=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 R$(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)}get axis(){return this._splitview}updateMargin(e){this._splitview.margin=e}get disabled(){return this._splitview.disabled}set disabled(e){this._splitview.disabled=e}dispose(){this._onDidChange.dispose(),this._splitview.dispose()}},R4=class{constructor(e,t,n,r=0,i=35){this._disposables=new X,this._viewConfigs=new Map,this._pendingSizes=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 I4(t,n);this._middleColumn=new L4(a,r),this._outerSplitview=new R$(this._shellElement,{orientation:`HORIZONTAL`,proportionalLayout:!1,margin:r}),this._middleIndex=0,this._outerSplitview.addView(this._middleColumn,{type:`distribute`},0),this._disposables.addDisposables(VQ(this._shellElement,e=>{if(!this._shellElement.offsetParent||!t$(this._shellElement))return;let t=Math.round(e.contentRect.width),n=Math.round(e.contentRect.height);(t!==this._currentWidth||n!==this._currentHeight)&&this.layout(t,n)}),this._outerSplitview,this._middleColumn,a)}get element(){return this._shellElement}get locked(){return this._outerSplitview.disabled}set locked(e){this._outerSplitview.disabled=e,this._middleColumn.disabled=e}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=new F4(f1(f1({},t),{},{collapsedSize:t.collapsedSize??this._defaultCollapsedSize}),n,N4(e)?`horizontal`:`vertical`,this._axisFor(e)),i=r.isCollapsed?r.collapsedSize:r.lastExpandedSize;switch(e){case`left`:this._outerSplitview.addView(r,i,0),this._leftIndex=0,this._middleIndex+=1,this._rightIndex!==void 0&&(this._rightIndex+=1),this._leftView=r;break;case`right`:{let e=this._outerSplitview.length;this._outerSplitview.addView(r,i,e),this._rightIndex=e,this._rightView=r}break;case`top`:this._middleColumn.addTopView(r,i),this._topView=r;break;case`bottom`:this._middleColumn.addBottomView(r,i),this._bottomView=r}return this._disposables.addDisposables(r),!r.isCollapsed&&!this._canResize(e)&&this._pendingSizes.set(e,i),this._relayout(),r}layoutFromElement(){if(!this._shellElement.offsetParent||!t$(this._shellElement))return;let e=Math.round(this._shellElement.clientWidth),t=Math.round(this._shellElement.clientHeight);e!==0&&t!==0&&this.layout(e,t)}layout(e,t){this._currentWidth=e,this._currentHeight=t,this._outerSplitview.layout(e,t),this._flushPendingSizes()}updateTheme(e,t){this._gap=e,this._defaultCollapsedSize=t,this._outerSplitview.margin=e,this._middleColumn.updateMargin(e),this._applyThemeSizing(),this._relayout()}_hasSiblingOn(e){return N4(e)?this._leftView!==void 0&&this._rightView!==void 0:this._topView!==void 0&&this._bottomView!==void 0}_axisFor(e){return N4(e)?this._outerSplitview:this._middleColumn.axis}_applyThemeSizing(){for(let e of M4){let t=this._getView(e),n=this._viewConfigs.get(e);t&&n&&t.updateSizing(n.collapsedSize??this._defaultCollapsedSize,n.minimumSize)}}_relayout(){this._currentWidth>0&&this._currentHeight>0&&this.layout(this._currentWidth,this._currentHeight)}_slotSize(e){switch(e){case`left`:return this._leftIndex===void 0?0:this._outerSplitview.getViewSize(this._leftIndex);case`right`:return this._rightIndex===void 0?0:this._outerSplitview.getViewSize(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.getViewSize(e)}}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._pendingSizes.delete(e),this._relayout()}}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){let n=this._getView(e)!==void 0&&t!==this.isEdgeGroupVisible(e);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)}n&&this._gap>0&&this._hasSiblingOn(e)&&this._relayout(),t&&this._flushPendingSizes()}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);n&&(n.setCollapsed(t),t?(this._pendingSizes.delete(e),this._resizeView(e,n.collapsedSize)):this.resizeEdgeGroup(e,n.lastExpandedSize))}resizeEdgeGroup(e,t){let n=this._getView(e);if(!n||!Number.isFinite(t))return;let r=Math.round(t);r<=0||(n.restoreExpandedSize(r),n.isCollapsed?this._pendingSizes.delete(e):this._canResize(e)?(this._pendingSizes.delete(e),this._resizeView(e,r)):this._pendingSizes.set(e,r))}_canResize(e){return this.isEdgeGroupVisible(e)&&this._axisFor(e).size>0}_resizeView(e,t){switch(e){case`left`:this._leftIndex!==void 0&&this._outerSplitview.resizeView(this._leftIndex,t);break;case`right`:this._rightIndex!==void 0&&this._outerSplitview.resizeView(this._rightIndex,t);break;case`top`:case`bottom`:this._middleColumn.resizeView(e,t)}}_flushPendingSizes(){if(this._pendingSizes.size!==0)for(let[e,t]of this._pendingSizes){let n=this._getView(e);n&&!n.isCollapsed&&this._canResize(e)&&(this._pendingSizes.delete(e),this._resizeView(e,t))}}isEdgeGroupCollapsed(e){return this._getView(e)?.isCollapsed??!1}getEdgeGroupExpandedSize(e){return this._getView(e)?.lastExpandedContentSize??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={};for(let t of M4){let n=this._getView(t);if(!n)continue;let r=this.isEdgeGroupVisible(t);e[t]={size:this._expandedSize(n,t,r),visible:r,collapsed:n.isCollapsed||void 0,minimumSize:n.configuredMinimumSize,maximumSize:Number.isFinite(n.configuredMaximumSize)?n.configuredMaximumSize:void 0,collapsedSize:n.configuredCollapsedSize}}return e}_expandedSize(e,t,n){if(e.isCollapsed)return e.lastExpandedSize;let r=this._pendingSizes.get(t);return r===void 0?n?this._slotSize(t):this._cachedVisibleSize(t)??e.lastExpandedSize:r}_cachedVisibleSize(e){switch(e){case`left`:return this._leftIndex===void 0?void 0:this._outerSplitview.getViewCachedVisibleSize(this._leftIndex);case`right`:return this._rightIndex===void 0?void 0:this._outerSplitview.getViewCachedVisibleSize(this._rightIndex);case`top`:case`bottom`:return this._middleColumn.getViewCachedVisibleSize(e)}}fromJSON(e){for(let t of M4){let n=e[t],r=this._getView(t);n&&r&&(r.restoreExpandedSize(n.size),r.setCollapsed(n.collapsed??!1),n.collapsed?(this._pendingSizes.delete(t),this._resizeView(t,r.collapsedSize)):this.resizeEdgeGroup(t,n.size),this.setEdgeGroupVisible(t,!!n.visible))}}dispose(){this._disposables.dispose(),this._shellElement.remove()}};function z4(e){e.error?console.error(`dockview: failed to create popout.`,e.error):e.reason===`blocked`?console.error(`dockview: failed to create popout. perhaps you need to allow pop-ups for this website`):console.error(`dockview: failed to create popout (${e.reason}).`)}function B4(e){return new L0(e.tabGroupColors??I0,e.tabGroupAccent!==`off`)}function V4(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 H4=()=>({dispose:()=>{}}),U4=H4,W4=100,G4=class extends o1{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 dndCapabilities(){return v0(this.options)}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=A2(this._smartGuidesService,`SmartGuides`,`api.setSmartGuidesEnabled`))==null||t.setEnabled(e)}updateSmartGuidesOptions(e){var t;(t=A2(this._smartGuidesService,`SmartGuides`,`api.updateSmartGuidesOptions`))==null||t.updateOptions(e)}get onDidSnapFloat(){return this._smartGuidesService?.onDidSnapFloat??H4}get onDidSnapTogether(){return this._smartGuidesService?.onDidSnapTogether??H4}_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?f1(f1({},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 a2({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:kQ,kind:`edge`});if(this._onWillDrop.fire(n),n.defaultPrevented)return;let r=kQ();r?this.moveGroupOrPanel({from:{groupId:r.groupId,panelId:r.panelId??void 0},to:{group:this.orthogonalize(t),position:`center`}}):this._onDidDrop.fire(new i2({nativeEvent:e,position:t,panel:void 0,api:this._api,group:void 0,getData:kQ}))}get headerActionsService(){return this._moduleRegistry.services.headerActionsService}get _layoutHistoryService(){return this._moduleRegistry.services.layoutHistoryService}undo(){var e;(e=A2(this._layoutHistoryService,`LayoutHistory`,`api.undo`))==null||e.undo()}redo(){var e;(e=A2(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??U4}get hasEdgeDragReveal(){return!!this._moduleRegistry.services.autoEdgeGroupService}isGridEmpty(){return this.gridview.length===0}rootDropTargetOverrideTarget(){return this.rootDropTargetContainer?.model}dispatchUnhandledDragOver(e,t){let n=new A0(e,`edge`,t,kQ);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){let n=this.getGridviewForGroup(e);if(!n.element.contains(e.element))return;let r=J$(e.element),i=(t?n.previous(r):n.next(r)).view;if(n===this.gridview||i!==e)return i}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)??jQ.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)}isLastGridGroup(e){return e.api.location.type===`grid`&&!this.groups.some(t=>t!==e&&t.api.location.type===`grid`)}fireLayoutChange(e){this._bufferOnDidLayoutChange.fire(e)}get popoutRestorationPromise(){return this._popoutWindowService?.restorationPromise??Promise.resolve()}constructor(e,t){super(e,{proportionalLayout:t.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=M$(),this._deserializer=new y2(this),this._moduleRegistry=new j2,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._syncMutationDepth=0,this._pendingLocationChanges=new Map,this._openingPopoutWindows=new Set,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._onWillClosePopoutWindow=new Z,this.onWillClosePopoutWindow=this._onWillClosePopoutWindow.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=B4(t);let n=t.modules??[...b4,...N2()];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 A4(this.element),this.addDisposables(this.popupService,jQ.from(()=>{for(let e of this._openingPopoutWindows)e.dispose();this._openingPopoutWindows.clear()})),this._api=new b1(this),this.disableResizing=!0,this.element.remove(),this._shellManager=new R4(e,this.element,(e,t)=>this._layoutFromShell(e,t),t.theme?.gap??0,t.theme?.edgeGroupCollapsedSize),this._shellManager.locked=!!t.locked,this.popupService.updateRoot(this._shellManager.element),this._shellThemeClassnames=new l$(this._shellManager.element),this.rootDropTargetContainer=new j4(this._shellManager.element,{disabled:!0}),this.floatingDropTargetContainer=new j4(this._shellManager.element,{disabled:!1}),this.overlayRenderContainer=new E4(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 D4(this)),this.addDisposables(jQ.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,NQ.any(this.onDidPopoutGroupSizeChange,this.onDidPopoutGroupPositionChange)(()=>{this.fireLayoutChange(`geometry`)}),NQ.any(this.onDidCreateTabGroup,this.onDidDestroyTabGroup,this.onDidAddPanelToTabGroup,this.onDidRemovePanelFromTabGroup,this.onDidTabGroupChange,this.onDidTabGroupCollapsedChange)(()=>{this.fireLayoutChange(`structure`)}),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})}),NQ.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidRemoveGroup,this.onDidMovePanel)(()=>{this._bufferOnDidLayoutChange.fire(`structure`)}),this.onDidActivePanelChange(()=>{this._bufferOnDidLayoutChange.fire(`activePanel`)}),jQ.from(()=>{var e;this._moduleRegistry.dispose(),(e=this._shellManager)==null||e.dispose()}),this._onWillClosePopoutWindow);let i=this._rootDropTargetService;i&&this.addDisposables(i.onWillShowOverlay(e=>{this.gridview.length>0&&e.position===`center`||this._onWillShowOverlay.fire(new C0(e,{kind:`edge`,panel:void 0,api:this._api,group:void 0,getData:kQ}))}),i.onDrop(e=>this.dockToLayoutEdge(e.nativeEvent,e.position))),this._moduleRegistry.postConstruct(this),this._shellManager.layoutFromElement()}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=A2(this._popoutWindowService,`PopoutWindow`,`api.addPopoutGroup`);if(!r||e instanceof p2&&e.model.location.type===`edge`)return Promise.resolve(!1);if(e instanceof g2&&e.group.size===1&&this.closeEmptyGroups)return this.addPopoutGroup(e.group,t);let i=c$(this.gridview.element),a=this.element;function o(){if(t?.position)return t.position;let n=(e instanceof p2?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=l??`/popout.html`,d=new w$(`${this.id}-${c}`,i??``,{url:u,left:s.left,top:s.top,width:s.width,height:s.height,onDidOpen:t?.onDidOpen,onWillClose:e=>{var n;t==null||(n=t.onWillClose)==null||n.call(t,e),this._onWillClosePopoutWindow.fire(e)},nonce:this.options?.nonce,styleRoot:()=>this.element.getRootNode()}),f=new X(d,d.onDidClose(()=>{f.dispose()}));this._openingPopoutWindows.add(f);let p=C$(u);return(p?Promise.resolve(null):d.open()).then(n=>{if(this._openingPopoutWindows.delete(f),this.isDisposed)return f.dispose(),!1;if(d.isDisposed){let e=d.failure;return e&&!this.isDisposed&&(z4(e),this._onDidOpenPopoutWindowFail.fire(e)),!1}let i=t?.referenceGroup??(e instanceof g2?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:f,failure:p?{reason:`url-refused`,error:p}:d.failure??{reason:`blocked`}}),!1;let u=document.createElement(`div`);u.className=`dv-overlay-render-container`;let m=new E4(u,this);s.model.renderContainer=m;let h=t?.overridePopoutGridview??this.createNestedGridview();t?.overridePopoutGridview?h.locked=this.gridview.locked:h.addView(s,L$.Distribute,[0]),h.element.style.width=`100%`,h.element.style.height=`100%`,h.layout(d.window.innerWidth,d.window.innerHeight);let g=!1,_=()=>{g||(g=!0,h.dispose())},v,y=[];if(!t?.overridePopoutGroup&&!t?.overridePopoutGridview&&o){if(e instanceof g2){let t=e.group;this.movingLock(()=>{let t=i.model.removePanel(e);s.model.openPanel(t)}),y=[{panel:e,from:t}]}else switch(this.movingLock(()=>V4({from:i,to:s})),y=s.panels.map(e=>({panel:e,from:i})),a){case`grid`:i.api.setVisible(!1);break;case`floating`:case`popout`:v=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(u),n.appendChild(h.element);let b=document.createElement(`div`),x=new j4(b,{disabled:this.rootDropTargetContainer.disabled});n.appendChild(b),s.model.dropTargetContainer=x;let S=new A4(n,d.window);if(f.addDisposables(S),s.model.location={type:`popout`,getWindow:()=>d.window,popoutUrl:l},t?.overridePopoutGridview){let e=this.groups.filter(e=>h.element.contains(e.element));for(let t of e)t.model.renderContainer=m,t.model.dropTargetContainer=x,t.model.location={type:`popout`,getWindow:()=>d.window,popoutUrl:l}}o&&e.api.location.type===`grid`&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(s);let C=r.observeGridviewSize(d,h,m);C&&f.addDisposables(C);let w=new MQ;f.addDisposables(w);let T=e=>{w.value=new X(e.api.onDidActiveChange(e=>{if(e.isActive){var t;(t=d.window)==null||t.focus()}}),e.api.onWillFocus(()=>{var e;(e=d.window)==null||e.focus()}))};T(s);let E={},D=o&&i&&this.getPanel(i.id),O={window:d,popoutGroup:s,gridview:h,overlayRenderContainer:m,dropTargetContainer:x,getWindow:()=>d.window,popoutUrl:l,referenceGroup:D?i.id:void 0,popupService:S,setAnchorGroup:e=>{O.popoutGroup=e,T(e)},disposable:{dispose:()=>(f.dispose(),E.returnedGroup)}},k=f$(d.window);f.addDisposables(k,p$(d.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:d.window.innerWidth,height:d.window.innerHeight,group:O.popoutGroup})}),k.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:d.window.screenX,screenY:d.window.screenY,group:O.popoutGroup})}),Q(d.window,`resize`,()=>{h.layout(d.window.innerWidth,d.window.innerHeight)}),m,jQ.from(()=>this.disposePopoutWindow({group:s,referenceGroup:i,popoutGridview:h,isGroupAddedToDom:o,floatingBox:v,disposePopoutGridview:_,closeResult:E}))),r.add(O),this._onDidAddPopoutGroup.fire({id:O.popoutGroup.id,group:O.popoutGroup,window:O.getWindow()});for(let{panel:e,from:t}of y)this.fireDidMovePanel(e,t);return!0}).catch(e=>(this._openingPopoutWindows.delete(f),console.error(`dockview: failed to create popout.`,e),!1))}handleBlockedPopout(e){let{group:t,referenceGroup:n,options:r,popoutWindowDisposable:i,failure:a}=e;if(z4(a),i.dispose(),this._onDidOpenPopoutWindowFail.fire(a),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)}else t===n?this.gridview.element.contains(t.element)||(this.movingLock(()=>this.doAddGroup(t,[0])),t.model.location={type:`grid`}):(this.movingLock(()=>V4({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;if(!c){u&&this.getPanel(t.id)&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,s.returnedGroup=t),o();return}let f=[];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(()=>V4({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,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(!A2(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`)||e instanceof p2&&e.model.location.type===`edge`)return;let n,r=[];if(e instanceof g2){let t=e.group;n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!1,skipDispose:!0,skipSetActiveGroup:!0})),this.removeGroupIfEmpty(t),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(()=>V4({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=I2.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=I2.top,e.width=typeof t.width==`number`?Math.max(t.width,0):I2.width,e.height=typeof t.height==`number`?Math.max(t.height,0):I2.height,e}return{left:typeof t?.x==`number`?Math.max(t.x,0):I2.left,top:typeof t?.y==`number`?Math.max(t.y,0):I2.top,width:typeof t?.width==`number`?Math.max(t.width,0):I2.width,height:typeof t?.height==`number`?Math.max(t.height,0):I2.height}}let a=i(),o=this.createNestedGridview();o.addView(n,L$.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)}get closeEmptyGroups(){return this.options.closeEmptyGroups!==!1}keepEmptyGroups(e){return e.keepEmptyGroups??!this.closeEmptyGroups}removeGroupIfEmpty(e){e.model.size===0&&this.closeEmptyGroups&&this.doRemoveGroup(e,{skipActive:!0})}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e,this._shellManager&&(this._shellManager.locked=e);for(let t of this.nestedGridviews())t.locked=e}nestedGridviews(){return[...this.floatingGroups.map(e=>e.gridview),...(this._popoutWindowService?.entries??[]).map(e=>e.gridview)]}createNestedGridview(e=`HORIZONTAL`){return new t1(this.gridview.proportionalLayout,this.options.hideBorders?{separatorBorder:`transparent`}:void 0,e,this.gridview.locked,this.options.theme?.gap??0)}mountFloatingWindow(e,t,n,r,i){let a=A2(this._floatingGroupService,`FloatingGroup`,`api.addFloatingGroup`);if(!a)return;let o=(i?.dragHandle??this.options.floatingGroupDragHandle??`titlebar`)===`titlebar`?new w2(this,t):void 0,s=new C2(f1(f1({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,jQ.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=f1(f1({},this.options),e);let a=this.options.disableDnd,o=this.options.dndStrategy;if((r!==a||i!==o)&&this.updateDragAndDropState(),`proportionalLayout`in e){let e=this.gridview.proportionalLayout;for(let t of this.nestedGridviews())t.proportionalLayout=e}if(`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??I0),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){F2(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(O2(`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.onDidChange(t=>{var n;if(!t)return;let r=N4(e)?t.width:t.height;typeof r==`number`&&((n=this._shellManager)==null||n.resizeEdgeGroup(e,r))}),a=r.model.onDidRemovePanel(()=>{r.model.isEmpty&&(n.isAutoReveal(r)?queueMicrotask(()=>{r.model.isEmpty&&this._edgeGroupService?.includes(r)&&this.removeEdgeGroup(e)}):this.setEdgeGroupCollapsed(r,!0))});n.add(e,r,new X(a,i)),t.autoHide!==void 0&&n.setAutoHide(r,t.autoHide),t.autoReveal!==void 0&&n.setAutoReveal(r,t.autoReveal),this._onDidAddGroup.fire(r);let o={element:r.element,get headerPosition(){return r.model.headerPosition},layout:(e,t)=>r.layout(e,t)};return this._shellManager.addEdgeView(e,t,o),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=A2(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.pinEdgeGroup`))==null||t.pin(e)}autoHideEdgeGroup(e){var t;(t=A2(this._moduleRegistry.services.autoHideEdgeGroupService,`AutoHideEdgeGroup`,`api.autoHideEdgeGroup`))==null||t.autoHide(e)}peekEdgeGroup(e,t){var n;(n=A2(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=A2(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),this.activateFallbackGroupIfRemoved(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&&O0(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=this.activationTarget(e.group,!1);t&&this.doSetGroupAndPanelActive(t)}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=this.activationTarget(e.group,!0);t&&this.doSetGroupAndPanelActive(t)}activationTarget(e,t){let n=this.getGridviewForGroup(e);if(n.element.contains(e.element)){let r=J$(e.element),i=(t?n.previous(r):n.next(r)).view;if(n===this.gridview||i!==e)return i}let r=[],i=e=>{$$(e)?e.children.forEach(i):r.push(e.view)};i(this.gridview.getView());let a=r.filter(e=>e.api.isVisible);return a[t?a.length-1:0]}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(jQ.from(()=>{var n;this.movingLock(()=>{for(let t of e.panels.slice())e.model.removePanel(t)}),t?.disposable.dispose(),(n=this.headerActionsService)==null||n.disposeGroup(e),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??!1,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.slice())this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(let e of this.groups)this._edgeGroupService?.includes(e)||(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=A2(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,locked:s,hideHeader:c}=i;o.locked=s??!1,o.header.hidden=!!c;let l=[];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)}),l.push(e),e.updateFromStateModel(t[i]);else{let e=this._deserializer.fromJSON(t[i],o);l.push(e)}}for(let e of l){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?A2(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})}else this.removeGroup(t,{skipActive:!0});t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){this.mutation(`remove`,()=>{let e=Array.from(this._groups.values()).map(e=>e.value);for(let t of e){if(!this._groups.has(t.id))continue;t.model.closeAllPanels();let e=this.options.noPanelsOverlay===`emptyGroup`&&this.isLastGridGroup(t);!this.closeEmptyGroups&&!e&&this._groups.has(t.id)&&t.model.size===0&&this.removeGroup(t,{skipActive:!0})}})}addPanel(e){return this.mutation(`add`,()=>this._doAddPanel(e))}addPanelFromJSON(e,t){if(!e.contentComponent)throw Error(`dockview: serialized panel ${e.id} has no contentComponent`);return this.mutation(`add`,()=>{let n=this._doAddPanel(f1(f1({},t),{},{id:e.id,component:e.contentComponent,tabComponent:e.tabComponent,title:e.title,renderer:e.renderer,params:e.params,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight}));return e.pinned&&this.setPanelPinned(n,!0),n})}_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(M0(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(N0(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(M1(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=a1(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,f1(f1({},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===`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=this.getGridviewForGroup(t),c=J$(t.element),l=Y$(s.orientation,c,o),u=this.createGroupAtLocation(l,this.orientationAtLocation(l,s)===`VERTICAL`?n?.height:n?.width,void 0,s);a=this.createPanel(e,u),u.model.openPanel(a,{skipSetActive:i(u),skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(u)}}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,f1(f1({},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??this.closeEmptyGroups,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 b2}addGroup(e){return this.mutation(`add`,()=>this._doAddGroup(e))}serializeGroup(e){let t={};for(let n of e.panels)t[n.id]=n.toJSON();return{group:e.model.toJSON(),panels:t}}addGroupFromJSON(e,t){return this.validateSerializedGroup(e),this.mutation(`add`,()=>this._doAddGroupFromJSON(e,t))}validateSerializedGroup(e){let t=e?.group;if(typeof t?.id!=`string`)throw TypeError(`dockview: group id must be of type string`);if(!Array.isArray(t.views))throw TypeError(`dockview: serialized group ${t.id} has no views`);for(let n of t.views){if(!e.panels?.[n])throw Error(`dockview: serialized group ${t.id} is missing panel state for ${n}`);if(this.panels.some(e=>e.id===n))throw Error(`dockview: panel with id ${n} already exists`)}}_doAddGroupFromJSON(e,t){let{id:n,locked:r,hideHeader:i,headerPosition:a,constraints:o,activeView:s,tabGroups:c}=e.group;if(t&&(t.direction??`within`)===`within`){let n=this.resolveReferenceGroup(t);if(n)return this.mergeGroupFromJSON(e,n,t)}let l={id:n,locked:r??!1,hideHeader:!!i,headerPosition:a,constraints:o,initialWidth:t?.initialWidth,initialHeight:t?.initialHeight,skipSetActive:!0},u=this.addEmptyGroupAt(l,t),d;try{d=this.deserializePanels(e,u)}catch(e){throw this.doRemoveGroup(u,{skipActive:!0}),e}for(let e of d)u.model.openPanel(e,{skipSetActive:e.id!==s,skipSetGroupActive:!0});return c&&c.length>0&&u.model.restoreTabGroups(c),!u.activePanel&&u.panels.length>0&&u.model.openPanel(u.panels[u.panels.length-1],{skipSetGroupActive:!0}),t?.skipSetActive||this.doSetGroupAndPanelActive(u),u}addEmptyGroupAt(e,t){if(t!==void 0&&(P0(t)||F0(t)||typeof t.direction==`string`))return this._doAddGroup(f1(f1({},t),e));let n=this.createGroup(e);return this.doAddGroup(n),n}deserializePanels(e,t){let n=[];try{for(let r of e.group.views)n.push(this._deserializer.fromJSON(e.panels[r],t))}catch(e){for(let e of n)e.dispose();throw e}return n}resolveReferenceGroup(e){if(P0(e)){let t=typeof e.referencePanel==`string`?e.referencePanel:e.referencePanel.id,n=this.getGroupPanel(t);if(!n)throw Error(`dockview: reference panel ${t} does not exist`);return n.group}if(F0(e)){let t=typeof e.referenceGroup==`string`?e.referenceGroup:e.referenceGroup.id,n=this.getPanel(t);if(!n)throw Error(`dockview: reference group ${t} does not exist`);return n}}mergeGroupFromJSON(e,t,n){let{activeView:r}=e.group,i=n.index;return this.deserializePanels(e,t).forEach((e,n)=>{t.model.openPanel(e,{index:i===void 0?void 0:i+n,skipSetActive:e.id!==r,skipSetGroupActive:!0})}),n.skipSetActive||this.doSetGroupAndPanelActive(t),t}_doAddGroup(e){if(e){let t;if(P0(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(F0(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(M1(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}let n=a1(e.direction||`within`),r=this.getGridviewForGroup(t),i=J$(t.element),a=Y$(r.orientation,i,n),o=this.orientationAtLocation(a,r)===`VERTICAL`?e.initialHeight:e.initialWidth,s=this.createGroupAtLocation(a,o,e,r);return e.skipSetActive||this.doSetGroupAndPanelActive(s),s}{let t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}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.closeEmptyGroups||!e.api.isVisible)&&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);this._syncMutationDepth++;try{return t()}finally{this._syncMutationDepth--,this._syncMutationDepth===0&&this.releaseDisposedActiveGroup(),n()}}mutationAsync(e,t){var n=this;return y$(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.releaseDisposedActiveGroup(),this.flushLocationChanges(),this._onDidMutateLayout.fire({kind:e,origin:t}))}}releaseDisposedActiveGroup(){!this.isDisposed&&this._activeGroup?.model.isDisposed&&this.activateFallbackGroupIfRemoved(this._activeGroup)}deferLocationChange(e,t){this._mutationDepth===0?t():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});else 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}`);!this.keepEmptyGroups(e)&&o.model.size===0&&o!==t&&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 n=this.getGridviewForGroup(t),a=J$(t.element),s=Y$(n.orientation,a,i);if(o.size<2&&!this.keepEmptyGroups(e)){if(o===t)return;let[e,c]=T$(s);if(o.api.location.type===`grid`&&n===this.gridview){let[n,i]=T$(J$(o.element));if((this.options.dropSizing!==`distribute`||o===t)&&E$(n,e)){this.gridview.moveView(n,i,c),this.fireDidMovePanel(this.getGroupPanel(r),o);return}}if(o.api.location.type===`popout`&&this.nestedWindowMembers(o).length<=1){let e=this._popoutWindowService?.findByGroup(o);if(!e)return;let a=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(o,{skipActive:!0});let s=Y$(n.orientation,J$(t.element),i),c=this.createGroupAtLocation(s,this.sizingForDrop(J$(t.element)),void 0,n);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 e=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!e)throw Error(`dockview: No panel with id ${r}`);let t=this.createGroupAtLocation(s,this.sizingForDrop(a),void 0,n);this.movingLock(()=>t.model.openPanel(e,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(t),this.fireDidMovePanel(e,o);return}let l=this.movingLock(()=>this.doRemoveGroup(o,{skipActive:!0,skipDispose:!0})),u=J$(t.element),d=Y$(n.orientation,u,i);this.movingLock(()=>this.doAddGroup(l,d,this.sizingForDrop(u),n)),this.setGroupLocationForRoot(l,n),this.doSetGroupAndPanelActive(l),this.fireDidMovePanel(this.getGroupPanel(r),o)}else{let e=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!e)throw Error(`dockview: No panel with id ${r}`);let t=Y$(n.orientation,a,i),s=this.createGroupAtLocation(t,this.sizingForDrop(a),void 0,n);this.movingLock(()=>s.model.openPanel(e,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(s),this.fireDidMovePanel(e,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`?J$(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=this.getGridviewForGroup(r),t=Y$(e.orientation,f,i);h=this.createGroupAtLocation(t,this.sizingForDrop(f),void 0,e)}!this.keepEmptyGroups(e)&&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;if(r===`center`&&t===n)return;let 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{let e=(()=>{if(t.api.location.type===`edge`||n.api.location.type===`edge`)return!1;let e=this.getGridviewForGroup(t);if(e!==this.getGridviewForGroup(n))return!1;let i,a;try{i=J$(t.element),a=J$(n.element)}catch{return!1}return i.length===0||a.length===0?!1:E$(T$(i)[0],T$(a)[0])&&Z$(e.orientation,a)===X$(r)})();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(J$(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 a=this.getGridviewForGroup(n),o=J$(n.element),s=Y$(a.orientation,o,r),c;c=e&&this.options.dropSizing!==`distribute`?X$(r)===`HORIZONTAL`?t.api.width:t.api.height:this.sizingForDrop(o),a.addView(i,c,s),this.setGroupLocationForRoot(i,a)}}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.options.groupIdGenerator;if(!e){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}for(let t=0;t<W4;t++){let t=e();if(typeof t!=`string`||t.length===0)throw TypeError(`dockview: groupIdGenerator must return a non-empty string`);if(!this._groups.has(t))return t}throw Error(`dockview: groupIdGenerator returned an id already in use ${W4} times in a row`)}createGroup(e){e??={};let t=e?.id;t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),t||=this.getNextGroupId();let n=new p2(this,t,e);if(n.init({params:{},accessor:this}),!this._groups.has(n.id)){let e=new X(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;this.options.disableDnd?e.preventDefault():(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)}),n.model.onDidPanelTitleChange(()=>{this._bufferOnDidLayoutChange.fire(`panelTitle`)}),n.model.onDidPanelParametersChange(()=>{this._bufferOnDidLayoutChange.fire(`panelParameters`)}));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 v2(this,e.id,n,r),a=new g2(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}sizingForDrop(e){return this.options.dropSizing===`distribute`?L$.Distribute:L$.Split(e.length===0?0:e[e.length-1])}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);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}):(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,t=this.gridview){let n=t.orientation;return e.length%2==1?n:Q$(n)}updateTheme(){var e,t;let n=this._options.theme??m2;(e=this._shellThemeClassnames)==null||e.setClassNames(n.className);let r=n.gap??0;this.gridview.margin=r;for(let e of this.nestedGridviews())e.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()}},K4=class extends o1{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout??!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new Z,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new Z,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new Z,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new Z,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)})),this.layoutFromElement()}updateOptions(e){super.updateOptions(e);let t=typeof e.orientation==`string`&&this.gridview.orientation!==e.orientation;this._options=f1(f1({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){return{grid:this.gridview.serialize(),activePanel:this.activeGroup?.id}}setVisible(e,t){this.gridview.setViewVisible(J$(e.element),t)}setActive(e){this._groups.forEach((t,n)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)==null||e.focus()}fromJSON(e){this.clear();let{grid:t,activePanel:n}=e;try{let e=[],r=this.width,i=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{let{data:n}=t,r=this.options.createComponent({id:n.id,name:n.component});return e.push(()=>r.init({params:n.params,minimumWidth:n.minimumWidth,maximumWidth:n.maximumWidth,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,priority:n.priority,snap:!!n.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(r),this.registerPanel(r),r}}),this.layout(r,i,!0),e.forEach(e=>e()),typeof n==`string`){let e=this.getPanel(n);e&&this.doSetGroupActive(e)}}catch(e){for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){let e=this.activeGroup,t=Array.from(this._groups.values());for(let e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){let n=this._groups.get(t.reference)?.value;if(!n)throw Error(`reference group ${t.reference} does not exist`);let r=a1(t.direction);if(r===`center`)throw Error(`${r} not supported as an option`);let i=J$(n.element),a=Y$(this.gridview.orientation,i,r),o=this.gridview.remove(e);this.doAddGroup(o,a,t.size)}addPanel(e){let t=e.location??[0];if(e.position?.referencePanel){let n=this._groups.get(e.position.referencePanel)?.value;if(!n)throw Error(`reference group ${e.position.referencePanel} does not exist`);let r=a1(e.position.direction);if(r===`center`)throw Error(`${r} not supported as an option`);{let e=J$(n.element);t=Y$(this.gridview.orientation,e,r)}}let n=this.options.createComponent({id:e.id,name:e.component});return n.init({params:e.params??{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(n,t,e.size),this.registerPanel(n),this.doSetGroupActive(n),n}registerPanel(e){let t=new X(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{let n=t.value;n.setActive(n===e)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,n){let r=this.getPanel(t);if(!r)throw Error(`invalid operation`);let i=J$(e.element),[a,o]=T$(Y$(this.gridview.orientation,i,n)),[s,c]=T$(J$(r.element));if(E$(s,a)){this.gridview.moveView(s,c,o);return}let l=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),u=J$(e.element),d=Y$(this.gridview.orientation,u,n);this.doAddGroup(l,d)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},q4=class extends r1{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new X(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire({reasons:new Set([`geometry`])})}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===`HORIZONTAL`?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===`HORIZONTAL`?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._splitviewChangeDisposable=new MQ,this._panels=new Map,this._onDidLayoutfromJSON=new Z,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new Z,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Z,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new Z,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new l$(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.splitview=new R$(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange),this.layoutFromElement()}updateOptions(e){if(`className`in e&&this._classNames.setClassNames(e.className??``),`disableAutoResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),typeof e.orientation==`string`&&e.orientation!==this.splitview.orientation){this.splitview.orientation=e.orientation;for(let t of this.panels)t.orientation=e.orientation}this._options=f1(f1({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)==null||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){let n=this.panels.indexOf(e);this.splitview.setViewVisible(n,t)}setActive(e,t){this._activePanel=e,this.panels.filter(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){let n=this._panels.get(e.id);if(!n)throw Error(`unknown splitview panel ${e.id}`);n.dispose(),this._panels.delete(e.id);let r=this.panels.indexOf(e);this.splitview.removeView(r,t).dispose();let i=this.panels;i.length>0&&this.setActive(i[i.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){if(this._panels.has(e.id))throw Error(`panel ${e.id} already exists`);let t=this.options.createComponent({id:e.id,name:e.component});t.orientation=this.splitview.orientation,t.init({params:e.params??{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});let n=typeof e.size==`number`?e.size:L$.Distribute,r=typeof e.index==`number`?e.index:void 0;return this.splitview.addView(t,n,r),this.doAddView(t),this.setActive(t),t}layout(e,t){let[n,r]=this.splitview.orientation===`HORIZONTAL`?[e,t]:[t,e];this.splitview.layout(n,r)}doAddView(e){let t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){return{views:this.splitview.getViews().map((e,t)=>{let n=this.splitview.getViewCachedVisibleSize(t),r=typeof n==`number`;return f1({size:r?n:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority},r?{visible:!1}:{})}),activeView:this._activePanel?.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();let{views:t,orientation:n,size:r,activeView:i}=e,a=[],o=this.width,s=this.height;if(this.splitview=new R$(this.element,{orientation:n,proportionalLayout:this.options.proportionalLayout,descriptor:{size:r,views:t.map(e=>{let t=e.data;if(this._panels.has(t.id))throw Error(`panel ${t.id} already exists`);let r=this.options.createComponent({id:t.id,name:t.component});return a.push(()=>{r.init({params:t.params??{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this}),e.visible===!1&&r.setVisible(!1)}),r.orientation=n,this.doAddView(r),setTimeout(()=>{this._onDidAddView.fire(r)},0),{size:e.size,view:r,visible:e.visible}})}}),this.layout(o,s),a.forEach(e=>e()),typeof i==`string`){let e=this.getPanel(i);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(let e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,L$.Distribute,!0).dispose()}dispose(){for(let e of this._panels.values())e.dispose();this._panels.clear();let e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(let t of e)t.dispose();this.element.remove(),super.dispose()}},J4=class extends X{get element(){return this._element}constructor(){super(),this._expandedIcon=p0(),this._collapsedIcon=m0(),this.disposable=new MQ,this.apiRef={api:null},this._element=document.createElement(`div`),this.element.className=`dv-default-header`,this._content=document.createElement(`span`),this._expander=document.createElement(`div`),this._expander.className=`dv-pane-header-icon`,this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(Q(this._element,`click`,()=>{var e;(e=this.apiRef.api)==null||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){let e=!!this.apiRef.api?.isExpanded;$(this._expander,`collapsed`,!e),e?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}},Y4=M$(),X4=22,Z4=0,Q4=2**53-1,$4=class extends o0{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},e3=class extends r1{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new X(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire({reasons:new Set([`geometry`])})}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===`HORIZONTAL`?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===`HORIZONTAL`?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=Y4.next(),this._disposable=new MQ,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new Z,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new Z,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new Z,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new Z,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new Z,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOver=new Z,this.onUnhandledDragOver=this._onUnhandledDragOver.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOver),this._classNames=new l$(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.paneview=new B$(this.element,{orientation:`VERTICAL`}),this.addDisposables(this._disposable)}setVisible(e,t){let n=this.panels.indexOf(e);this.paneview.setViewVisible(n,t)}focus(){}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableAutoResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),this._options=f1(f1({},this.options),e)}addPanel(e){let t=this.options.createComponent({id:e.id,name:e.component}),n;e.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),n??=new J4;let r=new $4({id:e.id,component:e.component,headerComponent:e.headerComponent,header:n,body:t,orientation:`VERTICAL`,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??X4,minimumBodySize:Z4,maximumBodySize:Q4});this.doAddPanel(r);let i=typeof e.size==`number`?e.size:L$.Distribute,a=typeof e.index==`number`?e.index:void 0;return r.init({params:e.params??{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new v1(this),accessor:this}),this.paneview.addPane(r,i,a),r.orientation=this.paneview.orientation,r}removePanel(e){let t=this.panels.indexOf(e);if(t<0)throw Error(`unknown paneview panel ${e.id}`);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){let[n,r]=this.paneview.orientation===`HORIZONTAL`?[e,t]:[t,e];this.paneview.layout(n,r)}toJSON(){let e=e=>e===2**53-1||e===1/0?void 0:e,t=e=>e<=0?void 0:e;return{views:this.paneview.getPanes().map((n,r)=>{let i=this.paneview.getViewCachedVisibleSize(r),a=typeof i==`number`;return f1({size:a?i:this.paneview.getViewSize(r),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()},a?{visible:!1}:{})}),size:this.paneview.size}}fromJSON(e){this.clear();let{views:t,size:n}=e,r=[],i=this.width,a=this.height;this.paneview.dispose(),this.paneview=new B$(this.element,{orientation:`VERTICAL`,descriptor:{size:n,views:t.map(e=>{let t=e.data,n=this.options.createComponent({id:t.id,name:t.component}),i;t.headerComponent&&this.options.createHeaderComponent&&(i=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),i??=new J4;let a=new $4({id:t.id,component:t.component,headerComponent:t.headerComponent,header:i,body:n,orientation:`VERTICAL`,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??X4,minimumBodySize:e.minimumSize??Z4,maximumBodySize:e.maximumSize??Q4});return this.doAddPanel(a),r.push(()=>{a.init({params:t.params??{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new v1(this),accessor:this}),a.orientation=this.paneview.orientation,e.visible===!1&&a.setVisible(!1)}),setTimeout(()=>{this._onDidAddView.fire(a)},0),{size:e.size,view:a,visible:e.visible}})}}),this.layout(i,a),r.forEach(e=>e()),this._onDidLayoutfromJSON.fire()}clear(){for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear();let e=this.width,t=this.height;this.paneview.dispose(),this.paneview=new B$(this.element,{orientation:`VERTICAL`}),this.layout(e,t)}doAddPanel(e){let t=new X(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOver(e=>{this._onUnhandledDragOver.fire(e)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){let t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},t3=class extends i0{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){let e=typeof this._minimumSize==`function`?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){let e=typeof this._maximumSize==`function`?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new n0(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=1/0,this._minimumSize=0,this._maximumSize=1/0,this._snap=!1,this._onDidChange=new Z,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,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.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumSize==`number`||typeof e.minimumSize==`function`)&&(this._minimumSize=e.minimumSize),(typeof e.maximumSize==`number`||typeof e.maximumSize==`function`)&&(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){let[n,r]=this.orientation===`HORIZONTAL`?[e,t]:[t,e];super.layout(n,r)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return f1(f1({},super.toJSON()),{},{minimumSize:(e=>e<=0?void 0:e)(this.minimumSize),maximumSize:(e=>e===2**53-1||e===1/0?void 0:e)(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function n3(e,t){return new G4(e,t).api}function r3(e,t){return new _1(new q4(e,t))}function i3(e,t){return new y1(new K4(e,t))}function a3(e,t){return new v1(new e3(e,t))}function o3(e){"@babel/helpers - typeof";return o3=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},o3(e)}function s3(e,t){if(o3(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o3(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c3(e){var t=s3(e,`string`);return o3(t)==`symbol`?t:t+``}function l3(e,t,n){return(t=c3(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u3(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 d3(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u3(Object(n),!0).forEach(function(t){l3(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u3(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var f3=(e,t)=>{let[,n]=H.useState(0),r=H.useRef(e.componentProps);return H.useImperativeHandle(t,()=>({update:e=>{r.current=d3(d3({},r.current),e),n(e=>e+1)}}),[]),H.createElement(e.component,r.current)};f3.displayName=`DockviewReactJsBridge`;var p3=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),m3=H.createContext({}),h3=class{constructor(e,t,n,r,i){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=i,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);this.componentInstance?this.componentInstance.update(e):this._initialProps=d3(d3({},this._initialProps),e)}createPortal(){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);if(!_3(this.component))throw Error(`Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components`);let e=H.createElement(H.forwardRef(f3),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?H.createElement(m3.Provider,{value:this.context},e):e,n=lp.createPortal(t,this.parent,p3.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;(e=this.ref)==null||e.disposable.dispose(),this.disposed=!0}},g3=()=>{let[e,t]=H.useState([]);return H.useDebugValue(`Portal count: ${e.length}`),[e,H.useCallback(e=>{t(t=>[...t,e]);let n=!1;return jQ.from(()=>{if(n)throw Error(`invalid operation: resource already disposed`);n=!0,t(t=>t.filter(t=>t!==e))})},[])]};function _3(e){return typeof e==`function`||!!e?.$$typeof}function v3(e,t){let n=e=>e instanceof ShadowRoot?e.host:e.parentNode,r=new Set,i=new MutationObserver(n=>{if(!e.isConnected)i.disconnect(),t();else for(let e of n)for(let t of e.removedNodes)if(r.has(t)){a();return}}),a=()=>{i.disconnect(),r.clear();for(let t=n(e);t;t=n(t))r.add(t),i.observe(t,{childList:!0})};return a(),jQ.from(()=>i.disconnect())}var y3=Number.parseInt(`19.3.1`,10)>=18;function b3(e,t,n){let r=H.useRef(void 0);H.useEffect(()=>{var i;let a=e.current;if(!a)return;(i=r.current)==null||i.dispose(),r.current=void 0;let o=t.current??n(a);return t.current=o,()=>{let e=()=>{r.current=void 0,t.current=void 0,o.dispose()};y3&&a.isConnected&&typeof MutationObserver<`u`?r.current=v3(a,e):e()}},[])}function x3(e){let t=H.useRef({instance:void 0,values:new Map});return H.useCallback(n=>{t.current.instance!==e.current&&(t.current={instance:e.current,values:new Map});let r=t.current.values,i=!0;for(let[e,t]of Object.entries(n))r.has(e)&&r.get(e)!==t&&(i=!1),r.set(e,t);return i},[e])}var S3=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,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-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new h3(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)==null||e.dispose()}},C3=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new h3(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},w3=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new h3(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t;this.parameters&&(this.parameters.params=e.params),(t=this.part)==null||t.update({params:this.parameters?.params??{}})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},T3=class{get element(){return this._element}get part(){return this._part}constructor(e,t,n){this.component=e,this.reactPortalStore=t,this._group=n,this.mutableDisposable=new MQ,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.mutableDisposable.value=new X(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new h3(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)==null||e.dispose()}update(e){var t;(t=this._part)==null||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}},E3=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new h3(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;(e=this.part)==null||e.dispose()}},D3=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new h3(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;(t=this.part)==null||t.update({tabGroup:e.tabGroup})}dispose(){var e;(e=this.part)==null||e.dispose()}},O3=class{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.display=`inline-flex`}init(e){this.part=new h3(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;(e=this.part)==null||e.dispose()}};function k3(e,t){return e?n=>new T3(e,t,n):void 0}var A3=`props.defaultTabComponent`;function j3(e){return j0.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var M3=H.forwardRef((e,t)=>{let n=H.useRef(null),r=H.useRef(void 0),[i,a]=g3(),o=x3(r);H.useImperativeHandle(t,()=>n.current,[]);let s=H.useRef({});return H.useEffect(()=>{let t={};j0.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},j0.map(t=>e[t])),b3(n,r,t=>{let n=d3({},e.tabComponents);e.defaultTabComponent&&(n[A3]=e.defaultTabComponent);let r={createLeftHeaderActionComponent:k3(e.leftHeaderActionsComponent,{addPortal:a}),createRightHeaderActionComponent:k3(e.rightHeaderActionsComponent,{addPortal:a}),createPrefixHeaderActionComponent:k3(e.prefixHeaderActionsComponent,{addPortal:a}),createComponent:t=>new S3(t.id,e.components[t.name],{addPortal:a}),createTabComponent(e){return new C3(e.id,n[e.name],{addPortal:a})},createWatermarkComponent:e.watermarkComponent?()=>new w3(`watermark`,e.watermarkComponent,{addPortal:a}):void 0,defaultTabComponent:e.defaultTabComponent?A3:void 0,createContextMenuItemComponent:e=>{if(e.component)return new E3(e.id,e.component,{addPortal:a})}},i=j3(e);if(e.tabGroupChipComponent){let t=e.tabGroupChipComponent;i.createTabGroupChipComponent=()=>new D3(t,{addPortal:a})}if(e.groupDragGhostComponent){let t=e.groupDragGhostComponent;i.createGroupDragGhostComponent=()=>new O3(t,{addPortal:a})}let o=n3(t,d3(d3({},i),r)),{clientWidth:s,clientHeight:c}=t;return o.layout(s,c),e.onReady&&e.onReady({api:o}),o}),H.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),H.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),H.useEffect(()=>{r.current&&!o({tabGroupChipComponent:e.tabGroupChipComponent})&&r.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new D3(e.tabGroupChipComponent,{addPortal:a}):void 0})},[e.tabGroupChipComponent]),H.useEffect(()=>{r.current&&!o({groupDragGhostComponent:e.groupDragGhostComponent})&&r.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new O3(e.groupDragGhostComponent,{addPortal:a}):void 0})},[e.groupDragGhostComponent]),H.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new S3(t.id,e.components[t.name],{addPortal:a})})},[e.components]),H.useEffect(()=>{if(!r.current||o({tabComponents:e.tabComponents,defaultTabComponent:e.defaultTabComponent}))return;let t=d3({},e.tabComponents);e.defaultTabComponent&&(t[A3]=e.defaultTabComponent),r.current.updateOptions({defaultTabComponent:e.defaultTabComponent?A3:void 0,createTabComponent(e){return new C3(e.id,t[e.name],{addPortal:a})}})},[e.tabComponents,e.defaultTabComponent]),H.useEffect(()=>{r.current&&!o({watermarkComponent:e.watermarkComponent})&&r.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new w3(`watermark`,e.watermarkComponent,{addPortal:a}):void 0})},[e.watermarkComponent]),H.useEffect(()=>{r.current&&!o({rightHeaderActionsComponent:e.rightHeaderActionsComponent})&&r.current.updateOptions({createRightHeaderActionComponent:k3(e.rightHeaderActionsComponent,{addPortal:a})})},[e.rightHeaderActionsComponent]),H.useEffect(()=>{r.current&&!o({leftHeaderActionsComponent:e.leftHeaderActionsComponent})&&r.current.updateOptions({createLeftHeaderActionComponent:k3(e.leftHeaderActionsComponent,{addPortal:a})})},[e.leftHeaderActionsComponent]),H.useEffect(()=>{r.current&&!o({prefixHeaderActionsComponent:e.prefixHeaderActionsComponent})&&r.current.updateOptions({createPrefixHeaderActionComponent:k3(e.prefixHeaderActionsComponent,{addPortal:a})})},[e.prefixHeaderActionsComponent]),H.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});M3.displayName=`DockviewComponent`;var N3=class extends t3{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new h3(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new _1(this._params.accessor)})}};function P3(e){return z$.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var F3=H.forwardRef((e,t)=>{let n=H.useRef(null),r=H.useRef(void 0),[i,a]=g3(),o=x3(r);H.useImperativeHandle(t,()=>n.current,[]);let s=H.useRef({});return H.useEffect(()=>{let t={};z$.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},z$.map(t=>e[t])),b3(n,r,t=>{let n=r3(t,d3(d3({},P3(e)),{createComponent:t=>new N3(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:r,clientHeight:i}=t;return n.layout(r,i),e.onReady&&e.onReady({api:n}),n}),H.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new N3(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),H.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});F3.displayName=`SplitviewComponent`;var I3=class extends c2{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new h3(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new y1(this._params.accessor)})}};function L3(e){return n1.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var R3=H.forwardRef((e,t)=>{let n=H.useRef(null),r=H.useRef(void 0),[i,a]=g3(),o=x3(r);H.useImperativeHandle(t,()=>n.current,[]);let s=H.useRef({});return H.useEffect(()=>{let t={};n1.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},n1.map(t=>e[t])),b3(n,r,t=>{let n=i3(t,d3(d3({},L3(e)),{createComponent:t=>new I3(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:r,clientHeight:i}=t;return n.layout(r,i),e.onReady&&e.onReady({api:n}),n}),H.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new I3(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),H.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});R3.displayName=`GridviewComponent`;var z3=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new h3(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)==null||t.update({params:e.params})}dispose(){var e;(e=this.part)==null||e.dispose()}};function B3(e){return Q1.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var V3=H.forwardRef((e,t)=>{let n=H.useRef(null),r=H.useRef(void 0),[i,a]=g3(),o=x3(r);H.useImperativeHandle(t,()=>n.current,[]);let s=H.useRef({});return H.useEffect(()=>{let t={};Q1.forEach(n=>{let r=n,i=e[r];r in e&&i!==s.current[r]&&(t[r]=i)}),r.current&&Object.keys(t).length>0&&r.current.updateOptions(t),s.current=e},Q1.map(t=>e[t])),b3(n,r,t=>{let n=e.headerComponents??{},r=a3(t,d3(d3({},B3(e)),{createComponent:t=>new z3(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new z3(e.id,n[e.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=t;return r.layout(i,o),e.onReady&&e.onReady({api:r}),r}),H.useEffect(()=>{r.current&&!o({components:e.components})&&r.current.updateOptions({createComponent:t=>new z3(t.id,e.components[t.name],{addPortal:a})})},[e.components]),H.useEffect(()=>{if(!r.current||o({headerComponents:e.headerComponents}))return;let t=e.headerComponents??{};r.current.updateOptions({createHeaderComponent:e=>new z3(e.id,t[e.name],{addPortal:a})})},[e.headerComponents]),H.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),H.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});V3.displayName=`PaneviewComponent`;var H3=e=>e>99?`99+`:String(e),U3=()=>{let{count:e}=yb(sb().followUpsDue);return e===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:EY.tabCount,children:H3(e)}),(0,K.jsx)(Dk,{children:`, ${String(e)} due`})]})},W3=e=>{let{count:t}=yb(sb().followUpsDue);return t===0?e:`${e}, ${String(t)} due`},G3={dock:`_dock_psx21_10`,tab:`_tab_psx21_155`,buttons:`_buttons_psx21_178`,body:`_body_psx21_189`,heading:`_heading_psx21_197`,none:`_none_psx21_209`},K3=({label:e,shortcut:t,onClick:n,children:r})=>{let i=mA();return(0,K.jsx)(Sb,{"aria-keyshortcuts":cA(t,i),keys:sA(t,i),label:e,onClick:n,children:r})},q3=({group:e,activePanel:t,workspace:n})=>{yb(n.view);let r=t?.title??`panel`,i=t!==void 0&&vQ(t.id)?t.id:void 0,a=e.api.location.type===`floating`,o=e.api.isMaximized();return(0,K.jsxs)(`div`,{className:G3.buttons,children:[(0,K.jsx)(K3,{label:`Minimize ${r}`,onClick:()=>{n.minimize(i)},shortcut:dA.minimize,children:(0,K.jsx)(vy,{})}),a?null:(0,K.jsx)(K3,{label:o?`Restore ${r}`:`Maximize ${r}`,onClick:()=>{n.toggleMaximize(e)},shortcut:dA.maximize,children:o?(0,K.jsx)(by,{}):(0,K.jsx)(yy,{})}),(0,K.jsx)(K3,{label:a?`Dock ${r}`:`Float ${r}`,onClick:()=>{n.toggleFloat(e)},shortcut:dA.float,children:a?(0,K.jsx)(Sy,{}):(0,K.jsx)(xy,{})}),(0,K.jsx)(K3,{label:`Close ${r}`,onClick:()=>{n.close(i)},shortcut:dA.close,children:(0,K.jsx)(sy,{})})]})},J3=e=>{let t=(0,H.use)(wU);return t===null?null:(0,K.jsx)(q3,{...e,workspace:t})},Y3=6,X3=({api:e})=>{let t=vQ(e.id)?yQ(e.id).Icon:null;return(0,K.jsxs)(`span`,{className:G3.tab,children:[t===null?null:(0,K.jsx)(t,{}),e.title,e.id===`followups`?(0,K.jsx)(U3,{}):null]})},Z3=()=>(0,K.jsx)(`div`,{className:G3.none,children:(0,K.jsx)(dO,{title:`No panels open.`,children:`Reopen one from Window, or press the command palette's keys.`})}),Q3=Object.fromEntries(_Q.map(({id:e,title:t,Body:n})=>[e,()=>(0,K.jsxs)(`div`,{className:G3.body,children:[(0,K.jsx)(`h2`,{className:G3.heading,children:t}),(0,K.jsx)(n,{})]})])),$3={name:`ork`,className:G3.dock??``,gap:Y3,dndOverlayMounting:`relative`,dndPanelOverlay:`group`,dndTabIndicator:`line`},e6=({workspace:e})=>{let t=(0,H.useCallback)(({api:t})=>{e.attach(t)},[e]);return(0,H.useEffect)(()=>()=>{e.detach()},[e]),(0,K.jsx)(M3,{announcer:({message:t})=>{e.announceFromDock(t)},components:Q3,defaultTabComponent:X3,disableTabsOverflowList:!0,onReady:t,rightHeaderActionsComponent:J3,theme:$3,watermarkComponent:Z3})},t6=`(min-width: 64rem)`,n6=(e,t,n)=>{let r=e?.panels??[],i=e?.activePanel?.id;return{wide:n,open:_Q.map(e=>e.id).filter(e=>r.some(t=>t.id===e)),minimized:t.minimized.map(e=>e.id),folded:t.folded,active:i!==void 0&&vQ(i)?i:null,floating:e?.activePanel?.group.api.location.type===`floating`,maximized:e?.hasMaximizedGroup()??!1}},r6=(e,t)=>JSON.stringify(e)===JSON.stringify(t),i6=e=>`stack-${e}`,a6=e=>`rail-${e}`,o6=e=>{document.querySelector(`#${e}`)?.focus()},s6=({id:e,name:t,workspace:n})=>{let{Icon:r}=yQ(e);return(0,K.jsx)(Sb,{id:a6(e),label:`Restore ${t}`,onClick:()=>{n.restore(e)},children:(0,K.jsx)(r,{})})},c6=({workspace:e})=>(0,K.jsx)(s6,{id:`followups`,name:W3(yQ(`followups`).title),workspace:e}),l6=({id:e,workspace:t})=>e===`followups`?(0,K.jsx)(c6,{workspace:t}):(0,K.jsx)(s6,{id:e,name:yQ(e).title,workspace:t}),u6=({workspace:e})=>{let{minimized:t}=yb(e.view);return t.length===0?null:(0,K.jsx)(`nav`,{"aria-label":`Minimized panels`,className:_A.rail,children:t.map(t=>(0,K.jsx)(l6,{id:t,workspace:e},t))})},d6=({workspace:e})=>{let{folded:t}=yb(e.view);return(0,K.jsx)(`div`,{className:_A.stack,children:_Q.map(({id:n,title:r,Icon:i,Body:a})=>{let o=!t.includes(n),s=`${i6(n)}-body`;return(0,K.jsxs)(`section`,{"aria-labelledby":i6(n),className:_A.stacked,children:[(0,K.jsx)(`h2`,{className:_A.stackedHeading,children:(0,K.jsxs)(`button`,{"aria-controls":o?s:void 0,"aria-expanded":o,className:_A.stackedButton,id:i6(n),onClick:()=>{e.toggleFold(n)},type:`button`,children:[o?(0,K.jsx)(ly,{}):(0,K.jsx)(uy,{}),(0,K.jsx)(i,{}),r]})}),o?(0,K.jsx)(`div`,{className:_A.stackedBody,id:s,children:(0,K.jsx)(a,{})}):null]},n)})})},f6=e=>{(0,H.useEffect)(()=>{let t=window.matchMedia(t6),n=()=>{e.setWide(t.matches)};return n(),t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}},[e])},p6=({workspace:e})=>{let{wide:t}=yb(e.view);return f6(e),(0,K.jsx)(`main`,{className:_A.middle,children:t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u6,{workspace:e}),(0,K.jsx)(`div`,{className:_A.dockArea,children:(0,K.jsx)(e6,{workspace:e})})]}):(0,K.jsx)(d6,{workspace:e})})},m6=`ork-new-version-action`,h6=(e,t,n)=>e?.version===t&&n-Date.parse(e.at)<864e5,g6=(e,t,n)=>{let{job:r}=e;if(r!==null)return r.state===`running`?{kind:`running`,latest:r.latest}:h6(t,r.latest,n)?null:r.state===`succeeded`?{kind:`installed`,latest:r.latest,current:e.current}:{kind:`failed`,latest:r.latest,code:r.code??1}},_6=({info:e,connection:t,pageVersion:n,dismissed:r,now:i})=>{let{server:a}=t;if(t.link!==`open`||a===null||`error`in a)return null;if(n!==null&&a.version!==n)return{kind:`pageOlder`,page:n,server:a.version};if(e===null)return null;let o=g6(e,r,i);if(o!==void 0)return o;let{newer:s,releaseNotes:c}=e;return s===null||c===null||h6(r,s,i)?null:{kind:`newer`,newer:s,current:e.current,releaseNotes:c}},v6=e=>e===null?`none`:`${e.kind}:${`newer`in e?e.newer:`latest`in e?e.latest:e.server}`,y6=e=>e?.kind===`newer`?`Ork ${e.newer} is out. Upgrade… is above the panels.`:e?.kind===`installed`?`Ork ${e.latest} is installed; restart \`ork ui\` to use it.`:e?.kind===`pageOlder`?`This page is from an older Ork. Reload to use ${e.server}.`:null,b6=e=>e.kind===`newer`?e.newer:e.kind===`installed`||e.kind===`failed`?e.latest:null,x6={slot:`_slot_s34lg_8`,banner:`_banner_s34lg_14`,icon:`_icon_s34lg_43`,line:`_line_s34lg_52`,version:`_version_s34lg_59`,link:`_link_s34lg_71`,spacer:`_spacer_s34lg_82`,facts:`_facts_s34lg_86`,factName:`_factName_s34lg_99`,factValue:`_factValue_s34lg_114`,adviceWords:`_adviceWords_s34lg_125`,note:`_note_s34lg_131`,message:`_message_s34lg_142`,alert:`_alert_s34lg_149`,alertIcon:`_alertIcon_s34lg_168`,heading:`_heading_s34lg_175`,glyph:`_glyph_s34lg_189`,clock:`_clock_s34lg_200`,foot:`_foot_s34lg_210`,actions:`_actions_s34lg_220`},S6=({latest:e,current:t})=>(0,K.jsxs)(`p`,{className:x6.line,children:[`Ork`,` `,(0,K.jsx)(`span`,{className:x6.version,"data-new":``,children:e}),` `,`is out (you have `,(0,K.jsx)(`span`,{className:x6.version,children:t}),`).`]}),C6=({url:e,version:t,children:n})=>(0,K.jsxs)(`a`,{className:x6.link,href:e,rel:`noreferrer`,target:`_blank`,children:[n,t===void 0?null:(0,K.jsx)(Dk,{children:` in ${t}`}),(0,K.jsx)(Fy,{}),(0,K.jsx)(Dk,{children:` (opens in a new tab)`})]}),w6=8,T6=({ids:e})=>{if(e.length===0)return null;let t=e.slice(0,w6).map(e=>`\`${e.slice(0,8)}\``),n=e.length-w6,r=n>0?`${t.join(`, `)} and ${String(n)} more`:t.join(`, `);return(0,K.jsxs)(`p`,{className:x6.alert,"data-tone":`note`,children:[(0,K.jsx)(`span`,{className:x6.alertIcon,children:(0,K.jsx)(My,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:`Running now: ${r}. Their next sessions would start from the new install; upgrading after they finish is safer.`})})]})},E6=()=>{let e=document.activeElement;return e===null||e===document.body||e.getAttribute(`role`)===`dialog`},D6=({tone:e,text:t,ref:n})=>{let r=(0,H.useRef)(null),i=n??r;return(0,H.useLayoutEffect)(()=>{i.current?.focus()},[i]),(0,H.useEffect)(()=>{let e=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>{E6()&&i.current?.focus()})});return()=>{cancelAnimationFrame(e)}},[i]),(0,K.jsxs)(`h3`,{className:x6.heading,ref:i,tabIndex:-1,children:[e===void 0?null:(0,K.jsx)(`span`,{className:x6.glyph,"data-tone":e,children:e===`succeeded`?(0,K.jsx)(Xj,{}):(0,K.jsx)($j,{})}),(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:t})})]})},O6=({since:e})=>{let t=_K(!0),n=Math.max(0,Math.floor((t-e)/1e3));return(0,K.jsx)(`span`,{"aria-hidden":`true`,className:x6.clock,children:`${String(n)} s`})},k6=({text:e,icon:t=!1})=>e===null?null:(0,K.jsxs)(`p`,{className:x6.alert,role:`alert`,children:[t?(0,K.jsx)(My,{}):null,(0,K.jsx)(`span`,{children:(0,K.jsx)(J,{text:e})})]}),A6=({why:e,id:t})=>(0,K.jsx)(`output`,{className:x6.note,id:t,children:(0,K.jsx)(J,{text:e??``})}),j6=({note:e,children:t})=>(0,K.jsxs)(`div`,{className:x6.foot,children:[e===void 0?null:(0,K.jsx)(`p`,{className:x6.note,children:(0,K.jsx)(J,{text:e})}),(0,K.jsx)(`div`,{className:x6.actions,children:t})]}),M6=`Dismissed for a day. Upgrade Ork… is in Commands.`,N6=(e,t,n,r)=>{let i=(0,H.useRef)(null),a=v6(e);(0,H.useEffect)(()=>{if(!t)return;let o=i.current;if(i.current=a,o===null||o===a||n)return;let s=y6(e);s!==null&&r.announce(s)},[e,a,t,n,r])},P6=()=>{let[e,t]=(0,H.useState)(Date.now);return(0,H.useEffect)(()=>{let e=setInterval(()=>{t(Date.now())},6e4);return()=>{clearInterval(e)}},[]),e},F6=()=>{window.location.reload()},I6={newer:{label:`Upgrade…`,primary:!0,opens:`ask`},running:{label:`Show output`,primary:!1,opens:`job`},failed:{label:`Show output`,primary:!1,opens:`job`},installed:{label:`Restart…`,primary:!0,opens:`job`},pageOlder:{label:`Reload`,primary:!0,opens:null}},L6=e=>e.kind===`running`?`Upgrading Ork to ${e.latest}…`:e.kind===`failed`?`The upgrade to ${e.latest} did not finish: exit ${String(e.code)}.`:e.kind===`installed`?`Ork ${e.latest} is installed. \`ork ui\` still runs ${e.current} until it restarts.`:`This page is from Ork ${e.page}; \`ork ui\` now runs ${e.server}.`,R6=({banner:e,onOpen:t})=>{let n=I6[e.kind];return(0,K.jsxs)(K.Fragment,{children:[e.kind===`newer`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(S6,{current:e.current,latest:e.newer}),(0,K.jsx)(C6,{url:e.releaseNotes,version:e.newer,children:`What changed`})]}):(0,K.jsx)(`p`,{className:x6.line,children:(0,K.jsx)(J,{text:L6(e)})}),(0,K.jsx)(`span`,{className:x6.spacer}),(0,K.jsx)(Y,{cli:e.kind===`newer`?`ork upgrade`:void 0,id:m6,onClick:()=>{n.opens===null?F6():t(n.opens)},variant:n.primary?`primary`:`default`,children:n.label})]})},z6=({workspace:e})=>{let{version:t,connection:n,preferences:r}=sb(),i=yb(t.info),a=yb(n),o=yb(r.value),s=yb(t.dialog),c=P6(),l=_6({info:i,connection:a,pageVersion:t.pageVersion,dismissed:o.updateDismissed,now:c});N6(l,i!==null&&a.server!==null,s!==null,e);let u=l===null?null:b6(l);return(0,K.jsx)(`div`,{className:x6.slot,children:l===null?null:(0,K.jsxs)(`section`,{"aria-label":`New version`,className:x6.banner,children:[(0,K.jsx)(`span`,{className:x6.icon,children:(0,K.jsx)($y,{})}),(0,K.jsx)(R6,{banner:l,onOpen:t.openDialog}),u===null?null:(0,K.jsx)(Sb,{label:`Dismiss for a day`,onClick:()=>{r.update({updateDismissed:{version:u,at:new Date().toISOString()}}),e.announce(M6),e.focusPanels()},children:(0,K.jsx)(sy,{})})]})})},B6=e=>e===null?`Asking the npm registry for the latest version…`:`Asking the registry at \`${e}\` for the latest version…`,V6=({plan:e})=>(0,K.jsxs)(`dl`,{className:x6.facts,children:[(0,K.jsx)(`dt`,{className:x6.factName,children:`Installed with`}),(0,K.jsx)(`dd`,{className:x6.factValue,children:e.installer?.label??`Ork couldn't tell`}),e.kind===`command`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:x6.factName,children:`Command`}),(0,K.jsx)(`dd`,{className:x6.factValue,children:(0,K.jsx)(`section`,{"aria-label":`Command to run`,children:(0,K.jsx)(lC,{command:e.command.join(` `)})})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:x6.factName,children:`What to do`}),(0,K.jsxs)(`dd`,{className:x6.factValue,children:[(0,K.jsx)(`p`,{className:x6.adviceWords,children:(0,K.jsx)(J,{text:e.words})}),e.commands.map(e=>(0,K.jsx)(lC,{command:e},e))]})]})]}),H6=({plan:e})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(S6,{current:e.current,latest:e.latest}),(0,K.jsxs)(`p`,{className:x6.message,children:[`What changed:`,` `,(0,K.jsx)(C6,{url:e.releaseNotes,children:e.releaseNotes})]}),(0,K.jsx)(V6,{plan:e}),e.kind===`advice`?(0,K.jsx)(`p`,{className:x6.note,children:`Ork runs only a package manager's own command from here; this one is yours to run.`}):null,(0,K.jsx)(T6,{ids:e.running}),(0,K.jsx)(`p`,{className:x6.note,children:`The same, in a terminal:`}),(0,K.jsx)(lC,{command:`ork upgrade`})]}),U6=({step:e,registry:t})=>e.step===`plan`?(0,K.jsx)(H6,{plan:e.plan}):e.step===`latest`?(0,K.jsx)(D6,{text:`Ork ${e.current} is the latest version.`,tone:`succeeded`}):e.step===`unreachable`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k6,{icon:!0,text:e.words}),(0,K.jsx)(`p`,{className:x6.message,children:`Nothing was changed.`})]}):(0,K.jsx)(`section`,{"aria-busy":`true`,"aria-label":`Asking`,className:x6.message,children:(0,K.jsx)(J,{text:B6(t)})}),W6=({step:e,registry:t,first:n,onClose:r,onAsk:i,onUpgrade:a})=>{let o=(0,H.useId)();(0,H.useEffect)(()=>{E6()&&n.current?.focus()},[n]);let s=e.step===`plan`&&e.plan.kind===`command`,c=e.step===`checking`||s,l=e.step===`plan`&&e.starting;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(U6,{registry:t,step:e}),(0,K.jsx)(k6,{text:e.step===`plan`?e.refusal:null}),(0,K.jsx)(A6,{id:o,why:e.step===`checking`?`Asking the registry…`:null}),(0,K.jsxs)(j6,{note:c?`It runs on this machine as you.`:void 0,children:[e.step===`unreachable`?(0,K.jsx)(Y,{onClick:()=>{n.current?.focus(),i()},variant:`ghost`,children:`Try again`},`again`):null,(0,K.jsx)(Y,{disabled:l,focusableWhenDisabled:!0,onClick:r,ref:n,variant:c?`ghost`:`default`,children:c?`Cancel`:`Close`},`close`),c?(0,K.jsx)(Y,{"aria-describedby":o,disabled:!s||l,focusableWhenDisabled:!0,onClick:a,variant:`primary`,children:e.step===`plan`?`Upgrade to ${e.plan.latest}`:`Upgrade`},`upgrade`):null]})]})},G6=({step:e,port:t})=>{let n=(0,H.useId)();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(D6,{text:"Restarting `ork ui`…"}),(0,K.jsx)(`p`,{className:x6.message,children:e.step===`back`?`Ork ${e.version} is up. Reloading…`:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{text:`Waiting for \`ork ui\` to come back on port ${t}. Runs keep running.`}),` `,(0,K.jsx)(O6,{since:e.since})]})}),(0,K.jsx)(A6,{id:n,why:"It closes once `ork ui` is back."}),(0,K.jsx)(j6,{children:(0,K.jsx)(Y,{"aria-describedby":n,disabled:!0,focusableWhenDisabled:!0,children:`Close`})})]})},K6=({step:e,port:t,onClose:n,onKeepWaiting:r,onReload:i})=>{if(e.step===`restarting`||e.step===`back`)return(0,K.jsx)(G6,{port:t,step:e});let a=q6(e,t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(D6,{text:a.heading,tone:`failed`}),(0,K.jsx)(k6,{text:a.words}),(0,K.jsx)(lC,{command:a.command}),(0,K.jsxs)(j6,{children:[e.step===`gaveUp`?(0,K.jsx)(Y,{onClick:r,children:`Keep waiting`}):(0,K.jsx)(Y,{onClick:n,children:`Close`}),e.step===`signedOut`?null:(0,K.jsx)(Y,{onClick:i,variant:`primary`,children:`Reload`})]})]})},q6=(e,t)=>e.step===`gaveUp`?{heading:"`ork ui` didn't come back",words:`It wasn't back on port ${t} after 60 seconds. Its terminal says why. Start it again there:`,command:`ork ui --port ${t}`}:e.step===`oldVersion`?{heading:`\`ork ui\` is back on ${e.version}`,words:`\`ork ui\` is back, but it runs ${e.version}: the \`ork\` it started is not the one that was upgraded. Another \`ork\` may come first on your PATH.`,command:`ork upgrade`}:{heading:`This page isn't signed in`,words:"`ork ui` is back, but this page isn't signed in to it. Open it again from a terminal:",command:`ork ui`},J6="Lost the output from `ork ui`. The command may still be running; reconnecting…",Y6=e=>e.command[0]??`it`,X6=(e,t)=>{let n=t.split(`
111
+ `).findLast(e=>e.startsWith(`Could not run`));return e.code===127&&n!==void 0?n:`\`${Y6(e)}\` failed (exit ${String(e.code??1)}); the upgrade did not finish.`},Z6=({job:e,lost:t,output:n})=>{let r=(0,H.useId)();(0,H.useEffect)(()=>{n.current?.focus()},[n]);let i=Y6(e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:x6.message,children:[(0,K.jsx)(J,{text:`Running \`${i}\`…`}),` `,(0,K.jsx)(O6,{since:Date.parse(e.startedAt)})]}),(0,K.jsx)(lC,{command:e.command.join(` `)}),t?(0,K.jsx)(k6,{text:J6}):null,(0,K.jsx)(A6,{id:r,why:`It closes when ${i} ends; closing now would hide how it ended.`}),(0,K.jsx)(j6,{children:(0,K.jsx)(Y,{"aria-describedby":r,disabled:!0,focusableWhenDisabled:!0,children:`Close`})})]})},Q6=({step:e,text:t,lost:n,current:r,port:i,output:a,heading:o,onClose:s,onAsk:c,onRestart:l})=>{let{job:u}=e,d=`Output of ${Y6(u)}`;if(e.step===`running`)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ZU,{label:d,ref:a,text:t}),(0,K.jsx)(Z6,{job:u,lost:n,output:a})]});let f=(0,K.jsx)(ZU,{label:d,text:t});return e.step===`failed`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(D6,{ref:o,text:`The upgrade did not finish`,tone:`failed`}),(0,K.jsx)(k6,{text:`${X6(u,t)} Nothing was restarted; \`ork ui\` still runs ${r}.`}),f,(0,K.jsx)(`p`,{className:x6.note,children:`To run it in a terminal yourself:`}),(0,K.jsx)(lC,{command:u.command.join(` `)}),(0,K.jsxs)(j6,{children:[(0,K.jsx)(Y,{onClick:s,children:`Close`}),(0,K.jsx)(Y,{onClick:c,variant:`ghost`,children:`Try again`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(D6,{ref:o,text:`Upgraded to ${u.latest}`,tone:`succeeded`}),(0,K.jsx)(`p`,{className:x6.message,children:(0,K.jsx)(J,{text:`Ork ${u.latest} is installed. This page and \`ork ui\` still run ${r} until \`ork ui\` restarts. Restart stops it and starts it again on port ${i} with the same options; runs keep running, and the page reloads itself when it's back.`})}),f,(0,K.jsx)(k6,{text:e.refusal}),(0,K.jsxs)(j6,{children:[(0,K.jsx)(Y,{onClick:s,variant:`ghost`,children:`Later`}),(0,K.jsxs)(Y,{cli:`ork ui --port ${i}`,disabled:e.asking,focusableWhenDisabled:!0,onClick:l,tip:"Stops `ork ui` and starts the new one",variant:`primary`,children:[(0,K.jsx)(eb,{}),`Restart`]})]})]})},$6={pollMs:1e3,waitMs:6e4,reloadMs:1500},e8=async(e,t,n)=>{let{job:r,port:i,pid:a,since:o}=t,s=await e.call(`health`);if(s.ok&&s.data.pid!==a){let{version:e}=s.data;return e===r.latest?{step:`back`,version:e}:{step:`oldVersion`,job:r,version:e}}return!s.ok&&s.status===401?{step:`signedOut`}:Date.now()-o>=n?{step:`gaveUp`,job:r,port:i,pid:a}:null},t8=({client:e,step:t,setStep:n,announce:r,reload:i,timing:a})=>{let o=(0,H.useRef)({announce:r,reload:i});(0,H.useEffect)(()=>{o.current={announce:r,reload:i}}),(0,H.useEffect)(()=>{let r=t.step===`restarting`?t:null,i=!1,s=async t=>{let r=await e8(e,t,a.waitMs);i||r===null||(i=!0,n(r),r.step===`gaveUp`&&o.current.announce("`ork ui` didn't come back."),r.step===`back`&&(o.current.announce(`Ork ${r.version} is up. Reloading…`),setTimeout(()=>{o.current.reload()},a.reloadMs)))},c=r===null?void 0:setInterval(()=>{s(r)},a.pollMs);return()=>{i=!0,clearInterval(c)}},[e,t,n,a])},n8=e=>e===null?`Could not reach the npm registry to look for a new version.`:`Could not reach the registry at \`${e}\` to look for a new version.`,r8=(e,t)=>e.kind===`unreachable`?{step:`unreachable`,words:n8(t)}:e.kind===`latest`?{step:`latest`,current:e.current}:{step:`plan`,plan:e,refusal:null,starting:!1},i8=e=>e.kind===`command`?`Ork ${e.latest} is out. The plan is below.`:`Ork ${e.latest} is out. Ork can't run this upgrade from here; what to do is below.`,a8=e=>e.state===`running`?{step:`running`,job:e}:e.state===`succeeded`?{step:`done`,job:e,refusal:null,asking:!1}:{step:`failed`,job:e},o8=({client:e,open:t,job:n,registry:r,announce:i,onAsked:a})=>{let[o,s]=(0,H.useState)(()=>n===null?{step:`checking`}:a8(n)),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(!1),f=(0,H.useRef)(null),p=(0,H.useRef)(0),m=(0,H.useRef)({announce:i,onAsked:a,registry:r});(0,H.useEffect)(()=>{m.current={announce:i,onAsked:a,registry:r}});let h=(0,H.useCallback)(e=>{f.current?.close(),p.current=0,l([]);let n=KH({url:()=>`${ZD.upgrade}?after=${String(p.current)}`,open:t,on:{output:e=>{e.seq<=p.current||(p.current=e.seq,l(t=>[...t,e]))},end:t=>{n.close(),d(!1),s(a8({...e,state:t.state,code:t.code})),t.state===`succeeded`&&m.current.announce(`Upgraded to ${e.latest}.`)}},onStatus:e=>{d(e===`lost`)}});f.current=n},[t]),g=(0,H.useCallback)(async()=>{s({step:`checking`});let t=await e.call(`upgradePlan`);m.current.onAsked();let n=t.ok?r8(t.data,m.current.registry):{step:`unreachable`,words:t.error};s(n),n.step===`plan`&&m.current.announce(i8(n.plan))},[e]),_=(0,H.useRef)(n);(0,H.useEffect)(()=>{let e=_.current;return e===null?g():h(e),()=>{f.current?.close()}},[g,h]);let v=async(t,n)=>{let r=await e.call(`version`),i=r.ok?r.data.job:null;if(i?.state===`running`){m.current.announce(n),s({step:`running`,job:i}),h(i);return}let a=await e.call(`upgradePlan`);if(m.current.onAsked(),!a.ok){s({step:`plan`,plan:t,refusal:n,starting:!1});return}let o=r8(a.data,m.current.registry);s(o.step===`plan`?{...o,refusal:n}:o)},y=async t=>{s({step:`plan`,plan:t,refusal:null,starting:!0});let n=await e.call(`upgrade`,{body:{planId:t.planId}});n.ok?(m.current.announce(`Upgrading Ork to ${t.latest}.`),s({step:`running`,job:n.data.job}),h(n.data.job)):n.status===409?await v(t,n.error):s({step:`plan`,plan:t,refusal:n.error,starting:!1})},b=async t=>{s({step:`done`,job:t,refusal:null,asking:!0});let n=await e.call(`restart`);s(n.ok?{step:`restarting`,job:t,port:n.data.port,pid:n.data.pid,since:Date.now()}:{step:`done`,job:t,refusal:n.error,asking:!1})};return{step:o,setStep:s,text:c.map(e=>e.text).join(`
112
+ `),lost:u,ask:()=>{g()},upgrade:()=>{o.step===`plan`&&o.plan.kind===`command`&&y(o.plan)},restart:()=>{o.step===`done`&&b(o.job)},keepWaiting:()=>{o.step===`gaveUp`&&s({...o,step:`restarting`,since:Date.now()})}}},s8=e=>[`checking`,`unreachable`,`latest`,`plan`].includes(e.step),c8=e=>[`running`,`done`,`failed`].includes(e.step),l8=e=>!s8(e)&&!c8(e),u8=({starts:e,timing:t,reload:n,onStep:r,onClose:i})=>{let{version:a,client:o}=sb(),s=(0,H.use)(wU),c=yb(a.info),l=yb(a.dialog),u=(0,H.useCallback)(e=>s?.announce(e),[s]),d=o8({client:o,open:a.open,job:l===`job`?c?.job??null:null,registry:c?.registry??null,announce:u,onAsked:()=>void a.refresh()}),{step:f,setStep:p}=d;t8({client:o,step:f,setStep:p,announce:u,reload:n,timing:t}),(0,H.useEffect)(()=>{r(f)},[f,r]);let m=f.step===`restarting`||f.step===`back`;(0,H.useEffect)(()=>(a.restarting.setValue(m),()=>{a.restarting.setValue(!1)}),[a,m]);let h=window.location.port;return s8(f)?(0,K.jsx)(W6,{first:e.first,onAsk:d.ask,onClose:i,onUpgrade:d.upgrade,registry:c?.registry??null,step:f}):c8(f)?(0,K.jsx)(Q6,{current:c?.current??``,heading:e.heading,lost:d.lost,onAsk:d.ask,onClose:i,onRestart:d.restart,output:e.output,port:h,step:f,text:d.text}):l8(f)?(0,K.jsx)(K6,{onClose:i,onKeepWaiting:d.keepWaiting,onReload:n,port:h,step:f}):null},d8=()=>{window.location.reload()},f8=e=>![`running`,`restarting`,`back`].includes(e.step)&&!(e.step===`plan`&&e.starting)&&!(e.step===`done`&&e.asking),p8=`Upgrade Ork`,m8=({timing:e=$6,reload:t=d8})=>{let{version:n}=sb(),r=(0,H.use)(wU),i=yb(n.dialog),a=yb(n.info),o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(null),l=i===`job`&&a?.job?.state!==`running`,u=i===`job`?l?c:s:o,[d,f]=(0,H.useState)(p8),p=(0,H.useRef)({closable:!0,ran:!1}),m=(0,H.useCallback)(e=>{p.current={closable:f8(e),ran:p.current.ran||`job`in e},f(t=>s8(e)?p8:`job`in e?`Upgrading Ork to ${e.job.latest}`:t)},[]),h=()=>{p.current.closable&&(p.current.ran||r?.announce(`Nothing was changed.`),p.current={closable:!0,ran:!1},f(p8),n.closeDialog())};return(0,K.jsx)(PC,{finalFocus:()=>{let e=document.querySelector(`#${m6}`);return e===null?(r?.focusPanels(),!1):e},initialFocus:u,onOpenChange:e=>{e||h()},open:i!==null,size:`wide`,title:d,children:(0,K.jsx)(u8,{onClose:h,onStep:m,reload:t,starts:{first:o,output:s,heading:c},timing:e})})},h8=({workspace:e})=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(z6,{workspace:e}),(0,K.jsx)(m8,{})]}),g8=[`Panels`,`Runs`,`Window`,`Layout`,`View`,`Ork`],_8=`Needs a wider window.`,v8=`No panel is active.`,y8=[`left`,`right`,`up`,`down`],b8={left:`narrower`,right:`wider`,up:`shorter`,down:`taller`},x8=e=>e.wide?e.active===null?v8:void 0:_8,S8=e=>_Q.map((t,n)=>{let r={id:`go-${t.id}`,title:`Go to ${t.title}`,group:`Panels`,run:()=>{e.goTo(t.id)}},i=pA(n+1);return i!==void 0&&(r.shortcut=i),r}),C8=(e,t)=>[{id:`follow-ups-due`,title:`Follow-ups: show due`,group:`Panels`,run:()=>{t.followUpsFilter.setValue({...t.followUpsFilter.getValue(),status:`due`}),e.goTo(`followups`),requestAnimationFrame(()=>{document.querySelector(`[data-followups-list]`)?.focus()})}}],w8=e=>[{id:`run-workflow`,title:`Run workflow…`,group:`Runs`,run:()=>{e.runDialog.setValue(!0)}}],T8=(e,t)=>{let n=x8(t),r=t.active===null?`panel`:yQ(t.active).title,i=n??(t.floating?`A floating panel cannot be maximized.`:void 0),a=n??(t.maximized?`Restore the panel first.`:void 0);return[{id:`minimize`,title:`Minimize ${r}`,group:`Window`,shortcut:dA.minimize,run:()=>{e.minimize()},disabled:n},{id:`maximize`,title:t.maximized?`Restore ${r}`:`Maximize ${r}`,group:`Window`,shortcut:dA.maximize,run:()=>{e.toggleMaximize()},disabled:i},{id:`float`,title:t.floating?`Dock ${r}`:`Float ${r}`,group:`Window`,shortcut:dA.float,run:()=>{e.toggleFloat()},disabled:n},{id:`close`,title:`Close ${r}`,group:`Window`,shortcut:dA.close,run:()=>{e.close()},disabled:n},...y8.map(t=>({id:`resize-${t}`,title:`Make ${r} ${b8[t]}`,group:`Window`,shortcut:dA.resize(t),run:()=>{e.resize(t)},disabled:a})),...y8.map(t=>({id:`move-${t}`,title:`Move ${r} ${t}`,group:`Window`,shortcut:dA.move(t),run:()=>{e.move(t)},disabled:n}))]},E8=(e,t)=>{let n=t.wide?void 0:_8;return[{id:`next-group`,title:`Focus next panel group`,group:`Layout`,shortcut:dA.nextGroup,run:()=>{e.cycleGroup(1)},disabled:n},{id:`previous-group`,title:`Focus previous panel group`,group:`Layout`,shortcut:dA.previousGroup,run:()=>{e.cycleGroup(-1)},disabled:n},{id:`reset-layout`,title:`Reset layout`,group:`Layout`,run:()=>{e.resetLayout()}}]},D8=[{theme:`system`,title:`Follow the system`},{theme:`dark`,title:`Dark`},{theme:`light`,title:`Light`}],O8=[{density:`compact`,title:`Compact`},{density:`comfortable`,title:`Comfortable`}],k8=(e,t,n)=>[...D8.map(({theme:r,title:i})=>({id:`theme-${r}`,title:`Theme: ${i}`,group:`View`,run:()=>{t.update({theme:r}),e.announce(`Theme: ${i}.`)},disabled:n.theme===r?`This is the theme now.`:void 0})),...O8.map(({density:r,title:i})=>({id:`density-${r}`,title:`Density: ${i}`,group:`View`,run:()=>{t.update({density:r}),e.announce(`Density: ${i}.`)},disabled:n.density===r?`This is the density now.`:void 0}))],A8=e=>[{id:`upgrade-ork`,title:`Upgrade Ork…`,group:`Ork`,detail:`Asks the registry for a new version now.`,run:()=>{e.version.openDialog(`ask`)}}],j8=(e,t,n,r)=>[...S8(e),...C8(e,n),...w8(n),...T8(e,t),...E8(e,t),...k8(e,n.preferences,r),...A8(n)],M8={palette:`_palette_p3ocp_6`,input:`_input_p3ocp_45`,list:`_list_p3ocp_78`,group:`_group_p3ocp_88`,empty:`_empty_p3ocp_106`},N8=e=>g8.map(t=>({value:t,items:e.filter(e=>e.group===t).map(e=>({label:e.title,command:e}))})),P8=({commands:e,onChoose:t})=>{let n=(0,H.useMemo)(()=>N8(e),[e]),r=mA();return(0,K.jsxs)(WV,{autoHighlight:`always`,inline:!0,items:n,keepHighlight:!0,open:!0,children:[(0,K.jsx)(Qx,{"aria-label":`Search commands`,className:M8.input,placeholder:`Type a command`}),(0,K.jsx)(nC,{children:(0,K.jsx)(`p`,{className:M8.empty,children:`No command matches.`})}),(0,K.jsx)(vS,{className:M8.list,children:e=>(0,K.jsxs)(WS,{items:e.items,children:[(0,K.jsx)(GS,{className:M8.group,children:e.value}),(0,K.jsx)(cS,{children:e=>(0,K.jsxs)(qV,{className:a_.item,disabled:e.command.disabled!==void 0,onClick:()=>{t(e.command)},value:e,children:[(0,K.jsx)(`span`,{children:e.label}),(e.command.disabled??e.command.detail)===void 0?null:(0,K.jsx)(`span`,{className:a_.itemDetail,children:e.command.disabled??e.command.detail}),e.command.shortcut===void 0?null:(0,K.jsx)(i_,{keys:sA(e.command.shortcut,r)})]},e.command.id)})]},e.value)})]})},F8=()=>(document.activeElement===null||document.activeElement===document.body)&&document.querySelector(`[data-modal]`)===null,I8=e=>{requestAnimationFrame(()=>{requestAnimationFrame(e)})},L8=({workspace:e,commands:t})=>{let n=yb(e.palette),r=(0,H.useRef)(null),i=(0,H.useRef)(!1),a=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{n&&(i.current=!1,a.current=document.activeElement)},[n]);let o=t=>{e.palette.setValue(t)},s=()=>{if(!F8())return;let t=a.current;t instanceof HTMLElement&&t.isConnected?t.focus():e.focusPanels()};return(0,K.jsx)(jC,{onOpenChange:o,onOpenChangeComplete:e=>{if(e)return;let t=r.current;r.current=null,t!==null&&(t.run(),I8(s))},open:n,children:(0,K.jsxs)(kC,{children:[(0,K.jsx)(yC,{className:MC.backdrop}),(0,K.jsx)(OC,{"aria-label":`Command palette`,"aria-modal":`true`,className:M8.palette,finalFocus:()=>!i.current,children:(0,K.jsx)(P8,{commands:t,onChoose:e=>{r.current=e,i.current=!0,o(!1)}})})]})})},R8=(e,t,n)=>`${String(e)} ${e===1?t:n}`,z8=()=>{let{runs:e,decisions:t,connection:n}=sb(),r=vb(e,_U),i=vb(t,e=>e?.length??null);return vb(n,({link:e})=>e===`open`)&&r!==null&&i!==null?(0,K.jsxs)(`span`,{className:_A.status,children:[R8(r,`run live`,`runs live`),`,`,` `,R8(i,`decision open`,`decisions open`)]}):null},B8=({workspace:e})=>{let t=yb(e.announcement),{connection:n,version:r}=sb(),i=vb(n,gU),a=yb(r.restarting);return(0,K.jsxs)(`footer`,{className:_A.bar,children:[(0,K.jsx)(`output`,{"aria-live":a?`off`:void 0,className:_A.status,children:(0,K.jsx)(J,{text:i})}),(0,K.jsx)(z8,{}),(0,K.jsx)(`output`,{"aria-atomic":`true`,"aria-live":`polite`,className:_A.visuallyHidden,children:t})]})},V8=e=>{let t=sb(),{preferences:n}=t,r=yb(e.view),i=yb(n.value),a=(0,H.useMemo)(()=>j8(e,r,t,i),[e,r,t,i]);return gA(e,a),a},H8=e=>{let t=sb();(0,H.useEffect)(()=>t.notifications.onNew(n=>{if(e.announce(n.map(({title:e})=>e).join(` `)),t.preferences.value.getValue().desktopNotifications)for(let r of n)TK(r.title,r.id,()=>{t.selectRun(r.runId),e.goTo(`notifications`)})}),[t,e])},U8=({workspace:e})=>{let t=V8(e);return H8(e),(0,K.jsx)(wU,{value:e,children:(0,K.jsxs)(`div`,{className:_A.shell,children:[(0,K.jsx)(CQ,{workspace:e}),(0,K.jsx)(h8,{workspace:e}),(0,K.jsx)(p6,{workspace:e}),(0,K.jsx)(B8,{workspace:e}),(0,K.jsx)(L8,{commands:t,workspace:e}),(0,K.jsx)(iA,{})]})})},W8=1e3,G8=e=>{let t=[],n=!1,r=i=>{n=!0,e.setValue(``),setTimeout(()=>{e.setValue(i)},0),setTimeout(()=>{n=!1,t.length>0&&r(t.splice(0).join(` `))},W8)};return e=>{let i=n_(e);n?t.push(i):r(i)}},K8=280,q8=340,J8=240,Y8={minimumWidth:240,minimumHeight:120},X8=e=>{e.api.setConstraints(Y8)},Z8=(e,t,n)=>[e.onDidAddGroup(X8),e.onDidLayoutChange(()=>{n(),t()}),e.onDidAddPanel(t),e.onDidRemovePanel(t),e.onDidActivePanelChange(t),e.onDidMaximizedGroupChange(t)],Q8=(e,t)=>{try{return e.fromJSON(t),!0}catch{return e.clear(),!1}},$8=(e,t,n)=>e.addPanel({id:t,component:t,title:yQ(t).title,...n}),e5=e=>{let t=$8(e,`monitor`,{});$8(e,`builder`,{position:{referencePanel:`monitor`,direction:`within`},inactive:!0}),$8(e,`runs`,{position:{referencePanel:`monitor`,direction:`left`},initialWidth:K8,inactive:!0}),$8(e,`decisions`,{position:{referencePanel:`monitor`,direction:`right`},initialWidth:q8,inactive:!0}),$8(e,`notifications`,{position:{referencePanel:`decisions`,direction:`within`},inactive:!0}),$8(e,`context`,{position:{referencePanel:`decisions`,direction:`below`}}),$8(e,`logs`,{position:{referencePanel:`monitor`,direction:`below`},initialHeight:J8,inactive:!0}),$8(e,`chats`,{position:{referencePanel:`logs`,direction:`within`},inactive:!0}),$8(e,`usage`,{position:{referencePanel:`logs`,direction:`within`},inactive:!0}),$8(e,`feedback`,{position:{referencePanel:`usage`,direction:`within`},inactive:!0}),$8(e,`worktrees`,{position:{referencePanel:`feedback`,direction:`within`},inactive:!0}),$8(e,`followups`,{position:{referencePanel:`worktrees`,direction:`within`},inactive:!0}),t.api.setActive()},t5=(e,t,n)=>{if(!Array.isArray(e.data))return;let r=e.data,i=r.findIndex(e=>!Array.isArray(e.data)&&e.data.id===t);if(i!==-1)return{siblings:r,index:i,along:n};for(let e of r){let r=t5(e,t,!n);if(r!==void 0)return r}},n5={horizontal:`left`,vertical:`above`},r5={horizontal:`right`,vertical:`below`},i5=(e,t)=>{let{root:n,orientation:r}=e.toJSON().grid,i=r===F$.HORIZONTAL,a=t5(n,t.id,!0);if(a===void 0)return;let{siblings:o,index:s,along:c}=a,l=c===i?`horizontal`:`vertical`,u=o[s+1],d=u??o[s-1];if(d===void 0)return;let f={width:t.api.width,height:t.api.height},p=u===void 0?r5[l]:n5[l];return Array.isArray(d.data)?c?{group:null,direction:p,...f}:void 0:{group:d.data.id,direction:p,...f}},a5=(e,t)=>{if(t.api.location.type!==`floating`)return;let n=e.toJSON().floatingGroups?.find(e=>e.data?.id===t.id);if(n===void 0)return;let{position:r}=n,{width:i,height:a}=r;return{left:`left`in r?r.left:e.width-r.right-i,top:`top`in r?r.top:e.height-r.bottom-a,width:i,height:a}},o5=(e,t)=>{let{group:n}=t,r=a5(e,n),i=i5(e,n);return{group:n.id,index:n.panels.indexOf(t),...r===void 0?{}:{floating:r},...i===void 0?{}:{beside:i}}},s5=(e,t)=>{if(t!==void 0){if(e.getGroup(t.group)!==void 0)return{position:{referenceGroup:t.group,direction:`within`,index:t.index}};if(t.floating!==void 0){let{left:e,top:n,width:r,height:i}=t.floating;return{floating:{x:e,y:n,width:r,height:i}}}if(t.beside!==void 0){let{group:n,direction:r,width:i,height:a}=t.beside,o=r===`left`||r===`right`?{initialWidth:i}:{initialHeight:a};if(n===null)return{position:{direction:r},...o};if(e.getGroup(n)!==void 0)return{position:{referenceGroup:n,direction:r},...o}}}let n=e.activeGroup;return n===void 0?{}:{position:{referenceGroup:n.id,direction:`within`}}},c5=(e,t,n)=>$8(e,t,s5(e,n)),l5=(e,t)=>e.groups.find(e=>e.id===t),u5=e=>{let t=e.element.querySelector(`[role="tab"][aria-selected="true"]`);return t?.focus(),t!==null},d5=e=>{e.api.setActive(),requestAnimationFrame(()=>{u5(e.group)})},f5=e=>e.map(e=>({group:e,box:e.element.getBoundingClientRect()})).toSorted((e,t)=>e.box.left-t.box.left||e.box.top-t.box.top).map(({group:e})=>e),p5=(e,t)=>{let n=f5(e.groups),{activeGroup:r}=e;if(n.length===0)return;let i=n[((r===void 0?0:n.indexOf(r))+t+n.length)%n.length];i!==void 0&&(i.activePanel?.api.setActive(),u5(i))},m5=e=>{e.api.location.type===`grid`&&(e.api.isMaximized()?e.api.exitMaximized():e.api.maximize(),u5(e))},h5={right:{axis:`width`,delta:32},left:{axis:`width`,delta:-32},down:{axis:`height`,delta:32},up:{axis:`height`,delta:-32}},g5=(e,t)=>{let{axis:n,delta:r}=h5[t];e.api.setSize({[n]:e.api[n]+r})},_5=e=>{let t=String(Math.round(e.group.api.width)),n=String(Math.round(e.group.api.height));return`${e.title??e.id}: ${t} by ${n}.`},v5={right:{x:32,y:0},left:{x:-32,y:0},down:{x:0,y:32},up:{x:0,y:-32}},y5={left:`left`,right:`right`,up:`above`,down:`below`},b5=(e,t,n)=>{let{group:r}=t,i=a5(e,r);if(i!==void 0){let{x:t,y:a}=v5[n];e.addFloatingGroup(r,{x:Math.max(0,i.left+t),y:Math.max(0,i.top+a),width:i.width,height:i.height});return}let a=e.adjacentGroupInDirection(r,n),o=a===void 0?void 0:l5(e,a.id);o===void 0?(r.panels.length!==1||e.groups.length!==1)&&t.api.moveTo({group:e.addGroup({direction:y5[n]}),position:`center`}):t.api.moveTo({group:o,position:`center`})},x5={left:`left`,right:`right`,above:`top`,below:`bottom`},S5=(e,t,n)=>{let r=t.activePanel;if(r===void 0)return;if(t.api.location.type!==`floating`){let{beside:i}=o5(e,r);e.addFloatingGroup(t);let a=e.getPanel(r.id)?.group;a!==void 0&&i!==void 0&&n.set(a.id,i);return}let i=n.get(t.id);n.delete(t.id);let a=i?.group===void 0||i.group===null?void 0:l5(e,i.group),o=i?.direction??`right`;t.api.moveTo(a===void 0?{position:x5[o]}:{group:a,position:x5[o]}),i!==void 0&&t.api.setSize(o===`left`||o===`right`?{width:i.width}:{height:i.height})},C5=`ork.layout.v1`,w5=$s(e=>typeof e==`string`&&vQ(e)),T5=gs({left:is(),top:is(),width:is(),height:is()}),E5=gs({id:w5,anchor:gs({group:B(),index:is(),floating:T5.optional(),beside:gs({group:B().nullable(),direction:ks([`left`,`right`,`above`,`below`]),width:is(),height:is()}).optional()})}),D5=_s({grid:_s({root:_s({})}),panels:Ds(B(),_s({contentComponent:w5}))}),O5=gs({dock:us(),minimized:ms(E5),folded:ms(w5)}),k5=(e,t,n)=>[...e.filter(e=>e!==t),...n?[t]:[]],A5={dock:null,minimized:[],folded:[]},j5=e=>D5.safeParse(e).success,M5=e=>{let t=O5.safeParse(e);if(!t.success)return null;let{dock:n,minimized:r,folded:i}=t.data;if(n==null)return{dock:null,minimized:[],folded:i};if(!j5(n))return null;let a=new Set(Object.values(n.panels).map(e=>e.contentComponent));return{dock:n,minimized:r.filter(e=>!a.has(e.id)),folded:i}},N5=e=>new db(A5,{key:C5,storage:e}),P5=({dock:e,targetPanel:t,commit:n,refocus:r,announce:i,quietly:a})=>{let o=new Map,s=()=>{let t=e();t?.hasMaximizedGroup()===!0&&t.exitMaximizedGroup()};return{close:e=>{let i=t(e);i!==void 0&&(s(),i.api.close(),n(),r())},toggleMaximize:t=>{let r=t??e()?.activeGroup;r!==void 0&&m5(r),n()},toggleFloat:t=>{let i=e(),a=t??i?.activeGroup;i!==null&&a!==void 0&&(s(),S5(i,a,o),n(),r())},resize:t=>{let n=e(),r=n?.activeGroup,a=n?.activePanel;r!==void 0&&a!==void 0&&n?.hasMaximizedGroup()!==!0&&(g5(r,t),i(_5(a)))},move:t=>{let o=e(),c=o?.activePanel;o!==null&&c!==void 0&&(a(()=>{s(),b5(o,c,t)}),n(),r(),i(`${c.title??c.id} moved ${t}.`))},cycleGroup:t=>{let n=e();n!==null&&p5(n,t)}}},F5=({storage:e,wide:t,onLayoutDropped:n})=>{let r=N5(e),i=M5(r.getValue()),a=i===null;a&&r.reset();let o=lb.create(n6(null,i??A5,t)),s=lb.create(!1),c=lb.create(``),l=null,u=!1,d=[],f=G8(c),p=e=>{u||f(e)},m=e=>{u=!0,e(),u=!1},h=()=>{let e=o.getValue(),t=n6(l,r.getValue(),e.wide);r6(e,t)||o.setValue(t)},g=()=>{l!==null&&r.setValue({...r.getValue(),dock:l.toJSON()})},_=()=>{g(),h()},v=()=>{for(let e of d)e.dispose();d=[],l=null,h()},y=e=>{v(),u=!0,l=e;let{dock:t,folded:i}=r.getValue();t!==null&&Q8(e,t)||(a||=t!==null,r.setValue({...A5,folded:i}),e5(e)),a&&n?.(),a=!1,e.groups.forEach(X8),d=Z8(e,h,g),h(),u=!1},b=e=>e===void 0?l?.activePanel:l?.getPanel(e),x=()=>{l?.hasMaximizedGroup()===!0&&l.exitMaximizedGroup()},S=e=>{let t=r.getValue();r.setValue({...t,minimized:e(t.minimized)})},C=e=>{requestAnimationFrame(()=>{let t=l?.activeGroup;!(t!==void 0&&u5(t))&&e!==void 0&&o6(a6(e))})},w=()=>{let[e]=_Q;o.getValue().wide?C():e!==void 0&&o6(i6(e.id))},T=e=>{let t=b(e);if(l===null||t===void 0)return;let n=t.id;if(!vQ(n))return;m(x);let r=o5(l,t);S(e=>[...e,{id:n,anchor:r}]),m(()=>{t.api.close()}),f(`${yQ(n).title} minimized.`),_(),C(n)},E=e=>{if(l===null)return;let t=r.getValue().minimized.find(t=>t.id===e);S(t=>t.filter(t=>t.id!==e));let n=l;m(()=>{x(),d5(c5(n,e,t?.anchor))}),f(`${yQ(e).title} restored.`),_()},D=(e,t)=>{let n=r.getValue();r.setValue({...n,folded:k5(n.folded,e,t)}),_()},O=e=>{D(e,!r.getValue().folded.includes(e))},k=e=>{if(!o.getValue().wide){D(e,!1),o6(i6(e));return}if(l===null)return;let t=l.getPanel(e);if(t!==void 0)t.api.isMaximized()||x(),d5(t);else if(o.getValue().minimized.includes(e))E(e);else{let t=l;m(()=>{x(),d5(c5(t,e))}),f(`${yQ(e).title} opened.`)}},A=P5({dock:()=>l,targetPanel:b,commit:_,refocus:C,announce:f,quietly:m}),j=()=>{if(r.setValue(A5),l!==null){let e=l;m(()=>{e.clear(),e5(e)}),l.groups.forEach(X8),g(),C()}_(),f(`Layout reset.`)},M=e=>{let t=o.getValue();t.wide!==e&&o.setValue({...t,wide:e})};return{view:o,layout:r,palette:s,announcement:c,announce:f,announceFromDock:p,attach:y,detach:v,goTo:k,minimize:T,restore:E,toggleFold:O,resetLayout:j,focusPanels:w,...A,setWide:M}},I5=nO(),L5=`1.0.0-alpha.21`,R5=()=>vU({client:I5,open:VH,storage:xG(),pageVersion:L5}),z5=()=>F5({storage:xG(),wide:window.matchMedia(t6).matches,onLayoutDropped:()=>{nb.add({title:`Layout reset`,description:`The saved layout could not be read.`})}}),B5=()=>{let[e]=(0,H.useState)(R5),[t]=(0,H.useState)(z5);return(0,H.useLayoutEffect)(()=>gb(window,e.preferences),[e]),(0,H.useEffect)(()=>e.start(),[e]),(0,K.jsx)(ob,{value:e,children:(0,K.jsx)(s_,{children:(0,K.jsx)(ib,{children:(0,K.jsx)(U8,{workspace:t})})})})};export{B5 as App};