squad-kit 0.12.1 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.12.3] — 2026-08-25
|
|
11
|
+
|
|
12
|
+
### Bug fixes
|
|
13
|
+
|
|
14
|
+
- **The console's Doctor page was unreachable.** `/doctor` was defined as a route but never added to
|
|
15
|
+
the router's child list, so the sidebar link, the breadcrumb, and the Cmd+K entry all resolved to a
|
|
16
|
+
bare "Not Found". Introduced in 0.11.0 (`46519fd`, the runs-pages work) and shipped in every
|
|
17
|
+
release since. The CLI's `squad doctor` was unaffected throughout, which is why it went unnoticed.
|
|
18
|
+
|
|
19
|
+
The route is registered again, and `console-ui/src/router.test.ts` now asserts that **every**
|
|
20
|
+
sidebar destination resolves to a registered route. Neither the type checker nor the existing
|
|
21
|
+
tests could catch this: a defined-but-unregistered route is valid unused code, and a link to a
|
|
22
|
+
non-existent path is just a string.
|
|
23
|
+
|
|
24
|
+
## [0.12.2] — 2026-08-25
|
|
25
|
+
|
|
26
|
+
### Bug fixes
|
|
27
|
+
|
|
28
|
+
- **The planner never read any project files, then hung.** On the Agent SDK runtime a run reported
|
|
29
|
+
`reads 0/N`, the scout exhausted its turns without reaching `respond_with_scout_result`, the draft
|
|
30
|
+
produced a plan with no repo context, and the session then stalled indefinitely — the plan file was
|
|
31
|
+
written but the CLI and the console both kept spinning. Reported as
|
|
32
|
+
[#8](https://github.com/AzmSquad/Squad-Kit/issues/8). Two causes, both fixed:
|
|
33
|
+
|
|
34
|
+
1. **Every tool call is gated on a permission decision**, and the runtime supplied no handler. The
|
|
35
|
+
model emitted `tool_use` for `read_file` / `grep` / `list_dir` and nothing ever executed them.
|
|
36
|
+
The runtime now grants its own `mcp__squad-kit-*` tools and denies everything else, so a tool
|
|
37
|
+
the planner did not register can never run during planning.
|
|
38
|
+
2. **A claude.ai login carries the account's connectors into the session** as extra MCP servers
|
|
39
|
+
(Google Drive and friends), crowding the tool namespace the planner depends on — measured at 12
|
|
40
|
+
tools where the planner registers a handful. Planning now runs with `strictMcpConfig`, so it
|
|
41
|
+
sees only the tools squad-kit registers.
|
|
42
|
+
|
|
43
|
+
Verified on a real subscription run: `reads 0/25` and an indefinite hang before, `scout ✓` with
|
|
44
|
+
`reads 8/8` and a clean exit after.
|
|
45
|
+
|
|
46
|
+
**Scope.** Cause 2 needs a Claude subscription login and so only affects 0.12.x. Cause 1 is
|
|
47
|
+
auth-independent and dates to the Agent SDK runtime landing in **0.10.0**, so API-key users on
|
|
48
|
+
`planner.runtime.anthropic: agent-sdk` (the default for Anthropic) were most likely getting
|
|
49
|
+
context-free plans too. That inference follows from the mechanism; it has not been reproduced
|
|
50
|
+
against an API-key run.
|
|
51
|
+
|
|
52
|
+
### Internal
|
|
53
|
+
|
|
54
|
+
- Pinned `packageManager` to `pnpm@9.15.9` and removed the duplicate pin from the CI workflow.
|
|
55
|
+
Corepack had been resolving pnpm 11 locally, which re-added a `packageManager` field on every
|
|
56
|
+
invocation, generated a stray `pnpm-workspace.yaml`, and failed `pnpm install` on unapproved
|
|
57
|
+
esbuild build scripts — breaking `pnpm build`, `pnpm test`, and `npm publish` (whose
|
|
58
|
+
`prepublishOnly` runs all three). The lockfile has always been `lockfileVersion 9.0`.
|
|
59
|
+
|
|
10
60
|
## [0.12.1] — 2026-08-24
|
|
11
61
|
|
|
12
62
|
### Bug fixes
|
package/dist/cli.js
CHANGED
|
@@ -7214,6 +7214,13 @@ async function readSdkAccountInfo(q) {
|
|
|
7214
7214
|
if (timer) clearTimeout(timer);
|
|
7215
7215
|
}
|
|
7216
7216
|
}
|
|
7217
|
+
var SQUAD_MCP_TOOL_PREFIX = "mcp__squad-kit-";
|
|
7218
|
+
function allowOnlySquadKitTools() {
|
|
7219
|
+
return async (toolName, input5) => toolName.startsWith(SQUAD_MCP_TOOL_PREFIX) ? { behavior: "allow", updatedInput: input5 } : {
|
|
7220
|
+
behavior: "deny",
|
|
7221
|
+
message: `The squad-kit planner may only call its own tools; refusing ${toolName}.`
|
|
7222
|
+
};
|
|
7223
|
+
}
|
|
7217
7224
|
var AgentSdkRuntime = class {
|
|
7218
7225
|
constructor(modelId, auth2) {
|
|
7219
7226
|
this.modelId = modelId;
|
|
@@ -7313,6 +7320,11 @@ var AgentSdkRuntime = class {
|
|
|
7313
7320
|
includePartialMessages: true,
|
|
7314
7321
|
persistSession: false,
|
|
7315
7322
|
settingSources: [],
|
|
7323
|
+
// A claude.ai login carries the user's connectors (Drive, etc.) into the session: they show up
|
|
7324
|
+
// as extra MCP servers and crowd the tool namespace the planner depends on. Planning must see
|
|
7325
|
+
// only the tools squad-kit registers.
|
|
7326
|
+
strictMcpConfig: true,
|
|
7327
|
+
canUseTool: allowOnlySquadKitTools(),
|
|
7316
7328
|
abortController: ac,
|
|
7317
7329
|
env: buildSdkEnv(this.auth),
|
|
7318
7330
|
thinking,
|
|
@@ -7442,6 +7454,11 @@ var AgentSdkRuntime = class {
|
|
|
7442
7454
|
includePartialMessages: true,
|
|
7443
7455
|
persistSession: false,
|
|
7444
7456
|
settingSources: [],
|
|
7457
|
+
// A claude.ai login carries the user's connectors (Drive, etc.) into the session: they show up
|
|
7458
|
+
// as extra MCP servers and crowd the tool namespace the planner depends on. Planning must see
|
|
7459
|
+
// only the tools squad-kit registers.
|
|
7460
|
+
strictMcpConfig: true,
|
|
7461
|
+
canUseTool: allowOnlySquadKitTools(),
|
|
7445
7462
|
env: buildSdkEnv(this.auth),
|
|
7446
7463
|
thinking,
|
|
7447
7464
|
effort
|
|
@@ -93,7 +93,7 @@ Error generating stack: `+o.message+`
|
|
|
93
93
|
`)},h2=function(){var e=parseInt(document.body.getAttribute(vu)||"0",10);return isFinite(e)?e:0},WG=function(){C.useEffect(function(){return document.body.setAttribute(vu,(h2()+1).toString()),function(){var e=h2()-1;e<=0?document.body.removeAttribute(vu):document.body.setAttribute(vu,e.toString())}},[])},UG=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;WG();var o=C.useMemo(function(){return BG(i)},[i]);return C.createElement(FG,{styles:zG(o,!t,i,n?"":"!important")})},Vw=!1;if(typeof window<"u")try{var Bp=Object.defineProperty({},"passive",{get:function(){return Vw=!0,!0}});window.addEventListener("test",Bp,Bp),window.removeEventListener("test",Bp,Bp)}catch{Vw=!1}var kl=Vw?{passive:!1}:!1,HG=function(e){return e.tagName==="TEXTAREA"},KB=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!HG(e)&&n[t]==="visible")},VG=function(e){return KB(e,"overflowY")},qG=function(e){return KB(e,"overflowX")},d2=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=GB(e,r);if(i){var o=QB(e,r),s=o[1],a=o[2];if(s>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},KG=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},GG=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},GB=function(e,t){return e==="v"?VG(t):qG(t)},QB=function(e,t){return e==="v"?KG(t):GG(t)},QG=function(e,t){return e==="h"&&t==="rtl"?-1:1},XG=function(e,t,n,r,i){var o=QG(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),u=!1,c=s>0,f=0,h=0;do{if(!a)break;var d=QB(e,a),p=d[0],m=d[1],v=d[2],b=m-v-o*p;(p||b)&&GB(e,a)&&(f+=b,h+=p);var y=a.parentNode;a=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(c&&Math.abs(f)<1||!c&&Math.abs(h)<1)&&(u=!0),u},Fp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},p2=function(e){return[e.deltaX,e.deltaY]},m2=function(e){return e&&"current"in e?e.current:e},YG=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ZG=function(e){return`
|
|
94
94
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
95
95
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
96
|
-
`)},JG=0,Ol=[];function eQ(e){var t=C.useRef([]),n=C.useRef([0,0]),r=C.useRef(),i=C.useState(JG++)[0],o=C.useState(qB)[0],s=C.useRef(e);C.useEffect(function(){s.current=e},[e]),C.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var m=wG([e.lockRef.current],(e.shards||[]).map(m2),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=C.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var b=Fp(m),y=n.current,x="deltaX"in m?m.deltaX:y[0]-b[0],k="deltaY"in m?m.deltaY:y[1]-b[1],w,S=m.target,O=Math.abs(x)>Math.abs(k)?"h":"v";if("touches"in m&&O==="h"&&S.type==="range")return!1;var A=window.getSelection(),P=A&&A.anchorNode,M=P?P===S||P.contains(S):!1;if(M)return!1;var j=d2(O,S);if(!j)return!0;if(j?w=O:(w=O==="v"?"h":"v",j=d2(O,S)),!j)return!1;if(!r.current&&"changedTouches"in m&&(x||k)&&(r.current=w),!w)return!0;var E=r.current||w;return XG(E,v,m,E==="h"?x:k)},[]),l=C.useCallback(function(m){var v=m;if(!(!Ol.length||Ol[Ol.length-1]!==o)){var b="deltaY"in v?p2(v):Fp(v),y=t.current.filter(function(w){return w.name===v.type&&(w.target===v.target||v.target===w.shadowParent)&&YG(w.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var x=(s.current.shards||[]).map(m2).filter(Boolean).filter(function(w){return w.contains(v.target)}),k=x.length>0?a(v,x[0]):!s.current.noIsolation;k&&v.cancelable&&v.preventDefault()}}},[]),u=C.useCallback(function(m,v,b,y){var x={name:m,delta:v,target:b,should:y,shadowParent:tQ(b)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(k){return k!==x})},1)},[]),c=C.useCallback(function(m){n.current=Fp(m),r.current=void 0},[]),f=C.useCallback(function(m){u(m.type,p2(m),m.target,a(m,e.lockRef.current))},[]),h=C.useCallback(function(m){u(m.type,Fp(m),m.target,a(m,e.lockRef.current))},[]);C.useEffect(function(){return Ol.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,kl),document.addEventListener("touchmove",l,kl),document.addEventListener("touchstart",c,kl),function(){Ol=Ol.filter(function(m){return m!==o}),document.removeEventListener("wheel",l,kl),document.removeEventListener("touchmove",l,kl),document.removeEventListener("touchstart",c,kl)}},[]);var d=e.removeScrollBar,p=e.inert;return C.createElement(C.Fragment,null,p?C.createElement(o,{styles:ZG(i)}):null,d?C.createElement(UG,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tQ(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nQ=_G(VB,eQ);var XB=C.forwardRef(function(e,t){return C.createElement(Zv,ji({},e,{ref:t,sideCar:nQ}))});XB.classNames=Zv.classNames;var rQ=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Cl=new WeakMap,zp=new WeakMap,Wp={},fx=0,YB=function(e){return e&&(e.host||YB(e.parentNode))},iQ=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=YB(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},oQ=function(e,t,n,r){var i=iQ(t,Array.isArray(e)?e:[e]);Wp[n]||(Wp[n]=new WeakMap);var o=Wp[n],s=[],a=new Set,l=new Set(i),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};i.forEach(u);var c=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))c(h);else try{var d=h.getAttribute(r),p=d!==null&&d!=="false",m=(Cl.get(h)||0)+1,v=(o.get(h)||0)+1;Cl.set(h,m),o.set(h,v),s.push(h),m===1&&p&&zp.set(h,!0),v===1&&h.setAttribute(n,"true"),p||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return c(t),a.clear(),fx++,function(){s.forEach(function(f){var h=Cl.get(f)-1,d=o.get(f)-1;Cl.set(f,h),o.set(f,d),h||(zp.has(f)||f.removeAttribute(r),zp.delete(f)),d||f.removeAttribute(n)}),fx--,fx||(Cl=new WeakMap,Cl=new WeakMap,zp=new WeakMap,Wp={})}},sQ=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=rQ(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),oQ(r,i,n,"aria-hidden")):function(){return null}},Jv="Dialog",[ZB]=FK(Jv),[aQ,vi]=ZB(Jv),JB=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,a=C.useRef(null),l=C.useRef(null),[u,c]=VK({prop:r,defaultProp:i??!1,onChange:o,caller:Jv});return g.jsx(aQ,{scope:t,triggerRef:a,contentRef:l,contentId:bo(),titleId:bo(),descriptionId:bo(),open:u,onOpenChange:c,onOpenToggle:C.useCallback(()=>c(f=>!f),[c]),modal:s,children:n})};JB.displayName=Jv;var eF="DialogTrigger",lQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(eF,n),o=fl(t,i.triggerRef);return g.jsx($o.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":KC(i.open),...r,ref:o,onClick:ws(e.onClick,i.onOpenToggle)})});lQ.displayName=eF;var VC="DialogPortal",[uQ,tF]=ZB(VC,{forceMount:void 0}),nF=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=vi(VC,t);return g.jsx(uQ,{scope:t,forceMount:n,children:C.Children.map(r,s=>g.jsx(Yv,{present:n||o.open,children:g.jsx(WB,{asChild:!0,container:i,children:s})}))})};nF.displayName=VC;var Fg="DialogOverlay",rF=C.forwardRef((e,t)=>{const n=tF(Fg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=vi(Fg,e.__scopeDialog);return o.modal?g.jsx(Yv,{present:r||o.open,children:g.jsx(fQ,{...i,ref:t})}):null});rF.displayName=Fg;var cQ=DB("DialogOverlay.RemoveScroll"),fQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(Fg,n);return g.jsx(XB,{as:cQ,allowPinchZoom:!0,shards:[i.contentRef],children:g.jsx($o.div,{"data-state":KC(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qa="DialogContent",iF=C.forwardRef((e,t)=>{const n=tF(Qa,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=vi(Qa,e.__scopeDialog);return g.jsx(Yv,{present:r||o.open,children:o.modal?g.jsx(hQ,{...i,ref:t}):g.jsx(dQ,{...i,ref:t})})});iF.displayName=Qa;var hQ=C.forwardRef((e,t)=>{const n=vi(Qa,e.__scopeDialog),r=C.useRef(null),i=fl(t,n.contentRef,r);return C.useEffect(()=>{const o=r.current;if(o)return sQ(o)},[]),g.jsx(oF,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ws(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ws(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:ws(e.onFocusOutside,o=>o.preventDefault())})}),dQ=C.forwardRef((e,t)=>{const n=vi(Qa,e.__scopeDialog),r=C.useRef(!1),i=C.useRef(!1);return g.jsx(oF,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=o.target;n.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),oF=C.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,a=vi(Qa,n),l=C.useRef(null),u=fl(t,l);return xG(),g.jsxs(g.Fragment,{children:[g.jsx(FB,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:g.jsx($B,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":KC(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),g.jsxs(g.Fragment,{children:[g.jsx(yQ,{titleId:a.titleId}),g.jsx(bQ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),qC="DialogTitle",pQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(qC,n);return g.jsx($o.h2,{id:i.titleId,...r,ref:t})});pQ.displayName=qC;var sF="DialogDescription",mQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(sF,n);return g.jsx($o.p,{id:i.descriptionId,...r,ref:t})});mQ.displayName=sF;var aF="DialogClose",gQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(aF,n);return g.jsx($o.button,{type:"button",...r,ref:t,onClick:ws(e.onClick,()=>i.onOpenChange(!1))})});gQ.displayName=aF;function KC(e){return e?"open":"closed"}var lF="DialogTitleWarning",[
|
|
96
|
+
`)},JG=0,Ol=[];function eQ(e){var t=C.useRef([]),n=C.useRef([0,0]),r=C.useRef(),i=C.useState(JG++)[0],o=C.useState(qB)[0],s=C.useRef(e);C.useEffect(function(){s.current=e},[e]),C.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var m=wG([e.lockRef.current],(e.shards||[]).map(m2),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=C.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var b=Fp(m),y=n.current,x="deltaX"in m?m.deltaX:y[0]-b[0],k="deltaY"in m?m.deltaY:y[1]-b[1],w,S=m.target,O=Math.abs(x)>Math.abs(k)?"h":"v";if("touches"in m&&O==="h"&&S.type==="range")return!1;var A=window.getSelection(),P=A&&A.anchorNode,M=P?P===S||P.contains(S):!1;if(M)return!1;var j=d2(O,S);if(!j)return!0;if(j?w=O:(w=O==="v"?"h":"v",j=d2(O,S)),!j)return!1;if(!r.current&&"changedTouches"in m&&(x||k)&&(r.current=w),!w)return!0;var E=r.current||w;return XG(E,v,m,E==="h"?x:k)},[]),l=C.useCallback(function(m){var v=m;if(!(!Ol.length||Ol[Ol.length-1]!==o)){var b="deltaY"in v?p2(v):Fp(v),y=t.current.filter(function(w){return w.name===v.type&&(w.target===v.target||v.target===w.shadowParent)&&YG(w.delta,b)})[0];if(y&&y.should){v.cancelable&&v.preventDefault();return}if(!y){var x=(s.current.shards||[]).map(m2).filter(Boolean).filter(function(w){return w.contains(v.target)}),k=x.length>0?a(v,x[0]):!s.current.noIsolation;k&&v.cancelable&&v.preventDefault()}}},[]),u=C.useCallback(function(m,v,b,y){var x={name:m,delta:v,target:b,should:y,shadowParent:tQ(b)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(k){return k!==x})},1)},[]),c=C.useCallback(function(m){n.current=Fp(m),r.current=void 0},[]),f=C.useCallback(function(m){u(m.type,p2(m),m.target,a(m,e.lockRef.current))},[]),h=C.useCallback(function(m){u(m.type,Fp(m),m.target,a(m,e.lockRef.current))},[]);C.useEffect(function(){return Ol.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,kl),document.addEventListener("touchmove",l,kl),document.addEventListener("touchstart",c,kl),function(){Ol=Ol.filter(function(m){return m!==o}),document.removeEventListener("wheel",l,kl),document.removeEventListener("touchmove",l,kl),document.removeEventListener("touchstart",c,kl)}},[]);var d=e.removeScrollBar,p=e.inert;return C.createElement(C.Fragment,null,p?C.createElement(o,{styles:ZG(i)}):null,d?C.createElement(UG,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tQ(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nQ=_G(VB,eQ);var XB=C.forwardRef(function(e,t){return C.createElement(Zv,ji({},e,{ref:t,sideCar:nQ}))});XB.classNames=Zv.classNames;var rQ=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Cl=new WeakMap,zp=new WeakMap,Wp={},fx=0,YB=function(e){return e&&(e.host||YB(e.parentNode))},iQ=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=YB(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},oQ=function(e,t,n,r){var i=iQ(t,Array.isArray(e)?e:[e]);Wp[n]||(Wp[n]=new WeakMap);var o=Wp[n],s=[],a=new Set,l=new Set(i),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};i.forEach(u);var c=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))c(h);else try{var d=h.getAttribute(r),p=d!==null&&d!=="false",m=(Cl.get(h)||0)+1,v=(o.get(h)||0)+1;Cl.set(h,m),o.set(h,v),s.push(h),m===1&&p&&zp.set(h,!0),v===1&&h.setAttribute(n,"true"),p||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return c(t),a.clear(),fx++,function(){s.forEach(function(f){var h=Cl.get(f)-1,d=o.get(f)-1;Cl.set(f,h),o.set(f,d),h||(zp.has(f)||f.removeAttribute(r),zp.delete(f)),d||f.removeAttribute(n)}),fx--,fx||(Cl=new WeakMap,Cl=new WeakMap,zp=new WeakMap,Wp={})}},sQ=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=rQ(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),oQ(r,i,n,"aria-hidden")):function(){return null}},Jv="Dialog",[ZB]=FK(Jv),[aQ,vi]=ZB(Jv),JB=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,a=C.useRef(null),l=C.useRef(null),[u,c]=VK({prop:r,defaultProp:i??!1,onChange:o,caller:Jv});return g.jsx(aQ,{scope:t,triggerRef:a,contentRef:l,contentId:bo(),titleId:bo(),descriptionId:bo(),open:u,onOpenChange:c,onOpenToggle:C.useCallback(()=>c(f=>!f),[c]),modal:s,children:n})};JB.displayName=Jv;var eF="DialogTrigger",lQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(eF,n),o=fl(t,i.triggerRef);return g.jsx($o.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":KC(i.open),...r,ref:o,onClick:ws(e.onClick,i.onOpenToggle)})});lQ.displayName=eF;var VC="DialogPortal",[uQ,tF]=ZB(VC,{forceMount:void 0}),nF=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=vi(VC,t);return g.jsx(uQ,{scope:t,forceMount:n,children:C.Children.map(r,s=>g.jsx(Yv,{present:n||o.open,children:g.jsx(WB,{asChild:!0,container:i,children:s})}))})};nF.displayName=VC;var Fg="DialogOverlay",rF=C.forwardRef((e,t)=>{const n=tF(Fg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=vi(Fg,e.__scopeDialog);return o.modal?g.jsx(Yv,{present:r||o.open,children:g.jsx(fQ,{...i,ref:t})}):null});rF.displayName=Fg;var cQ=DB("DialogOverlay.RemoveScroll"),fQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(Fg,n);return g.jsx(XB,{as:cQ,allowPinchZoom:!0,shards:[i.contentRef],children:g.jsx($o.div,{"data-state":KC(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qa="DialogContent",iF=C.forwardRef((e,t)=>{const n=tF(Qa,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=vi(Qa,e.__scopeDialog);return g.jsx(Yv,{present:r||o.open,children:o.modal?g.jsx(hQ,{...i,ref:t}):g.jsx(dQ,{...i,ref:t})})});iF.displayName=Qa;var hQ=C.forwardRef((e,t)=>{const n=vi(Qa,e.__scopeDialog),r=C.useRef(null),i=fl(t,n.contentRef,r);return C.useEffect(()=>{const o=r.current;if(o)return sQ(o)},[]),g.jsx(oF,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ws(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ws(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:ws(e.onFocusOutside,o=>o.preventDefault())})}),dQ=C.forwardRef((e,t)=>{const n=vi(Qa,e.__scopeDialog),r=C.useRef(!1),i=C.useRef(!1);return g.jsx(oF,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=o.target;n.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),oF=C.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,a=vi(Qa,n),l=C.useRef(null),u=fl(t,l);return xG(),g.jsxs(g.Fragment,{children:[g.jsx(FB,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:g.jsx($B,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":KC(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),g.jsxs(g.Fragment,{children:[g.jsx(yQ,{titleId:a.titleId}),g.jsx(bQ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),qC="DialogTitle",pQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(qC,n);return g.jsx($o.h2,{id:i.titleId,...r,ref:t})});pQ.displayName=qC;var sF="DialogDescription",mQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(sF,n);return g.jsx($o.p,{id:i.descriptionId,...r,ref:t})});mQ.displayName=sF;var aF="DialogClose",gQ=C.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=vi(aF,n);return g.jsx($o.button,{type:"button",...r,ref:t,onClick:ws(e.onClick,()=>i.onOpenChange(!1))})});gQ.displayName=aF;function KC(e){return e?"open":"closed"}var lF="DialogTitleWarning",[KBe,uF]=BK(lF,{contentName:Qa,titleName:qC,docsSlug:"dialog"}),yQ=({titleId:e})=>{const t=uF(lF),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
97
97
|
|
|
98
98
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
99
99
|
|
|
@@ -439,4 +439,4 @@ ${d.slice(-2).join(`
|
|
|
439
439
|
--\u2028\u2029\uFEFF-]`,bO),gIe={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let m1=null;function yIe(){var e;if(m1==null&&typeof document<"u"&&document.body){let t=document.body.style;m1=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return m1||!1}const ig=se.define({combine(e){let t=Ji(e,{render:null,specialChars:mIe,addSpecialChars:null});return(t.replaceTabs=!yIe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,bO)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,bO)),t}});function vIe(e={}){return[ig.of(e),bIe()]}let OR=null;function bIe(){return OR||(OR=Et.fromClass(class{constructor(e){this.view=e,this.decorations=de.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(ig)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new pIe({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=zn(t[0],0);if(o==9){let s=i.lineAt(r),a=n.state.tabSize,l=qc(s.text,a,r-s.from);return de.replace({widget:new kIe((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=de.replace({widget:new SIe(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(ig);e.startState.facet(ig)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const xIe="•";function wIe(e){return e>=32?xIe:e==10?"":String.fromCharCode(9216+e)}class SIe extends eo{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=wIe(this.code),r=t.state.phrase("Control character")+" "+(gIe[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let o=document.createElement("span");return o.textContent=n,o.title=r,o.setAttribute("aria-label",r),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class kIe extends eo{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function OIe(){return AIe}const CIe=de.line({class:"cm-activeLine"}),AIe=Et.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(CIe.range(i.from)),t=i.from)}return de.set(n)}},{decorations:e=>e.decorations});class PIe extends eo{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?ch(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Id(n[0],r.direction!="rtl"),o=parseInt(r.lineHeight);return i.bottom-i.top>o*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+o}:i}ignoreEvent(){return!1}}function EIe(e){let t=Et.fromClass(class{constructor(n){this.view=n,this.placeholder=e?de.set([de.widget({widget:new PIe(e),side:1}).range(0)]):de.none}get decorations(){return this.view.state.doc.length?de.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,ie.contentAttributes.of({"aria-placeholder":e})]:t}const xO=2e3;function TIe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>xO||n.off>xO||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let u=e.doc.line(l);u.length<=a&&o.push(V.range(u.from+s,u.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let u=e.doc.line(l),c=Jk(u.text,s,e.tabSize,!0);if(c<0)o.push(V.cursor(u.to));else{let f=Jk(u.text,a,e.tabSize);o.push(V.range(u.from+c,u.from+f))}}}return o}function _Ie(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function CR(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>xO?-1:i==r.length?_Ie(e,t.clientX):qc(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function jIe(e,t){let n=CR(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let o=i.changes.mapPos(i.startState.doc.line(n.line).from),s=i.state.doc.lineAt(o);n={line:s.number,col:n.col,off:Math.min(n.off,s.length)},r=r.map(i.changes)}},get(i,o,s){let a=CR(e,i);if(!a)return r;let l=TIe(e.state,n,a);return l.length?s?V.create(l.concat(r.ranges)):V.create(l):r}}:null}function MIe(e){let t=n=>n.altKey&&n.button==0;return ie.mouseSelectionStyle.of((n,r)=>t(r)?jIe(n,r):null)}const IIe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},NIe={style:"cursor: crosshair"};function RIe(e={}){let[t,n]=IIe[e.key||"Alt"],r=Et.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,ie.contentAttributes.of(i=>{var o;return!((o=i.plugin(r))===null||o===void 0)&&o.isDown?NIe:null})]}const bm="-10000px";class S9{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(s=>s);let o=null;this.tooltipViews=this.tooltips.map(s=>o=r(s,o))}update(t,n){var r;let i=t.state.facet(this.facet),o=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let s=[],a=n?[]:null;for(let l=0;l<o.length;l++){let u=o[l],c=-1;if(u){for(let f=0;f<this.tooltips.length;f++){let h=this.tooltips[f];h&&h.create==u.create&&(c=f)}if(c<0)s[l]=this.createTooltipView(u,l?s[l-1]:null),a&&(a[l]=!!u.above);else{let f=s[l]=this.tooltipViews[c];a&&(a[l]=n[c]),f.update&&f.update(t)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(a.forEach((l,u)=>n[u]=l),n.length=a.length),this.input=i,this.tooltips=o,this.tooltipViews=s,!0}}function DIe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const g1=se.define({combine:e=>{var t,n,r;return{position:oe.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||DIe}}}),AR=new WeakMap,HP=Et.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(g1);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new S9(e,VP,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(g1);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=bm,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(oe.safari){let s=o.getBoundingClientRect();n=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}else n=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(e=o.width/this.parent.offsetWidth,t=o.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=FP(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,s)=>{let a=this.manager.tooltipViews[s];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(g1).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],u=this.manager.tooltipViews[a],{dom:c}=u,f=e.pos[a],h=e.size[a];if(!f||l.clip!==!1&&(f.bottom<=Math.max(n.top,r.top)||f.top>=Math.min(n.bottom,r.bottom)||f.right<Math.max(n.left,r.left)-.1||f.left>Math.min(n.right,r.right)+.1)){c.style.top=bm;continue}let d=l.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,v=(t=AR.get(u))!==null&&t!==void 0?t:h.bottom-h.top,b=u.offset||$Ie,y=this.view.textDirection==Je.LTR,x=h.width>r.right-r.left?y?r.left:r.right-h.width:y?Math.max(r.left,Math.min(f.left-(d?14:0)+b.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(d?14:0)-b.x),r.right-m),k=this.above[a];!l.strictSide&&(k?f.top-v-p-b.y<r.top:f.bottom+v+p+b.y>r.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[a]=!k);let w=(k?f.top-r.top:r.bottom-f.bottom)-p;if(w<v&&u.resize!==!1){if(w<this.view.defaultLineHeight){c.style.top=bm;continue}AR.set(u,v),c.style.height=(v=w)/o+"px"}else c.style.height&&(c.style.height="");let S=k?f.top-v-p-b.y:f.bottom+p+b.y,O=x+m;if(u.overlap!==!0)for(let A of s)A.left<O&&A.right>x&&A.top<S+v&&A.bottom>S&&(S=k?A.top-v-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-e.parent.top)/o+"px",PR(c,(x-e.parent.left)/i)):(c.style.top=S/o+"px",PR(c,x/i)),d){let A=f.left+(y?b.x:-b.x)-(x+14-7);d.style.left=A/i+"px"}u.overlap!==!0&&s.push({left:x,top:S,right:O,bottom:S+v}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=bm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function PR(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const LIe=ie.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),$Ie={x:0,y:0},VP=se.define({enables:[HP,LIe]}),hv=se.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class hb{static create(t){return new hb(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new S9(t,hv,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const BIe=VP.compute([hv],e=>{let t=e.facet(hv);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:hb.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class FIe{constructor(t,n,r,i,o){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.tile.nearest(n.target);if(!r)return;let i,o=1;if(r.isWidget())i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let a=t.coordsAtPos(i);if(!a||n.y<a.top||n.y>a.bottom||n.x<a.left-t.defaultCharacterWidth||n.x>a.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(c=>c.from<=i&&c.to>=i),u=l&&l.dir==Je.RTL?-1:1;o=n.x<a.left?-u:u}let s=this.source(t,i,o);if(s?.then){let a=this.pending={pos:i};s.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Gn(t.state,l,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let t=this.view.plugin(HP),n=t?t.manager.tooltips.findIndex(r=>r.create==hb.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:o}=this;if(i.length&&o&&!zIe(o.dom,t)||this.pending){let{pos:s}=i[0]||this.pending,a=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!WIe(this.view,s,a,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const xm=4;function zIe(e,t){let{left:n,right:r,top:i,bottom:o}=e.getBoundingClientRect(),s;if(s=e.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();i=Math.min(a.top,i),o=Math.max(a.bottom,o)}return t.clientX>=n-xm&&t.clientX<=r+xm&&t.clientY>=i-xm&&t.clientY<=o+xm}function WIe(e,t,n,r,i,o){let s=e.scrollDOM.getBoundingClientRect(),a=e.documentTop+e.documentPadding.top+e.contentHeight;if(s.left>r||s.right<r||s.top>i||Math.min(s.bottom,a)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function UIe(e,t={}){let n=ke.define(),r=kn.define({create(){return[]},update(i,o){if(i.length&&(t.hideOnChange&&(o.docChanged||o.selection)?i=[]:t.hideOn&&(i=i.filter(s=>!t.hideOn(o,s))),o.docChanged)){let s=[];for(let a of i){let l=o.changes.mapPos(a.pos,-1,jn.TrackDel);if(l!=null){let u=Object.assign(Object.create(null),a);u.pos=l,u.end!=null&&(u.end=o.changes.mapPos(u.end)),s.push(u)}}i=s}for(let s of o.effects)s.is(n)&&(i=s.value),s.is(HIe)&&(i=[]);return i},provide:i=>hv.from(i)});return{active:r,extension:[r,Et.define(i=>new FIe(i,e,r,n,t.hoverTime||300)),BIe]}}function k9(e,t){let n=e.plugin(HP);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const HIe=ke.define(),ER=se.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function qP(e,t){let n=e.plugin(O9),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const O9=Et.fromClass(class{constructor(e){this.input=e.state.facet(Rd),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(ER);this.top=new wm(e,!0,t.topContainer),this.bottom=new wm(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(ER);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new wm(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new wm(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Rd);if(n!=this.input){let r=n.filter(l=>l),i=[],o=[],s=[],a=[];for(let l of r){let u=this.specs.indexOf(l),c;u<0?(c=l(e.view),a.push(c)):(c=this.panels[u],c.update&&c.update(e)),i.push(c),(c.top?o:s).push(c)}this.specs=r,this.panels=i,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>ie.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class wm{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=TR(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=TR(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function TR(e){let t=e.nextSibling;return e.remove(),t}const Rd=se.define({enables:O9});function VIe(e,t){let n,r=new Promise(s=>n=s),i=s=>qIe(s,t,n);e.state.field(y1,!1)?e.dispatch({effects:C9.of(i)}):e.dispatch({effects:ke.appendConfig.of(y1.init(()=>[i]))});let o=A9.of(i);return{close:o,result:r.then(s=>((e.win.queueMicrotask||(l=>e.win.setTimeout(l,10)))(()=>{e.state.field(y1).indexOf(i)>-1&&e.dispatch({effects:o})}),s))}}const y1=kn.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(C9)?e=[n.value].concat(e):n.is(A9)&&(e=e.filter(r=>r!=n.value));return e},provide:e=>Rd.computeN([e],t=>t.field(e))}),C9=ke.define(),A9=ke.define();function qIe(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=Ke("form"),t.input){let a=Ke("input",t.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),r.appendChild(Ke("label",(t.label||"")+": ",a))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Ke("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let a=0;a<i.length;a++){let l=i[a];l.addEventListener("keydown",u=>{u.keyCode==27?(u.preventDefault(),s(null)):u.keyCode==13&&(u.preventDefault(),s(l))}),l.addEventListener("submit",u=>{u.preventDefault(),s(l)})}let o=Ke("div",r,Ke("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class),o.classList.add("cm-dialog");function s(a){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(a)}return{dom:o,top:t.top,mount:()=>{if(t.focus){let a;typeof t.focus=="string"?a=r.querySelector(t.focus):a=r.querySelector("input")||r.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}class Ro extends js{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Ro.prototype.elementClass="";Ro.prototype.toDOM=void 0;Ro.prototype.mapMode=jn.TrackBefore;Ro.prototype.startSide=Ro.prototype.endSide=-1;Ro.prototype.point=!0;const og=se.define(),KIe=se.define(),GIe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>_e.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},dh=se.define();function QIe(e){return[P9(),dh.of({...GIe,...e})]}const _R=se.define({combine:e=>e.some(t=>t)});function P9(e){return[XIe]}const XIe=Et.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(dh).map(t=>new MR(e,t)),this.fixed=!e.state.facet(_R);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(_R)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=_e.iter(this.view.state.facet(og),this.view.viewport.from),r=[],i=this.gutters.map(o=>new YIe(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let s=!0;for(let a of o.type)if(a.type==fn.Text&&s){wO(n,r,a.from);for(let l of i)l.line(this.view,a,r);s=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(o.type==fn.Text){wO(n,r,o.from);for(let s of i)s.line(this.view,o,r)}else if(o.widget)for(let s of i)s.widget(this.view,o);for(let o of i)o.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(dh),n=e.state.facet(dh),r=e.docChanged||e.heightChanged||e.viewportChanged||!_e.eq(e.startState.facet(og),e.state.facet(og),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let o of n){let s=t.indexOf(o);s<0?i.push(new MR(this.view,o)):(this.gutters[s].update(e),i.push(this.gutters[s]))}for(let o of this.gutters)o.dom.remove(),i.indexOf(o)<0&&o.destroy();for(let o of i)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>ie.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==Je.LTR?{left:r,right:i}:{right:r,left:i}})});function jR(e){return Array.isArray(e)?e:[e]}function wO(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class YIe{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=_e.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,o=(n.top-this.height)/t.scaleY,s=n.height/t.scaleY;if(this.i==i.elements.length){let a=new E9(t,s,o,r);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(t,s,o,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];wO(this.cursor,i,n.from),r.length&&(i=i.concat(r));let o=this.gutter.config.lineMarker(t,n,i);o&&i.unshift(o);let s=this.gutter;i.length==0&&!s.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let o of t.state.facet(KIe)){let s=o(t,n.widget,n);s&&(i||(i=[])).push(s)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class MR{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let o=i.target,s;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let l=o.getBoundingClientRect();s=(l.top+l.bottom)/2}else s=i.clientY;let a=t.lineBlockAtHeight(s-t.documentTop);n.domEventHandlers[r](t,a,i)&&i.preventDefault()});this.markers=jR(n.markers(t)),n.initialSpacer&&(this.spacer=new E9(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=jR(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!_e.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class E9{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),ZIe(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let o=0,s=0;;){let a=s,l=o<n.length?n[o++]:null,u=!1;if(l){let c=l.elementClass;c&&(r+=" "+c);for(let f=s;f<this.markers.length;f++)if(this.markers[f].compare(l)){a=f,u=!0;break}}else a=this.markers.length;for(;s<a;){let c=this.markers[s++];if(c.toDOM){c.destroy(i);let f=i.nextSibling;i.remove(),i=f}}if(!l)break;l.toDOM&&(u?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),u&&s++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function ZIe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}const JIe=se.define(),eNe=se.define(),lu=se.define({combine(e){return Ji(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let o=r[i],s=n[i];r[i]=o?(a,l,u)=>o(a,l,u)||s(a,l,u):s}return r}})}});class v1 extends Ro{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function b1(e,t){return e.state.facet(lu).formatNumber(t,e.state)}const tNe=dh.compute([lu],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(JIe)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new v1(b1(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(eNe)){let o=i(t,n,r);if(o)return o}return null},lineMarkerChange:t=>t.startState.facet(lu)!=t.state.facet(lu),initialSpacer(t){return new v1(b1(t,IR(t.state.doc.lines)))},updateSpacer(t,n){let r=b1(n.view,IR(n.view.state.doc.lines));return r==t.number?t:new v1(r)},domEventHandlers:e.facet(lu).domEventHandlers,side:"before"}));function nNe(e={}){return[lu.of(e),P9(),tNe]}function IR(e){let t=9;for(;t<e;)t=t*10+9;return t}const rNe=new class extends Ro{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},iNe=og.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(rNe.range(i)))}return _e.of(t)});function oNe(){return iNe}const T9=1024;let sNe=0;class x1{constructor(t,n){this.from=t,this.to=n}}class Te{constructor(t={}){this.id=sNe++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=nr.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}Te.closedBy=new Te({deserialize:e=>e.split(" ")});Te.openedBy=new Te({deserialize:e=>e.split(" ")});Te.group=new Te({deserialize:e=>e.split(" ")});Te.isolate=new Te({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Te.contextHash=new Te({perNode:!0});Te.lookAhead=new Te({perNode:!0});Te.mounted=new Te({perNode:!0});class ph{constructor(t,n,r,i=!1){this.tree=t,this.overlay=n,this.parser=r,this.bracketed=i}static get(t){return t&&t.props&&t.props[Te.mounted.id]}}const aNe=Object.create(null);class nr{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):aNe,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new nr(t.name||"",n,t.id,r);if(t.props){for(let o of t.props)if(Array.isArray(o)||(o=o(i)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(Te.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(Te.group),o=-1;o<(i?i.length:0);o++){let s=n[o<0?r.name:i[o]];if(s)return s}}}}nr.none=new nr("",Object.create(null),0,8);class KP{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let o of t){let s=o(r);if(s){i||(i=Object.assign({},r.props));let a=s[1],l=s[0];l.combine&&l.id in i&&(a=l.combine(i[l.id],a)),i[l.id]=a}}n.push(i?new nr(r.name,i,r.id,r.flags):r)}return new KP(n)}}const Sm=new WeakMap,NR=new WeakMap;var At;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"})(At||(At={}));class jt{constructor(t,n,r,i,o){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let t=ph.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new kO(this.topNode,t)}cursorAt(t,n=0,r=0){let i=Sm.get(this)||this.topNode,o=new kO(i);return o.moveTo(t,n),Sm.set(this,o._tree),o}get topNode(){return new Vr(this,0,0,null)}resolve(t,n=0){let r=Dd(Sm.get(this)||this.topNode,t,n,!1);return Sm.set(this,r),r}resolveInner(t,n=0){let r=Dd(NR.get(this)||this.topNode,t,n,!0);return NR.set(this,r),r}resolveStack(t,n=0){return cNe(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:o=this.length}=t,s=t.mode||0,a=(s&At.IncludeAnonymous)>0;for(let l=this.cursor(s|At.IncludeAnonymous);;){let u=!1;if(l.from<=o&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:XP(nr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new jt(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new jt(nr.none,n,r,i)))}static build(t){return fNe(t)}}jt.empty=new jt(nr.none,[],[],0);class GP{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new GP(this.buffer,this.index)}}class Rs{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return nr.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],o=i.name;if(/\W/.test(o)&&!i.isError&&(o=JSON.stringify(o)),t+=4,r==t)return o;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return o+"("+s.join(",")+")"}findChild(t,n,r,i,o){let{buffer:s}=this,a=-1;for(let l=t;l!=n&&!(_9(o,i,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(t,n,r){let i=this.buffer,o=new Uint16Array(n-t),s=0;for(let a=t,l=0;a<n;){o[l++]=i[a++],o[l++]=i[a++]-r;let u=o[l++]=i[a++]-r;o[l++]=i[a++]-t,s=Math.max(s,u)}return new Rs(o,s,this.set)}}function _9(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Dd(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let s=!r&&e instanceof Vr&&e.index<0?null:e.parent;if(!s)return e;e=s}let o=r?0:At.IgnoreOverlays;if(r)for(let s=e,a=s.parent;a;s=a,a=s.parent)s instanceof Vr&&s.index<0&&((i=a.enter(t,n,o))===null||i===void 0?void 0:i.from)!=s.from&&(e=a);for(;;){let s=e.enter(t,n,o);if(!s)return e;e=s}}class j9{cursor(t=0){return new kO(this,t)}getChild(t,n=null,r=null){let i=RR(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return RR(this,t,n,r)}resolve(t,n=0){return Dd(this,t,n,!1)}resolveInner(t,n=0){return Dd(this,t,n,!0)}matchContext(t){return SO(this.parent,t)}enterUnfinishedNodesBefore(t){let n=this.childBefore(t),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Vr extends j9{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,o=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,u=n>0?a.length:-1;t!=u;t+=n){let c=a[t],f=l[t]+s.from,h;if(!(!(o&At.EnterBracketed&&c instanceof jt&&(h=ph.get(c))&&!h.overlay&&h.bracketed&&r>=f&&r<=f+c.length)&&!_9(i,r,f,f+c.length))){if(c instanceof Rs){if(o&At.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,n,r-f,i);if(d>-1)return new cs(new lNe(s,c,t,f),null,d)}else if(o&At.IncludeAnonymous||!c.type.isAnonymous||QP(c)){let d;if(!(o&At.IgnoreMounts)&&(d=ph.get(c))&&!d.overlay)return new Vr(d.tree,f,t,s);let p=new Vr(c,f,t,s);return o&At.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,o)}}}if(o&At.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?t=s.index+n:t=n<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,n,r=0){let i;if(!(r&At.IgnoreOverlays)&&(i=ph.get(this._tree))&&i.overlay){let o=t-this.from,s=r&At.EnterBracketed&&i.bracketed;for(let{from:a,to:l}of i.overlay)if((n>0||s?a<=o:a<o)&&(n<0||s?l>=o:l>o))return new Vr(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function RR(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(n!=null){for(let s=!1;!s;)if(s=i.type.is(n),!i.nextSibling())return o}for(;;){if(r!=null&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return r==null?o:[]}}function SO(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class lNe{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class cs extends j9{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return o<0?null:new cs(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,n,r=0){if(r&At.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return o<0?null:new cs(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new cs(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new cs(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,o=r.buffer[this.index+3];if(o>i){let s=r.buffer[this.index+1];t.push(r.slice(i,o,s)),n.push(0)}return new jt(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function M9(e){if(!e.length)return null;let t=0,n=e[0];for(let o=1;o<e.length;o++){let s=e[o];(s.from>n.from||s.to<n.to)&&(n=s,t=o)}let r=n instanceof Vr&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new uNe(i,n)}class uNe{constructor(t,n){this.heads=t,this.node=n}get next(){return M9(this.heads)}}function cNe(e,t,n){let r=e.resolveInner(t,n),i=null;for(let o=r instanceof Vr?r:r.context.parent;o;o=o.parent)if(o.index<0){let s=o.parent;(i||(i=[r])).push(s.resolve(t,n)),o=s}else{let s=ph.get(o.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let a=new Vr(s.tree,s.overlay[0].from+o.from,-1,o);(i||(i=[r])).push(Dd(a,t,n,!1))}}return i?M9(i):r}class kO{get name(){return this.type.name}constructor(t,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~At.EnterBracketed,t instanceof Vr)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[t]],this.from=r+i.buffer[t+1],this.to=r+i.buffer[t+2],!0}yield(t){return t?t instanceof Vr?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,r,this.mode));let{buffer:i}=this.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.buffer.start,r);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,r=this.mode){return this.buffer?r&At.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&At.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&At.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(t<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,r,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(i.buffer.buffer[o+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let o=n+t,s=t<0?-1:r._tree.children.length;o!=s;o+=t){let a=r._tree.children[o];if(this.mode&At.IncludeAnonymous||a instanceof Rs||!a.type.isAnonymous||QP(a))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,n););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,n=null,r=0;if(t&&t.context==this.buffer)e:for(let i=this.index,o=this.stack.length;o>=0;){for(let s=t;s;s=s._parent)if(s.index==i){if(i==this.index)return s;n=s,r=o+1;break e}i=this.stack[--o]}for(let i=r;i<this.stack.length;i++)n=new cs(this.buffer,n,this.stack[i]);return this.bufferNode=new cs(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(t){if(!this.buffer)return SO(this.node.parent,t);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=t.length-1,o=this.stack.length-1;i>=0;o--){if(o<0)return SO(this._tree,t,i);let s=r[n.buffer[this.stack[o]]];if(!s.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}}function QP(e){return e.children.some(t=>t instanceof Rs||!t.type.isAnonymous||QP(t))}function fNe(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=T9,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new GP(n,n.length):n,l=r.types,u=0,c=0;function f(w,S,O,A,P,M){let{id:j,start:E,end:D,size:R}=a,N=c,B=u;if(R<0)if(a.next(),R==-1){let q=o[j];O.push(q),A.push(E-w);return}else if(R==-3){u=j;return}else if(R==-4){c=j;return}else throw new RangeError(`Unrecognized record size: ${R}`);let F=l[j],$,z,T=E-w;if(D-E<=i&&(z=v(a.pos-S,P))){let q=new Uint16Array(z.size-z.skip),I=a.pos-z.size,_=q.length;for(;a.pos>I;)_=b(z.start,q,_);$=new Rs(q,D-z.start,r),T=z.start-w}else{let q=a.pos-R;a.next();let I=[],_=[],K=j>=s?j:-1,Q=0,te=D;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=te-i&&(p(I,_,E,Q,a.end,te,K,N,B),Q=I.length,te=a.end),a.next()):M>2500?h(E,q,I,_):f(E,q,I,_,K,M+1);if(K>=0&&Q>0&&Q<I.length&&p(I,_,E,Q,E,te,K,N,B),I.reverse(),_.reverse(),K>-1&&Q>0){let he=d(F,B);$=XP(F,I,_,0,I.length,0,D-E,he,he)}else $=m(F,I,_,D-E,N-D,B)}O.push($),A.push(T)}function h(w,S,O,A){let P=[],M=0,j=-1;for(;a.pos>S;){let{id:E,start:D,end:R,size:N}=a;if(N>4)a.next();else{if(j>-1&&D<j)break;j<0&&(j=R-i),P.push(E,D,R),M++,a.next()}}if(M){let E=new Uint16Array(M*4),D=P[P.length-2];for(let R=P.length-3,N=0;R>=0;R-=3)E[N++]=P[R],E[N++]=P[R+1]-D,E[N++]=P[R+2]-D,E[N++]=N;O.push(new Rs(E,P[2]-D,r)),A.push(D-w)}}function d(w,S){return(O,A,P)=>{let M=0,j=O.length-1,E,D;if(j>=0&&(E=O[j])instanceof jt){if(!j&&E.type==w&&E.length==P)return E;(D=E.prop(Te.lookAhead))&&(M=A[j]+E.length+D)}return m(w,O,A,P,M,S)}}function p(w,S,O,A,P,M,j,E,D){let R=[],N=[];for(;w.length>A;)R.push(w.pop()),N.push(S.pop()+O-P);w.push(m(r.types[j],R,N,M-P,E-M,D)),S.push(P-O)}function m(w,S,O,A,P,M,j){if(M){let E=[Te.contextHash,M];j=j?[E].concat(j):[E]}if(P>25){let E=[Te.lookAhead,P];j=j?[E].concat(j):[E]}return new jt(w,S,O,A,j)}function v(w,S){let O=a.fork(),A=0,P=0,M=0,j=O.end-i,E={size:0,start:0,skip:0};e:for(let D=O.pos-w;O.pos>D;){let R=O.size;if(O.id==S&&R>=0){E.size=A,E.start=P,E.skip=M,M+=4,A+=4,O.next();continue}let N=O.pos-R;if(R<0||N<D||O.start<j)break;let B=O.id>=s?4:0,F=O.start;for(O.next();O.pos>N;){if(O.size<0)if(O.size==-3||O.size==-4)B+=4;else break e;else O.id>=s&&(B+=4);O.next()}P=F,A+=R,M+=B}return(S<0||A==w)&&(E.size=A,E.start=P,E.skip=M),E.size>4?E:void 0}function b(w,S,O){let{id:A,start:P,end:M,size:j}=a;if(a.next(),j>=0&&A<s){let E=O;if(j>4){let D=a.pos-(j-4);for(;a.pos>D;)O=b(w,S,O)}S[--O]=E,S[--O]=M-w,S[--O]=P-w,S[--O]=A}else j==-3?u=A:j==-4&&(c=A);return O}let y=[],x=[];for(;a.pos>0;)f(e.start||0,e.bufferStart||0,y,x,-1,0);let k=(t=e.length)!==null&&t!==void 0?t:y.length?x[0]+y[0].length:0;return new jt(l[e.topID],y.reverse(),x.reverse(),k)}const DR=new WeakMap;function sg(e,t){if(!e.isAnonymous||t instanceof Rs||t.type!=e)return 1;let n=DR.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof jt)){n=1;break}n+=sg(e,r)}DR.set(t,n)}return n}function XP(e,t,n,r,i,o,s,a,l){let u=0;for(let p=r;p<i;p++)u+=sg(e,t[p]);let c=Math.ceil(u*1.5/8),f=[],h=[];function d(p,m,v,b,y){for(let x=v;x<b;){let k=x,w=m[x],S=sg(e,p[x]);for(x++;x<b;x++){let O=sg(e,p[x]);if(S+O>=c)break;S+=O}if(x==k+1){if(S>c){let O=p[k];d(O.children,O.positions,0,O.children.length,m[k]+y);continue}f.push(p[k])}else{let O=m[x-1]+p[x-1].length-w;f.push(XP(e,p,m,k,x,w,O,null,l))}h.push(w+y-o)}}return d(t,n,r,i,0),(a||l)(f,h,s)}class za{constructor(t,n,r,i,o=!1,s=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new za(0,t.length,t,0,!1,r)];for(let o of n)o.to>t.length&&i.push(o);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],o=1,s=t.length?t[0]:null;for(let a=0,l=0,u=0;;a++){let c=a<n.length?n[a]:null,f=c?c.fromA:1e9;if(f-l>=r)for(;s&&s.from<f;){let h=s;if(l>=h.from||f<=h.to||u){let d=Math.max(h.from,l)-u,p=Math.min(h.to,f)-u;h=d>=p?null:new za(d,p,h.tree,h.offset+u,a>0,!!c)}if(h&&i.push(h),s.to>f)break;s=o<t.length?t[o++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}}class I9{startParse(t,n,r){return typeof t=="string"&&(t=new hNe(t)),r=r?r.length?r.map(i=>new x1(i.from,i.to)):[new x1(0,0)]:[new x1(0,t.length)],this.createParse(t,n||[],r)}parse(t,n,r){let i=this.startParse(t,n,r);for(;;){let o=i.advance();if(o)return o}}}class hNe{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}new Te({perNode:!0});let dNe=0,lo=class OO{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=dNe++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof OO&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new OO(r,[],null,[]);if(i.set.push(i),n)for(let o of n.set)i.set.push(o);return i}static defineModifier(t){let n=new dv(t);return r=>r.modified.indexOf(n)>-1?r:dv.get(r.base||r,r.modified.concat(n).sort((i,o)=>i.id-o.id))}},pNe=0;class dv{constructor(t){this.name=t,this.instances=[],this.id=pNe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(a=>a.base==t&&mNe(n,a.modified));if(r)return r;let i=[],o=new lo(t.name,i,t,n);for(let a of n)a.instances.push(o);let s=gNe(n);for(let a of t.set)if(!a.modified.length)for(let l of s)i.push(dv.get(a,l));return o}}function mNe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function gNe(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function N9(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let o=[],s=2,a=i;for(let f=0;;){if(a=="..."&&f>0&&f+3==i.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==i.length)break;let d=i[f++];if(f==i.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+i);a=i.slice(f)}let l=o.length-1,u=o[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new Ld(r,s,l>0?o.slice(0,l):null);t[u]=c.sort(t[u])}}return R9.add(t)}const R9=new Te({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new Ld(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class Ld{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}Ld.empty=new Ld([],2,null);function D9(e,t){let n=Object.create(null);for(let o of e)if(!Array.isArray(o.tag))n[o.tag.id]=o.class;else for(let s of o.tag)n[s.id]=o.class;let{scope:r,all:i=null}=t||{};return{style:o=>{let s=i;for(let a of o)for(let l of a.set){let u=n[l.id];if(u){s=s?s+" "+u:u;break}}return s},scope:r}}function yNe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function vNe(e,t,n,r=0,i=e.length){let o=new bNe(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}class bNe{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,o){let{type:s,from:a,to:l}=t;if(a>=r||l<=n)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let u=i,c=xNe(t)||Ld.empty,f=yNe(o,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,a),u),c.opaque)return;let h=t.tree&&t.tree.prop(Te.mounted);if(h&&h.overlay){let d=t.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(v=>!v.scope||v.scope(h.tree.type)),m=t.firstChild();for(let v=0,b=a;;v++){let y=v<h.overlay.length?h.overlay[v]:null,x=y?y.from+a:l,k=Math.max(n,b),w=Math.min(r,x);if(k<w&&m)for(;t.from<w&&(this.highlightRange(t,k,w,i,o),this.startSpan(Math.min(w,t.to),u),!(t.to>=x||!t.nextSibling())););if(!y||x>r)break;b=y.to+a,b>n&&(this.highlightRange(d.cursor(),Math.max(n,y.from+a),Math.min(r,b),"",p),this.startSpan(Math.min(r,b),u))}m&&t.parent()}else if(t.firstChild()){h&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,o),this.startSpan(Math.min(r,t.to),u)}while(t.nextSibling());t.parent()}}}function xNe(e){let t=e.type.prop(R9);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const re=lo.define,km=re(),Xo=re(),LR=re(Xo),$R=re(Xo),Yo=re(),Om=re(Yo),w1=re(Yo),Ai=re(),oa=re(Ai),Oi=re(),Ci=re(),CO=re(),Pf=re(CO),Cm=re(),W={comment:km,lineComment:re(km),blockComment:re(km),docComment:re(km),name:Xo,variableName:re(Xo),typeName:LR,tagName:re(LR),propertyName:$R,attributeName:re($R),className:re(Xo),labelName:re(Xo),namespace:re(Xo),macroName:re(Xo),literal:Yo,string:Om,docString:re(Om),character:re(Om),attributeValue:re(Om),number:w1,integer:re(w1),float:re(w1),bool:re(Yo),regexp:re(Yo),escape:re(Yo),color:re(Yo),url:re(Yo),keyword:Oi,self:re(Oi),null:re(Oi),atom:re(Oi),unit:re(Oi),modifier:re(Oi),operatorKeyword:re(Oi),controlKeyword:re(Oi),definitionKeyword:re(Oi),moduleKeyword:re(Oi),operator:Ci,derefOperator:re(Ci),arithmeticOperator:re(Ci),logicOperator:re(Ci),bitwiseOperator:re(Ci),compareOperator:re(Ci),updateOperator:re(Ci),definitionOperator:re(Ci),typeOperator:re(Ci),controlOperator:re(Ci),punctuation:CO,separator:re(CO),bracket:Pf,angleBracket:re(Pf),squareBracket:re(Pf),paren:re(Pf),brace:re(Pf),content:Ai,heading:oa,heading1:re(oa),heading2:re(oa),heading3:re(oa),heading4:re(oa),heading5:re(oa),heading6:re(oa),contentSeparator:re(Ai),list:re(Ai),quote:re(Ai),emphasis:re(Ai),strong:re(Ai),link:re(Ai),monospace:re(Ai),strikethrough:re(Ai),inserted:re(),deleted:re(),changed:re(),invalid:re(),meta:Cm,documentMeta:re(Cm),annotation:re(Cm),processingInstruction:re(Cm),definition:lo.defineModifier("definition"),constant:lo.defineModifier("constant"),function:lo.defineModifier("function"),standard:lo.defineModifier("standard"),local:lo.defineModifier("local"),special:lo.defineModifier("special")};for(let e in W){let t=W[e];t instanceof lo&&(t.name=e)}D9([{tag:W.link,class:"tok-link"},{tag:W.heading,class:"tok-heading"},{tag:W.emphasis,class:"tok-emphasis"},{tag:W.strong,class:"tok-strong"},{tag:W.keyword,class:"tok-keyword"},{tag:W.atom,class:"tok-atom"},{tag:W.bool,class:"tok-bool"},{tag:W.url,class:"tok-url"},{tag:W.labelName,class:"tok-labelName"},{tag:W.inserted,class:"tok-inserted"},{tag:W.deleted,class:"tok-deleted"},{tag:W.literal,class:"tok-literal"},{tag:W.string,class:"tok-string"},{tag:W.number,class:"tok-number"},{tag:[W.regexp,W.escape,W.special(W.string)],class:"tok-string2"},{tag:W.variableName,class:"tok-variableName"},{tag:W.local(W.variableName),class:"tok-variableName tok-local"},{tag:W.definition(W.variableName),class:"tok-variableName tok-definition"},{tag:W.special(W.variableName),class:"tok-variableName2"},{tag:W.definition(W.propertyName),class:"tok-propertyName tok-definition"},{tag:W.typeName,class:"tok-typeName"},{tag:W.namespace,class:"tok-namespace"},{tag:W.className,class:"tok-className"},{tag:W.macroName,class:"tok-macroName"},{tag:W.propertyName,class:"tok-propertyName"},{tag:W.operator,class:"tok-operator"},{tag:W.comment,class:"tok-comment"},{tag:W.meta,class:"tok-meta"},{tag:W.invalid,class:"tok-invalid"},{tag:W.punctuation,class:"tok-punctuation"}]);var S1;const uu=new Te;function wNe(e){return se.define({combine:e?t=>t.concat(e):void 0})}const SNe=new Te;class hi{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Ne.prototype.hasOwnProperty("tree")||Object.defineProperty(Ne.prototype,"tree",{get(){return xn(this)}}),this.parser=n,this.extension=[Ds.of(this),Ne.languageData.of((o,s,a)=>{let l=BR(o,s,a),u=l.type.prop(uu);if(!u)return[];let c=o.facet(u),f=l.type.prop(SNe);if(f){let h=l.resolve(s-l.from,a);for(let d of f)if(d.test(h,o)){let p=o.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(t,n,r=-1){return BR(t,n,r).type.prop(uu)==this.data}findRegions(t){let n=t.facet(Ds);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(o,s)=>{if(o.prop(uu)==this.data){r.push({from:s,to:s+o.length});return}let a=o.prop(Te.mounted);if(a){if(a.tree.prop(uu)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+s,to:l.to+s});else r.push({from:s,to:s+o.length});return}else if(a.overlay){let l=r.length;if(i(a.tree,a.overlay[0].from+s),r.length>l)return}}for(let l=0;l<o.children.length;l++){let u=o.children[l];u instanceof jt&&i(u,o.positions[l]+s)}};return i(xn(t),0),r}get allowsNesting(){return!0}}hi.setState=ke.define();function BR(e,t,n){let r=e.facet(Ds),i=xn(e).topNode;if(!r||r.allowsNesting)for(let o=i;o;o=o.enter(t,n,At.ExcludeBuffers|At.EnterBracketed))o.type.isTop&&(i=o);return i}class pv extends hi{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=wNe(t.languageData);return new pv(n,t.parser.configure({props:[uu.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new pv(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function xn(e){let t=e.field(hi.state,!1);return t?t.tree:jt.empty}class kNe{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t<r||n>=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let Ef=null;class mv{constructor(t,n,r=[],i,o,s,a,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new mv(t,n,[],jt.empty,0,r,[],null)}startParse(){return this.parser.startParse(new kNe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=jt.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(za.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(za.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Ef;Ef=this;try{return t()}finally{Ef=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=FR(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((u,c,f,h)=>l.push({fromA:u,toA:c,fromB:f,toB:h})),r=za.applyChanges(r,l),i=jt.empty,o=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){a=[];for(let u of this.skipped){let c=t.mapPos(u.from,1),f=t.mapPos(u.to,-1);c<f&&a.push({from:c,to:f})}}}return new mv(this.parser,n,r,i,o,s,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:o}=this.skipped[r];i<t.to&&o>t.from&&(this.fragments=FR(this.fragments,i,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends I9{createParse(n,r,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let l=Ef;if(l){for(let u of i)l.tempSkipped.push(u);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=s,new jt(nr.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return Ef}}function FR(e,t,n){return za.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class xc{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new xc(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=mv.create(t.facet(Ds).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new xc(r)}}hi.state=kn.define({create:xc.init,update(e,t){for(let n of t.effects)if(n.is(hi.setState))return n.value;return t.startState.facet(Ds)!=t.state.facet(Ds)?xc.init(t.state):e.apply(t)}});let L9=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(L9=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const k1=typeof navigator<"u"&&(!((S1=navigator.scheduling)===null||S1===void 0)&&S1.isInputPending)?()=>navigator.scheduling.isInputPending():null,ONe=Et.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(hi.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(hi.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=L9(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,o=r.field(hi.state);if(o.tree==o.context.tree&&o.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!k1?Math.max(25,t.timeRemaining()-5):1e9),a=o.context.treeLen<i&&r.doc.length>i+1e3,l=o.context.work(()=>k1&&k1()||Date.now()>s,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:hi.setState.of(new xc(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Gn(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ds=se.define({combine(e){return e.length?e[0]:null},enables:e=>[hi.state,ONe,ie.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class CNe{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}const ANe=se.define(),db=se.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function gv(e){let t=e.facet(db);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function $d(e,t){let n="",r=e.tabSize,i=e.facet(db)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let o=0;o<t;o++)n+=i;return n}function YP(e,t){e instanceof Ne&&(e=new pb(e));for(let r of e.state.facet(ANe)){let i=r(e,t);if(i!==void 0)return i}let n=xn(e.state);return n.length>=t?PNe(e,n,t):null}class pb{constructor(t,n={}){this.state=t,this.options=n,this.unit=gv(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:o}=this.options;return i!=null&&i>=r.from&&i<=r.to?o&&i==t?{text:"",from:t}:(n<0?i<t:i<=t)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(t,n=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(t,n);return r.slice(t-i,Math.min(r.length,t+100-i))}column(t,n=1){let{text:r,from:i}=this.lineAt(t,n),o=this.countColumn(r,t-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(o+=s-this.countColumn(r,r.search(/\S|$/))),o}countColumn(t,n=t.length){return qc(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),o=this.options.overrideIndentation;if(o){let s=o(i);if(s>-1)return s}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const $9=new Te;function PNe(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let o=[];for(let s=i;s&&!(s.from<r.node.from||s.to>r.node.to||s.from==r.node.from&&s.type==r.node.type);s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)r={node:o[s],next:r}}return B9(r,e,n)}function B9(e,t,n){for(let r=e;r;r=r.next){let i=TNe(r.node);if(i)return i(ZP.create(t,n,r))}return 0}function ENe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function TNe(e){let t=e.type.prop($9);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Te.closedBy))){let i=e.lastChild,o=i&&r.indexOf(i.name)>-1;return s=>F9(s,!0,1,void 0,o&&!ENe(s)?i.from:void 0)}return e.parent==null?_Ne:null}function _Ne(){return 0}class ZP extends pb{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new ZP(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(jNe(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return B9(this.context.next,this.base,this.pos)}}function jNe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function MNe(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=i==null||i<=o.from?o.to:Math.min(o.to,i);for(let a=n.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let u=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+u}}a=l.to}}function zR({closing:e,align:t=!0,units:n=1}){return r=>F9(r,t,n,e)}function F9(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?MNe(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}const INe=200;function NNe(){return Ne.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+INe)return e;let o=n.sliceString(i.from,r);if(!t.some(u=>u.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:u}of s.selection.ranges){let c=s.doc.lineAt(u);if(c.from==a)continue;a=c.from;let f=YP(s,c.from);if(f==null)continue;let h=/^\s*/.exec(c.text)[0],d=$d(s,f);h!=d&&l.push({from:c.from,to:c.from+h.length,insert:d})}return l.length?[e,{changes:l,sequential:!0}]:e})}const RNe=se.define(),z9=new Te;function DNe(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function LNe(e,t,n){let r=xn(e);if(r.length<n)return null;let i=r.resolveStack(n,1),o=null;for(let s=i;s;s=s.next){let a=s.node;if(a.to<=n||a.from>n)continue;if(o&&a.from<t)break;let l=a.type.prop(z9);if(l&&(a.to<r.length-50||r.length==e.doc.length||!$Ne(a))){let u=l(a,e);u&&u.from<=n&&u.from>=t&&u.to>n&&(o=u)}}return o}function $Ne(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function yv(e,t,n){for(let r of e.facet(RNe)){let i=r(e,t,n);if(i)return i}return LNe(e,t,n)}function W9(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const mb=ke.define({map:W9}),hp=ke.define({map:W9});function U9(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const ol=kn.define({create(){return de.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((n,r)=>e=WR(e,n,r)),e=e.map(t.changes);for(let n of t.effects)if(n.is(mb)&&!BNe(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(q9),i=r?de.replace({widget:new qNe(r(t.state,n.value))}):UR;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(hp)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=WR(e,t.selection.main.head)),e},provide:e=>ie.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(UR.range(r,i))}return de.set(t,!0)}});function WR(e,t,n=t){let r=!1;return e.between(t,n,(i,o)=>{i<n&&o>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(i,o)=>i>=n||o<=t}):e}function vv(e,t,n){var r;let i=null;return(r=e.field(ol,!1))===null||r===void 0||r.between(t,n,(o,s)=>{(!i||i.from>o)&&(i={from:o,to:s})}),i}function BNe(e,t,n){let r=!1;return e.between(t,t,(i,o)=>{i==t&&o==n&&(r=!0)}),r}function H9(e,t){return e.field(ol,!1)?t:t.concat(ke.appendConfig.of(K9()))}const FNe=e=>{for(let t of U9(e)){let n=yv(e.state,t.from,t.to);if(n)return e.dispatch({effects:H9(e.state,[mb.of(n),V9(e,n)])}),!0}return!1},zNe=e=>{if(!e.state.field(ol,!1))return!1;let t=[];for(let n of U9(e)){let r=vv(e.state,n.from,n.to);r&&t.push(hp.of(r),V9(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function V9(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return ie.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const WNe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=yv(t,i.from,i.to);o&&n.push(mb.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:H9(e.state,n)}),!!n.length},UNe=e=>{let t=e.state.field(ol,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(hp.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},HNe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:FNe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:zNe},{key:"Ctrl-Alt-[",run:WNe},{key:"Ctrl-Alt-]",run:UNe}],VNe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},q9=se.define({combine(e){return Ji(e,VNe)}});function K9(e){return[ol,QNe]}function G9(e,t){let{state:n}=e,r=n.facet(q9),i=s=>{let a=e.lineBlockAt(e.posAtDOM(s.target)),l=vv(e.state,a.from,a.to);l&&e.dispatch({effects:hp.of(l)}),s.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const UR=de.replace({widget:new class extends eo{toDOM(e){return G9(e,null)}}});class qNe extends eo{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return G9(t,this.value)}}const KNe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class O1 extends Ro{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function GNe(e={}){let t={...KNe,...e},n=new O1(t,!0),r=new O1(t,!1),i=Et.fromClass(class{constructor(s){this.from=s.viewport.from,this.markers=this.buildMarkers(s)}update(s){(s.docChanged||s.viewportChanged||s.startState.facet(Ds)!=s.state.facet(Ds)||s.startState.field(ol,!1)!=s.state.field(ol,!1)||xn(s.startState)!=xn(s.state)||t.foldingChanged(s))&&(this.markers=this.buildMarkers(s.view))}buildMarkers(s){let a=new Io;for(let l of s.viewportLineBlocks){let u=vv(s.state,l.from,l.to)?r:yv(s.state,l.from,l.to)?n:null;u&&a.add(l.from,l.from,u)}return a.finish()}}),{domEventHandlers:o}=t;return[i,QIe({class:"cm-foldGutter",markers(s){var a;return((a=s.plugin(i))===null||a===void 0?void 0:a.markers)||_e.empty},initialSpacer(){return new O1(t,!1)},domEventHandlers:{...o,click:(s,a,l)=>{if(o.click&&o.click(s,a,l))return!0;let u=vv(s.state,a.from,a.to);if(u)return s.dispatch({effects:hp.of(u)}),!0;let c=yv(s.state,a.from,a.to);return c?(s.dispatch({effects:mb.of(c)}),!0):!1}}}),K9()]}const QNe=ie.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class dp{constructor(t,n){this.specs=t;let r;function i(a){let l=Ms.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const o=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,s=n.scope;this.scope=s instanceof hi?a=>a.prop(uu)==s.data:s?a=>a==s:void 0,this.style=D9(t.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=r?new Ms(r):null,this.themeType=n.themeType}static define(t,n){return new dp(t,n||{})}}const AO=se.define(),Q9=se.define({combine(e){return e.length?[e[0]]:null}});function C1(e){let t=e.facet(AO);return t.length?t:e.facet(Q9)}function X9(e,t){let n=[YNe],r;return e instanceof dp&&(e.module&&n.push(ie.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Q9.of(e)):r?n.push(AO.computeN([ie.darkTheme],i=>i.facet(ie.darkTheme)==(r=="dark")?[e]:[])):n.push(AO.of(e)),n}class XNe{constructor(t){this.markCache=Object.create(null),this.tree=xn(t.state),this.decorations=this.buildDeco(t,C1(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=xn(t.state),r=C1(t.state),i=r!=C1(t.startState),{viewport:o}=t.view,s=t.changes.mapPos(this.decoratedTo,1);n.length<o.to&&!i&&n.type==this.tree.type&&s>=o.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=o.to)}buildDeco(t,n){if(!n||!this.tree.length)return de.none;let r=new Io;for(let{from:i,to:o}of t.visibleRanges)vNe(this.tree,n,(s,a,l)=>{r.add(s,a,this.markCache[l]||(this.markCache[l]=de.mark({class:l})))},i,o);return r.finish()}}const YNe=bl.high(Et.fromClass(XNe,{decorations:e=>e.decorations})),ZNe=dp.define([{tag:W.meta,color:"#404740"},{tag:W.link,textDecoration:"underline"},{tag:W.heading,textDecoration:"underline",fontWeight:"bold"},{tag:W.emphasis,fontStyle:"italic"},{tag:W.strong,fontWeight:"bold"},{tag:W.strikethrough,textDecoration:"line-through"},{tag:W.keyword,color:"#708"},{tag:[W.atom,W.bool,W.url,W.contentSeparator,W.labelName],color:"#219"},{tag:[W.literal,W.inserted],color:"#164"},{tag:[W.string,W.deleted],color:"#a11"},{tag:[W.regexp,W.escape,W.special(W.string)],color:"#e40"},{tag:W.definition(W.variableName),color:"#00f"},{tag:W.local(W.variableName),color:"#30a"},{tag:[W.typeName,W.namespace],color:"#085"},{tag:W.className,color:"#167"},{tag:[W.special(W.variableName),W.macroName],color:"#256"},{tag:W.definition(W.propertyName),color:"#00c"},{tag:W.comment,color:"#940"},{tag:W.invalid,color:"#f00"}]),JNe=ie.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Y9=1e4,Z9="()[]{}",J9=se.define({combine(e){return Ji(e,{afterCursor:!0,brackets:Z9,maxScanDistance:Y9,renderMatch:nRe})}}),eRe=de.mark({class:"cm-matchingBracket"}),tRe=de.mark({class:"cm-nonmatchingBracket"});function nRe(e){let t=[],n=e.matched?eRe:tRe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function HR(e){let t=[],n=e.facet(J9);for(let r of e.selection.ranges){if(!r.empty)continue;let i=$i(e,r.head,-1,n)||r.head>0&&$i(e,r.head-1,1,n)||n.afterCursor&&($i(e,r.head,1,n)||r.head<e.doc.length&&$i(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return de.set(t,!0)}const rRe=Et.fromClass(class{constructor(e){this.paused=!1,this.decorations=HR(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=HR(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),iRe=[rRe,JNe];function oRe(e={}){return[J9.of(e),iRe]}const sRe=new Te;function PO(e,t,n){let r=e.prop(t<0?Te.openedBy:Te.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function EO(e){let t=e.type.prop(sRe);return t?t(e.node):e}function $i(e,t,n,r={}){let i=r.maxScanDistance||Y9,o=r.brackets||Z9,s=xn(e),a=s.resolveInner(t,n);for(let l=a;l;l=l.parent){let u=PO(l.type,n,o);if(u&&l.from<l.to){let c=EO(l);if(c&&(n>0?t>=c.from&&t<c.to:t>c.from&&t<=c.to))return aRe(e,t,n,l,c,u,o)}}return lRe(e,t,n,s,a.type,i,o)}function aRe(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},u=0,c=a?.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&o.indexOf(c.type.name)>-1&&c.from<c.to){let f=EO(c);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(PO(c.type,n,s))u++;else if(PO(c.type,-n,s)){if(u==0){let f=EO(c);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}u--}}while(n<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}function lRe(e,t,n,r,i,o,s){if(n<0?!t:t==e.doc.length)return null;let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let u={from:n<0?t-1:t,to:n>0?t+1:t},c=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let h=0;!c.next().done&&h<=o;){let d=c.value;n<0&&(h+=d.length);let p=t+h*n;for(let m=n>0?0:d.length-1,v=n>0?d.length:-1;m!=v;m+=n){let b=s.indexOf(d[m]);if(!(b<0||r.resolveInner(p+m,1).type!=i))if(b%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:b>>1==l>>1};f--}}n>0&&(h+=d.length)}return c.done?{start:u,matched:!1}:null}const uRe=Object.create(null),VR=[nr.none],qR=[],KR=Object.create(null),cRe=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])cRe[e]=fRe(uRe,t);function A1(e,t){qR.indexOf(e)>-1||(qR.push(e),console.warn(t))}function fRe(e,t){let n=[];for(let a of t.split(" ")){let l=[];for(let u of a.split(".")){let c=e[u]||W[u];c?typeof c=="function"?l.length?l=l.map(c):A1(u,`Modifier ${u} used at start of tag`):l.length?A1(u,`Tag ${u} used as modifier`):l=Array.isArray(c)?c:[c]:A1(u,`Unknown highlighting tag ${u}`)}for(let u of l)n.push(u)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(a=>a.id),o=KR[i];if(o)return o.id;let s=KR[i]=nr.define({id:VR.length,name:r,props:[N9({[r]:n})]});return VR.push(s),s.id}Je.RTL,Je.LTR;const hRe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=eE(e.state,n.from);return r.line?dRe(e):r.block?mRe(e):!1};function JP(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}const dRe=JP(vRe,0),pRe=JP(eW,0),mRe=JP((e,t)=>eW(e,t,yRe(t)),0);function eE(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const Tf=50;function gRe(e,{open:t,close:n},r,i){let o=e.sliceDoc(r-Tf,r),s=e.sliceDoc(i,i+Tf),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,u=o.length-a;if(o.slice(u-t.length,u)==t&&s.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let c,f;i-r<=2*Tf?c=f=e.sliceDoc(r,i):(c=e.sliceDoc(r,r+Tf),f=e.sliceDoc(i-Tf,i));let h=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-n.length;return c.slice(h,h+t.length)==t&&f.slice(p,p+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(c.charAt(h+t.length))?1:0},close:{pos:i-d-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function yRe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function eW(e,t,n=t.selection.ranges){let r=n.map(o=>eE(t,o.from).block);if(!r.every(o=>o))return null;let i=n.map((o,s)=>gRe(t,r[s],o.from,o.to));if(e!=2&&!i.every(o=>o))return{changes:t.changes(n.map((o,s)=>i[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(e!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let l=r[s],{open:u,close:c}=a;o.push({from:u.pos-l.open.length,to:u.pos+u.margin},{from:c.pos-c.margin,to:c.pos+l.close.length})}return{changes:o}}return null}function vRe(e,t,n=t.selection.ranges){let r=[],i=-1;e:for(let{from:o,to:s}of n){let a=r.length,l=1e9,u;for(let c=o;c<=s;){let f=t.doc.lineAt(c);if(u==null&&(u=eE(t,f.from).line,!u))continue e;if(f.from>i&&(o==s||s>f.from)){i=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+u.length)==u?h:-1;h<f.text.length&&h<l&&(l=h),r.push({line:f,comment:p,token:u,indent:h,empty:d,single:!1})}c=f.to+1}if(l<1e9)for(let c=a;c<r.length;c++)r[c].indent<r[c].line.text.length&&(r[c].indent=l);r.length==a+1&&(r[a].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:u,empty:c,single:f}of r)(f||!c)&&o.push({from:a.from+u,insert:l+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of r)if(a>=0){let u=s.from+a,c=u+l.length;s.text[c-s.from]==" "&&c++,o.push({from:u,to:c})}return{changes:o}}return null}const TO=Zi.define(),bRe=Zi.define(),xRe=se.define(),tW=se.define({combine(e){return Ji(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,i)=>t(r,i)||n(r,i)})}}),nW=kn.define({create(){return Bi.empty},update(e,t){let n=t.state.facet(tW),r=t.annotation(TO);if(r){let l=Qn.fromTransaction(t,r.selection),u=r.side,c=u==0?e.undone:e.done;return l?c=bv(c,c.length,n.minDepth,l):c=oW(c,t.startState.selection),new Bi(u==0?r.rest:c,u==0?c:r.rest)}let i=t.annotation(bRe);if((i=="full"||i=="before")&&(e=e.isolate()),t.annotation(Kt.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Qn.fromTransaction(t),s=t.annotation(Kt.time),a=t.annotation(Kt.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),(i=="full"||i=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new Bi(e.done.map(Qn.fromJSON),e.undone.map(Qn.fromJSON))}});function wRe(e={}){return[nW,tW.of(e),ie.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?rW:t.inputType=="historyRedo"?_O:null;return r?(t.preventDefault(),r(n)):!1}})]}function gb(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(nW,!1);if(!i)return!1;let o=i.pop(e,n,t);return o?(r(o),!0):!1}}const rW=gb(0,!1),_O=gb(1,!1),SRe=gb(0,!0),kRe=gb(1,!0);class Qn{constructor(t,n,r,i,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=o}setSelAfter(t){return new Qn(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(t){return new Qn(t.changes&&zt.fromJSON(t.changes),[],t.mapped&&Ki.fromJSON(t.mapped),t.startSelection&&V.fromJSON(t.startSelection),t.selectionsAfter.map(V.fromJSON))}static fromTransaction(t,n){let r=Wr;for(let i of t.startState.facet(xRe)){let o=i(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new Qn(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Wr)}static selection(t){return new Qn(void 0,Wr,void 0,void 0,t)}}function bv(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function ORe(e,t){let n=[],r=!1;return e.iterChangedRanges((i,o)=>n.push(i,o)),t.iterChangedRanges((i,o,s,a)=>{for(let l=0;l<n.length;){let u=n[l++],c=n[l++];a>=u&&s<=c&&(r=!0)}}),r}function CRe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function iW(e,t){return e.length?t.length?e.concat(t):e:t}const Wr=[],ARe=200;function oW(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ARe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),bv(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Qn.selection([t])]}function PRe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function P1(e,t){if(!e.length)return e;let n=e.length,r=Wr;for(;n;){let i=ERe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let o=e.slice(0,n);return o[n-1]=i,o}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[Qn.selection(r)]:Wr}function ERe(e,t,n){let r=iW(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):Wr,n);if(!e.changes)return Qn.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new Qn(i,ke.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const TRe=/^(input\.type|delete)($|\.)/;class Bi{constructor(t,n,r=0,i=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new Bi(this.done,this.undone):this}addChanges(t,n,r,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!r||TRe.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,ORe(a.changes,t.changes))||r=="input.type.compose")?s=bv(s,s.length-1,i.minDepth,new Qn(t.changes.compose(a.changes),iW(ke.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,Wr)):s=bv(s,s.length,i.minDepth,t),new Bi(s,Wr,n,r)}addSelection(t,n,r,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:Wr;return o.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&CRe(o[o.length-1],t)?this:new Bi(oW(this.done,t),this.undone,n,r)}addMapping(t){return new Bi(P1(this.done,t),P1(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let i=t==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):n.selection);if(r&&o.selectionsAfter.length)return n.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:TO.of({side:t,rest:PRe(i),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?Wr:i.slice(0,i.length-1);return o.mapped&&(a=P1(a,o.mapped)),n.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:TO.of({side:t,rest:a,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}Bi.empty=new Bi(Wr,Wr);const _Re=[{key:"Mod-z",run:rW,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:_O,preventDefault:!0},{linux:"Ctrl-Shift-z",run:_O,preventDefault:!0},{key:"Mod-u",run:SRe,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:kRe,preventDefault:!0}];function Kc(e,t){return V.create(e.ranges.map(t),e.mainIndex)}function xi(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function wi({state:e,dispatch:t},n){let r=Kc(e.selection,n);return r.eq(e.selection,!0)?!1:(t(xi(e,r)),!0)}function yb(e,t){return V.cursor(t?e.to:e.from)}function sW(e,t){return wi(e,n=>n.empty?e.moveByChar(n,t):yb(n,t))}function On(e){return e.textDirectionAt(e.state.selection.main.head)==Je.LTR}const aW=e=>sW(e,!On(e)),lW=e=>sW(e,On(e));function uW(e,t){return wi(e,n=>n.empty?e.moveByGroup(n,t):yb(n,t))}const jRe=e=>uW(e,!On(e)),MRe=e=>uW(e,On(e));function IRe(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function vb(e,t,n){let r=xn(e).resolveInner(t.head),i=n?Te.closedBy:Te.openedBy;for(let l=t.head;;){let u=n?r.childAfter(l):r.childBefore(l);if(!u)break;IRe(e,u,i)?r=u:l=n?u.to:u.from}let o=r.type.prop(i),s,a;return o&&(s=n?$i(e,r.from,1):$i(e,r.to,-1))&&s.matched?a=n?s.end.to:s.end.from:a=n?r.to:r.from,V.cursor(a,n?-1:1)}const NRe=e=>wi(e,t=>vb(e.state,t,!On(e))),RRe=e=>wi(e,t=>vb(e.state,t,On(e)));function cW(e,t){return wi(e,n=>{if(!n.empty)return yb(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const fW=e=>cW(e,!1),hW=e=>cW(e,!0);function dW(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let o of e.state.facet(ie.scrollMargins)){let s=o(e);s?.top&&(n=Math.max(s?.top,n)),s?.bottom&&(r=Math.max(s?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function pW(e,t){let n=dW(e),{state:r}=e,i=Kc(r.selection,s=>s.empty?e.moveVertically(s,t,n.height):yb(s,t));if(i.eq(r.selection))return!1;let o;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,u=a.bottom-n.marginBottom;s&&s.top>l&&s.bottom<u&&(o=ie.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-l}))}return e.dispatch(xi(r,i),{effects:o}),!0}const GR=e=>pW(e,!1),jO=e=>pW(e,!0);function Gs(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(i=V.cursor(r.from+o))}return i}const DRe=e=>wi(e,t=>Gs(e,t,!0)),LRe=e=>wi(e,t=>Gs(e,t,!1)),$Re=e=>wi(e,t=>Gs(e,t,!On(e))),BRe=e=>wi(e,t=>Gs(e,t,On(e))),FRe=e=>wi(e,t=>V.cursor(e.lineBlockAt(t.head).from,1)),zRe=e=>wi(e,t=>V.cursor(e.lineBlockAt(t.head).to,-1));function WRe(e,t,n){let r=!1,i=Kc(e.selection,o=>{let s=$i(e,o.head,-1)||$i(e,o.head,1)||o.head>0&&$i(e,o.head-1,1)||o.head<e.doc.length&&$i(e,o.head+1,-1);if(!s||!s.end)return o;r=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return V.cursor(a)});return r?(t(xi(e,i)),!0):!1}const URe=({state:e,dispatch:t})=>WRe(e,t);function Zr(e,t){let n=Kc(e.state.selection,r=>{let i=t(r);return V.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(xi(e.state,n)),!0)}function mW(e,t){return Zr(e,n=>e.moveByChar(n,t))}const gW=e=>mW(e,!On(e)),yW=e=>mW(e,On(e));function vW(e,t){return Zr(e,n=>e.moveByGroup(n,t))}const HRe=e=>vW(e,!On(e)),VRe=e=>vW(e,On(e)),qRe=e=>Zr(e,t=>vb(e.state,t,!On(e))),KRe=e=>Zr(e,t=>vb(e.state,t,On(e)));function bW(e,t){return Zr(e,n=>e.moveVertically(n,t))}const xW=e=>bW(e,!1),wW=e=>bW(e,!0);function SW(e,t){return Zr(e,n=>e.moveVertically(n,t,dW(e).height))}const QR=e=>SW(e,!1),XR=e=>SW(e,!0),GRe=e=>Zr(e,t=>Gs(e,t,!0)),QRe=e=>Zr(e,t=>Gs(e,t,!1)),XRe=e=>Zr(e,t=>Gs(e,t,!On(e))),YRe=e=>Zr(e,t=>Gs(e,t,On(e))),ZRe=e=>Zr(e,t=>V.cursor(e.lineBlockAt(t.head).from)),JRe=e=>Zr(e,t=>V.cursor(e.lineBlockAt(t.head).to)),YR=({state:e,dispatch:t})=>(t(xi(e,{anchor:0})),!0),ZR=({state:e,dispatch:t})=>(t(xi(e,{anchor:e.doc.length})),!0),JR=({state:e,dispatch:t})=>(t(xi(e,{anchor:e.selection.main.anchor,head:0})),!0),eD=({state:e,dispatch:t})=>(t(xi(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),eDe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),tDe=({state:e,dispatch:t})=>{let n=bb(e).map(({from:r,to:i})=>V.range(r,Math.min(i+1,e.doc.length)));return t(e.update({selection:V.create(n),userEvent:"select"})),!0},nDe=({state:e,dispatch:t})=>{let n=Kc(e.selection,r=>{let i=xn(e),o=i.resolveStack(r.from,1);if(r.empty){let s=i.resolveStack(r.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&s.next)return V.range(a.to,a.from)}return r});return n.eq(e.selection)?!1:(t(xi(e,n)),!0)};function kW(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let o of n.selection.ranges){let s=n.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let a=o;;){let l=e.moveVertically(a,t);if(l.head<s.from||l.head>s.to){i.some(u=>u.head==l.head)||i.push(l);break}else{if(l.head==a.head)break;a=l}}}return i.length==r.ranges.length?!1:(e.dispatch(xi(n,V.create(i,i.length-1))),!0)}const rDe=e=>kW(e,!1),iDe=e=>kW(e,!0),oDe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=V.create([n.main]):n.main.empty||(r=V.create([V.cursor(n.main.head)])),r?(t(xi(e,r)),!0):!1};function pp(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=t(o);l<s?(n="delete.backward",l=Am(e,l,!1)):l>s&&(n="delete.forward",l=Am(e,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Am(e,s,!1),a=Am(e,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:V.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?ie.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function Am(e,t,n){if(e instanceof ie)for(let r of e.state.facet(ie.atomicRanges).map(i=>i(e)))r.between(t,t,(i,o)=>{i<t&&o>t&&(t=n?o:i)});return t}const OW=(e,t,n)=>pp(e,r=>{let i=r.from,{state:o}=e,s=o.doc.lineAt(i),a,l;if(n&&!t&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,i-s.from))){if(a[a.length-1]==" ")return i-1;let u=qc(a,o.tabSize),c=u%gv(o)||gv(o);for(let f=0;f<c&&a[a.length-1-f]==" ";f++)i--;l=i}else l=Jt(s.text,i-s.from,t,t)+s.from,l==i&&s.number!=(t?o.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=Jt(s.text,l-s.from,!1,!1)+s.from);return l}),MO=e=>OW(e,!1,!0),CW=e=>OW(e,!0,!1),AW=(e,t)=>pp(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let a=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let l=Jt(o.text,r-o.from,t)+o.from,u=o.text.slice(Math.min(r,l)-o.from,Math.max(r,l)-o.from),c=s(u);if(a!=null&&c!=a)break;(u!=" "||r!=n.head)&&(a=c),r=l}return r}),PW=e=>AW(e,!1),sDe=e=>AW(e,!0),aDe=e=>pp(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),lDe=e=>pp(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),uDe=e=>pp(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),cDe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Re.of(["",""])},range:V.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},fDe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let i=r.from,o=e.doc.lineAt(i),s=i==o.from?i-1:Jt(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:Jt(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:e.doc.slice(i,a).append(e.doc.slice(s,i))},range:V.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function bb(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=i.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function EW(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let o of bb(e)){if(n?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(n?o.to+1:o.from-1),a=s.length+1;if(n){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let l of o.ranges)i.push(V.range(Math.min(e.doc.length,l.anchor+a),Math.min(e.doc.length,l.head+a)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let l of o.ranges)i.push(V.range(l.anchor-a,l.head-a))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:V.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const hDe=({state:e,dispatch:t})=>EW(e,t,!1),dDe=({state:e,dispatch:t})=>EW(e,t,!0);function TW(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of bb(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const pDe=({state:e,dispatch:t})=>TW(e,t,!1),mDe=({state:e,dispatch:t})=>TW(e,t,!0),gDe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(bb(t).map(({from:i,to:o})=>(i>0?i--:o<t.doc.length&&o++,{from:i,to:o}))),r=Kc(t.selection,i=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(i.head),a=e.coordsAtPos(i.head,i.assoc||1);a&&(o=s.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(i,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function yDe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=xn(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),o;return r&&i&&r.to<=t&&i.from>=t&&(o=r.type.prop(Te.closedBy))&&o.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const tD=_W(!1),vDe=_W(!0);function _W(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(i=>{let{from:o,to:s}=i,a=t.doc.lineAt(o),l=!e&&o==s&&yDe(t,o);e&&(o=s=(s<=a.to?a:t.doc.lineAt(s)).to);let u=new pb(t,{simulateBreak:o,simulateDoubleBreak:!!l}),c=YP(u,o);for(c==null&&(c=qc(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:o,to:s}=l:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",$d(t,c)];return l&&f.push($d(t,u.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:Re.of(f)},range:V.cursor(o+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function tE(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let s=r.from;s<=r.to;){let a=e.doc.lineAt(s);a.number>n&&(r.empty||r.to>a.from)&&(t(a,i,r),n=a.number),s=a.to+1}let o=e.changes(i);return{changes:i,range:V.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const bDe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new pb(e,{overrideIndentation:o=>{let s=n[o];return s??-1}}),i=tE(e,(o,s,a)=>{let l=YP(r,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let u=/^\s*/.exec(o.text)[0],c=$d(e,l);(u!=c||a.from<o.from+u.length)&&(n[o.from]=l,s.push({from:o.from,to:o.from+u.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0},jW=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(tE(e,(n,r)=>{r.push({from:n.from,insert:e.facet(db)})}),{userEvent:"input.indent"})),!0),MW=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(tE(e,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let o=qc(i,e.tabSize),s=0,a=$d(e,Math.max(0,o-gv(e)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),xDe=e=>(e.setTabFocusMode(),!0),wDe=[{key:"Ctrl-b",run:aW,shift:gW,preventDefault:!0},{key:"Ctrl-f",run:lW,shift:yW},{key:"Ctrl-p",run:fW,shift:xW},{key:"Ctrl-n",run:hW,shift:wW},{key:"Ctrl-a",run:FRe,shift:ZRe},{key:"Ctrl-e",run:zRe,shift:JRe},{key:"Ctrl-d",run:CW},{key:"Ctrl-h",run:MO},{key:"Ctrl-k",run:aDe},{key:"Ctrl-Alt-h",run:PW},{key:"Ctrl-o",run:cDe},{key:"Ctrl-t",run:fDe},{key:"Ctrl-v",run:jO}],SDe=[{key:"ArrowLeft",run:aW,shift:gW,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:jRe,shift:HRe,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:$Re,shift:XRe,preventDefault:!0},{key:"ArrowRight",run:lW,shift:yW,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:MRe,shift:VRe,preventDefault:!0},{mac:"Cmd-ArrowRight",run:BRe,shift:YRe,preventDefault:!0},{key:"ArrowUp",run:fW,shift:xW,preventDefault:!0},{mac:"Cmd-ArrowUp",run:YR,shift:JR},{mac:"Ctrl-ArrowUp",run:GR,shift:QR},{key:"ArrowDown",run:hW,shift:wW,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ZR,shift:eD},{mac:"Ctrl-ArrowDown",run:jO,shift:XR},{key:"PageUp",run:GR,shift:QR},{key:"PageDown",run:jO,shift:XR},{key:"Home",run:LRe,shift:QRe,preventDefault:!0},{key:"Mod-Home",run:YR,shift:JR},{key:"End",run:DRe,shift:GRe,preventDefault:!0},{key:"Mod-End",run:ZR,shift:eD},{key:"Enter",run:tD,shift:tD},{key:"Mod-a",run:eDe},{key:"Backspace",run:MO,shift:MO,preventDefault:!0},{key:"Delete",run:CW,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:PW,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:sDe,preventDefault:!0},{mac:"Mod-Backspace",run:lDe,preventDefault:!0},{mac:"Mod-Delete",run:uDe,preventDefault:!0}].concat(wDe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),kDe=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:NRe,shift:qRe},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:RRe,shift:KRe},{key:"Alt-ArrowUp",run:hDe},{key:"Shift-Alt-ArrowUp",run:pDe},{key:"Alt-ArrowDown",run:dDe},{key:"Shift-Alt-ArrowDown",run:mDe},{key:"Mod-Alt-ArrowUp",run:rDe},{key:"Mod-Alt-ArrowDown",run:iDe},{key:"Escape",run:oDe},{key:"Mod-Enter",run:vDe},{key:"Alt-l",mac:"Ctrl-l",run:tDe},{key:"Mod-i",run:nDe,preventDefault:!0},{key:"Mod-[",run:MW},{key:"Mod-]",run:jW},{key:"Mod-Alt-\\",run:bDe},{key:"Shift-Mod-k",run:gDe},{key:"Shift-Mod-\\",run:URe},{key:"Mod-/",run:hRe},{key:"Alt-A",run:pRe},{key:"Ctrl-m",mac:"Shift-Alt-m",run:xDe}].concat(SDe),ODe={key:"Tab",run:jW,shift:MW},nD=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class wc{constructor(t,n,r=0,i=t.length,o,s){this.test=s,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,i),this.bufferStart=r,this.normalize=o?a=>o(nD(a)):nD,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return zn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=EP(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=Ni(t);let i=this.normalize(n);if(i.length)for(let o=0,s=r,a=!0;;o++){let l=i.charCodeAt(o),u=this.match(l,s,a,this.bufferPos+this.bufferStart,o==i.length-1);if(u)return this.value=u,this;if(o==i.length-1)break;a&&o<n.length&&n.charCodeAt(o)==l?s++:a=!1}}}match(t,n,r,i,o){let s=null;for(let a=0;a<this.matches.length;){let l=this.matches[a],u=!1;this.query.charCodeAt(l.index)==t&&(l.index==this.query.length-1?s={from:l.from,to:i,precise:o&&l.precise}:(l.index++,u=!0)),u?a++:this.matches.splice(a,1)}return this.query.charCodeAt(0)==t&&(this.query.length==1?s={from:n,to:i,precise:r&&o}:this.matches.push({from:n,index:1,precise:r})),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(wc.prototype[Symbol.iterator]=function(){return this});const IW={from:-1,to:-1,match:/.*/.exec(""),precise:!0},nE="gm"+(/x/.unicode==null?"":"u");class NW{constructor(t,n,r,i=0,o=t.length){if(this.text=t,this.to=o,this.curLine="",this.done=!1,this.value=IW,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new RW(t,n,r,i,o);this.re=new RegExp(n,nE+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=t.iter();let s=t.lineAt(i);this.curLineStart=s.from,this.matchPos=xv(t,i),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,i=r+n[0].length;if(this.matchPos=xv(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,precise:!0,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const E1=new WeakMap;class Tu{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let i=E1.get(t);if(!i||i.from>=r||i.to<=n){let a=new Tu(n,t.sliceString(n,r));return E1.set(t,a),a}if(i.from==n&&i.to==r)return i;let{text:o,from:s}=i;return s>n&&(o=t.sliceString(n,s)+o,s=n),i.to<r&&(o+=t.sliceString(i.to,r)),E1.set(t,new Tu(s,o)),new Tu(n,o.slice(n-s,r-s))}}class RW{constructor(t,n,r,i,o){this.text=t,this.to=o,this.done=!1,this.value=IW,this.matchPos=xv(t,i),this.re=new RegExp(n,nE+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=Tu.get(t,i,this.chunkEnd(i+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,i=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,precise:!0,match:n},this.matchPos=xv(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Tu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(NW.prototype[Symbol.iterator]=RW.prototype[Symbol.iterator]=function(){return this});function CDe(e){try{return new RegExp(e,nE),!0}catch{return!1}}function xv(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const ADe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=VIe(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(o=>{let s=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!s){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,l,u,c,f]=s,h=c?+c.slice(1):0,d=u?+u:a.number;if(u&&f){let v=d/100;l&&(v=v*(l=="-"?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*v)}else u&&l&&(d=d*(l=="-"?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),m=V.cursor(p.from+Math.max(0,Math.min(h,p.length)));e.dispatch({effects:[r,ie.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},PDe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},EDe=se.define({combine(e){return Ji(e,PDe,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function TDe(e){return[NDe,IDe]}const _De=de.mark({class:"cm-selectionMatch"}),jDe=de.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function rD(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=yt.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=yt.Word)}function MDe(e,t,n,r){return e(t.sliceDoc(n,n+1))==yt.Word&&e(t.sliceDoc(r-1,r))==yt.Word}const IDe=Et.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(EDe),{state:n}=e,r=n.selection;if(r.ranges.length>1)return de.none;let i=r.main,o,s=null;if(i.empty){if(!t.highlightWordAroundCursor)return de.none;let l=n.wordAt(i.head);if(!l)return de.none;s=n.charCategorizer(i.head),o=n.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<t.minSelectionLength||l>200)return de.none;if(t.wholeWords){if(o=n.sliceDoc(i.from,i.to),s=n.charCategorizer(i.head),!(rD(s,n,i.from,i.to)&&MDe(s,n,i.from,i.to)))return de.none}else if(o=n.sliceDoc(i.from,i.to),!o)return de.none}let a=[];for(let l of e.visibleRanges){let u=new wc(n.doc,o,l.from,l.to);for(;!u.next().done;){let{from:c,to:f}=u.value;if((!s||rD(s,n,c,f))&&(i.empty&&c<=i.from&&f>=i.to?a.push(jDe.range(c,f)):(c>=i.to||f<=i.from)&&a.push(_De.range(c,f)),a.length>t.maxMatches))return de.none}}return de.set(a)}},{decorations:e=>e.decorations}),NDe=ie.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),RDe=({state:e,dispatch:t})=>{let{selection:n}=e,r=V.create(n.ranges.map(i=>e.wordAt(i.head)||V.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function DDe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let s=!1,a=new wc(e.doc,t,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new wc(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some(l=>l.from==a.value.from))continue;if(o){let l=e.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const LDe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(o=>o.from===o.to))return RDe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(o=>e.sliceDoc(o.from,o.to)!=r))return!1;let i=DDe(e,r);return i?(t(e.update({selection:e.selection.addRange(V.range(i.from,i.to),!1),effects:ie.scrollIntoView(i.to)})),!0):!1},Gc=se.define({combine(e){return Ji(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new YDe(t),scrollToMatch:t=>ie.scrollIntoView(t)})}});class DW{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||CDe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
440
440
|
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new UDe(this):new FDe(this)}getCursor(t,n=0,r){let i=t.doc?t:Ne.create({doc:t});return r==null&&(r=i.doc.length),this.regexp?Fl(this,i,n,r):Bl(this,i,n,r)}}class LW{constructor(t){this.spec=t}}function $De(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}function Bl(e,t,n,r){let i;return e.wholeWord&&(i=BDe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=$De(e.test,t,i)),new wc(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:o=>o.toLowerCase(),i)}function BDe(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),(t(wv(i,n-o))!=yt.Word||t(Sv(i,n-o))!=yt.Word)&&(t(Sv(i,r-o))!=yt.Word||t(wv(i,r-o))!=yt.Word))}class FDe extends LW{constructor(t){super(t)}nextMatch(t,n,r){let i=Bl(this.spec,t,r,t.doc.length).nextOverlapping();if(i.done){let o=Math.min(t.doc.length,n+this.spec.unquoted.length);i=Bl(this.spec,t,0,o).nextOverlapping()}return i.done||i.value.from==n&&i.value.to==r?null:i.value}prevMatchInRange(t,n,r){for(let i=r;;){let o=Math.max(n,i-1e4-this.spec.unquoted.length),s=Bl(this.spec,t,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==n)return null;i-=1e4}}prevMatch(t,n,r){let i=this.prevMatchInRange(t,0,n);return i||(i=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),i&&(i.from!=n||i.to!=r)?i:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=Bl(this.spec,t,0,t.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(t,n,r,i){let o=Bl(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}function zDe(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}function Fl(e,t,n,r){let i;return e.wholeWord&&(i=WDe(t.charCategorizer(t.selection.main.head))),e.test&&(i=zDe(e.test,t,i)),new NW(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function wv(e,t){return e.slice(Jt(e,t,!1),t)}function Sv(e,t){return e.slice(t,Jt(e,t))}function WDe(e){return(t,n,r)=>!r[0].length||(e(wv(r.input,r.index))!=yt.Word||e(Sv(r.input,r.index))!=yt.Word)&&(e(Sv(r.input,r.index+r[0].length))!=yt.Word||e(wv(r.input,r.index+r[0].length))!=yt.Word)}class UDe extends LW{nextMatch(t,n,r){let i=Fl(this.spec,t,r,t.doc.length).next();return i.done&&(i=Fl(this.spec,t,0,n).next()),i.done?null:i.value}prevMatchInRange(t,n,r){for(let i=1;;i++){let o=Math.max(n,r-i*1e4),s=Fl(this.spec,t,o,r),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==n||a.from>o+10))return a;if(o==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let i=r.length;i>0;i--){let o=+r.slice(0,i);if(o>0&&o<t.match.length)return t.match[o]+r.slice(i)}return n})}matchAll(t,n){let r=Fl(this.spec,t,0,t.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(t,n,r,i){let o=Fl(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}const Bd=ke.define(),rE=ke.define(),Os=kn.define({create(e){return new T1(IO(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Bd)?e=new T1(n.value.create(),e.panel):n.is(rE)&&(e=new T1(e.query,n.value?iE:null));return e},provide:e=>Rd.from(e,t=>t.panel)});class T1{constructor(t,n){this.query=t,this.panel=n}}const HDe=de.mark({class:"cm-searchMatch"}),VDe=de.mark({class:"cm-searchMatch cm-searchMatch-selected"}),qDe=Et.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Os))}update(e){let t=e.state.field(Os);(t!=e.startState.field(Os)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return de.none;let{view:n}=this,r=new Io;for(let i=0,o=n.visibleRanges,s=o.length;i<s;i++){let{from:a,to:l}=o[i];for(;i<s-1&&l>o[i+1].from-2*250;)l=o[++i].to;e.highlight(n.state,a,l,(u,c)=>{let f=n.state.selection.ranges.some(h=>h.from==u&&h.to==c);r.add(u,c,f?VDe:HDe)})}return r.finish()}},{decorations:e=>e.decorations});function mp(e){return t=>{let n=t.state.field(Os,!1);return n&&n.query.spec.valid?e(t,n):FW(t)}}const kv=mp((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=V.single(r.from,r.to),o=e.state.facet(Gc);return e.dispatch({selection:i,effects:[oE(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),BW(e),!0}),Ov=mp((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=V.single(i.from,i.to),s=e.state.facet(Gc);return e.dispatch({selection:o,effects:[oE(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),BW(e),!0}),KDe=mp((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:V.create(n.map(r=>V.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),GDe=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let a=new wc(e.doc,e.sliceDoc(r,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==r&&(s=o.length),o.push(V.range(a.value.from,a.value.to))}return t(e.update({selection:V.create(o,s),userEvent:"select.search.matches"})),!0},iD=mp((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s=o,a=[],l,u,c=[];s.precise?s.from==r&&s.to==i&&(u=n.toText(t.getReplacement(s)),a.push({from:s.from,to:s.to,insert:u}),c.push(ie.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):s=t.nextMatch(n,s.from,s.to);let f=e.state.changes(a);return s&&(l=V.single(s.from,s.to).map(f),c.push(oE(e,s)),c.push(n.facet(Gc).scrollToMatch(l.main,e))),e.dispatch({changes:f,selection:l,effects:c,userEvent:"input.replace"}),!0}),QDe=mp((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let i of t.matchAll(e.state,1e9)){let{from:o,to:s,precise:a}=i;a&&n.push({from:o,to:s,insert:t.getReplacement(i)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:ie.announce.of(r),userEvent:"input.replace.all"}),!0});function iE(e){return e.state.facet(Gc).createPanel(e)}function IO(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let u=e.facet(Gc);return new DW({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(i=t?.literal)!==null&&i!==void 0?i:u.literal,regexp:(o=t?.regexp)!==null&&o!==void 0?o:u.regexp,wholeWord:(s=t?.wholeWord)!==null&&s!==void 0?s:u.wholeWord})}function $W(e){let t=qP(e,iE);return t&&t.dom.querySelector("[main-field]")}function BW(e){let t=$W(e);t&&t==e.root.activeElement&&t.select()}const FW=e=>{let t=e.state.field(Os,!1);if(t&&t.panel){let n=$W(e);if(n&&n!=e.root.activeElement){let r=IO(e.state,t.query.spec);r.valid&&e.dispatch({effects:Bd.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[rE.of(!0),t?Bd.of(IO(e.state,t.query.spec)):ke.appendConfig.of(JDe)]});return!0},zW=e=>{let t=e.state.field(Os,!1);if(!t||!t.panel)return!1;let n=qP(e,iE);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:rE.of(!1)}),!0},XDe=[{key:"Mod-f",run:FW,scope:"editor search-panel"},{key:"F3",run:kv,shift:Ov,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:kv,shift:Ov,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:zW,scope:"editor search-panel"},{key:"Mod-Shift-l",run:GDe},{key:"Mod-Alt-g",run:ADe},{key:"Mod-d",run:LDe,preventDefault:!0}];class YDe{constructor(t){this.view=t;let n=this.query=t.state.field(Os).query.spec;this.commit=this.commit.bind(this),this.searchField=Ke("input",{value:n.search,placeholder:lr(t,"Find"),"aria-label":lr(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ke("input",{value:n.replace,placeholder:lr(t,"Replace"),"aria-label":lr(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ke("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Ke("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Ke("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(i,o,s){return Ke("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=Ke("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>kv(t),[lr(t,"next")]),r("prev",()=>Ov(t),[lr(t,"previous")]),r("select",()=>KDe(t),[lr(t,"all")]),Ke("label",null,[this.caseField,lr(t,"match case")]),Ke("label",null,[this.reField,lr(t,"regexp")]),Ke("label",null,[this.wordField,lr(t,"by word")]),...t.state.readOnly?[]:[Ke("br"),this.replaceField,r("replace",()=>iD(t),[lr(t,"replace")]),r("replaceAll",()=>QDe(t),[lr(t,"replace all")])],Ke("button",{name:"close",onclick:()=>zW(t),"aria-label":lr(t,"close"),type:"button"},["×"])])}commit(){let t=new DW({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Bd.of(t)}))}keydown(t){tIe(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Ov:kv)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),iD(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(Bd)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Gc).top}}function lr(e,t){return e.state.phrase(t)}const Pm=30,Em=/[\s\.,:;?!]/;function oE(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-Pm),s=Math.min(i,n+Pm),a=e.state.sliceDoc(o,s);if(o!=r.from){for(let l=0;l<Pm;l++)if(!Em.test(a[l+1])&&Em.test(a[l])){a=a.slice(l);break}}if(s!=i){for(let l=a.length-1;l>a.length-Pm;l--)if(!Em.test(a[l-1])&&Em.test(a[l])){a=a.slice(0,l);break}}return ie.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const ZDe=ie.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),JDe=[Os,bl.low(qDe),ZDe];class WW{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=xn(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),o=i.search(UW(t,!1));return o<0?null:{from:r+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function oD(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function eLe(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let o=1;o<i.length;o++)n[i[o]]=!0}let r=oD(t)+oD(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function tLe(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:eLe(t);return i=>{let o=i.matchBefore(r);return o||i.explicit?{from:o?o.from:i.pos,options:t,validFor:n}:null}}class sD{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Wa(e){return e.selection.main.from}function UW(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",o=r[r.length-1]!="$";return!i&&!o?e:new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const HW=Zi.define();function nLe(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:V.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const aD=new WeakMap;function rLe(e){if(!Array.isArray(e))return e;let t=aD.get(e);return t||aD.set(e,t=tLe(e)),t}const Cv=ke.define(),Fd=ke.define();class iLe{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=zn(t,n),i=Ni(r);this.chars.push(r);let o=t.slice(n,n+i),s=o.toUpperCase();this.folded.push(zn(s==o?o.toLowerCase():s,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:o,byWord:s}=this;if(n.length==1){let y=zn(t,0),x=Ni(y),k=x==t.length?0:-100;if(y!=n[0])if(y==r[0])k+=-200;else return null;return this.ret(k,[0,x])}let a=t.indexOf(this.pattern);if(a==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,u=0;if(a<0){for(let y=0,x=Math.min(t.length,200);y<x&&u<l;){let k=zn(t,y);(k==n[u]||k==r[u])&&(i[u++]=y),y+=Ni(k)}if(u<l)return null}let c=0,f=0,h=!1,d=0,p=-1,m=-1,v=/[a-z]/.test(t),b=!0;for(let y=0,x=Math.min(t.length,200),k=0;y<x&&f<l;){let w=zn(t,y);a<0&&(c<l&&w==n[c]&&(o[c++]=y),d<l&&(w==n[d]||w==r[d]?(d==0&&(p=y),m=y+1,d++):d=0));let S,O=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=EP(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||O==1&&v||k==0&&O!=0)&&(n[f]==w||r[f]==w&&(h=!0)?s[f++]=y:s.length&&(b=!1)),k=O,y+=Ni(w)}return f==l&&s[0]==0&&b?this.result(-100+(h?-200:0),s,t):d==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):a>-1?this.ret(-700-t.length,[a,a+this.pattern.length]):d==l?this.ret(-900-t.length,[p,m]):f==l?this.result(-100+(h?-200:0)+-700+(b?0:-1100),s,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],o=0;for(let s of n){let a=s+(this.astral?Ni(zn(r,s)):1);o&&i[o-1]==s?i[o-1]=a:(i[o++]=s,i[o++]=a)}return this.ret(t-r.length,i)}}class oLe{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Zt=se.define({combine(e){return Ji(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:sLe,filterStrict:!1,compareCompletions:(t,n)=>(t.sortText||t.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>lD(t(r),n(r)),optionClass:(t,n)=>r=>lD(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function lD(e,t){return e?t?e+" "+t:e:t}function sLe(e,t,n,r,i,o){let s=e.textDirection==Je.RTL,a=s,l=!1,u="top",c,f,h=t.left-i.left,d=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(a&&h<Math.min(p,d)?a=!1:!a&&d<Math.min(p,h)&&(a=!0),p<=(a?h:d))c=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,f=Math.min(400,a?h:d);else{l=!0,f=Math.min(400,(s?t.right:i.right-t.left)-30);let y=i.bottom-t.bottom;y>=m||y>t.top?c=n.bottom-t.top:(u="bottom",c=t.bottom-n.top)}let v=(t.bottom-t.top)/o.offsetHeight,b=(t.right-t.left)/o.offsetWidth;return{style:`${u}: ${c/v}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}const sE=ke.define();function aLe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let u=0;u<o.length;){let c=o[u++],f=o[u++];c>l&&s.appendChild(document.createTextNode(a.slice(l,c)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(c,f))),h.className="cm-completionMatchedText",l=f}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function _1(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class lLe{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:o,selected:s}=i.open,a=t.state.facet(Zt);this.optionContent=aLe(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=_1(o.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:u}=t.state.field(n).open;for(let c=l.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<u.length){this.applyCompletion(t,u[+f[1]]),l.preventDefault();return}if(l.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(t.dispatch({effects:sE.of(c)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let u=t.state.field(this.stateField,!1);u&&u.tooltip&&t.state.facet(Zt).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:Fd.of(null)})}),this.showOptions(o,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:o,selected:s,disabled:a}=r.open;(!i.open||i.open.options!=o)&&(this.range=_1(o.length,s,t.state.facet(Zt).maxRenderedOptions),this.showOptions(o,r.id)),this.updateSel(),a!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=_1(n.options.length,n.selected,this.view.state.facet(Zt).maxRenderedOptions),this.showOptions(n.options,t.id));let r=this.updateSelectedOption(n.selected);if(r){this.destroyInfo();let{completion:i}=n.options[n.selected],{info:o}=i;if(!o)return;let s=typeof o=="string"?document.createTextNode(o):o(i);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(a,i)}).catch(a=>Gn(this.view.state,a,"completion info")):(this.addInfoPane(s,i),r.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",r.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:o}=t;r.appendChild(i),this.infoDestroy=o||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&(r.removeAttribute("aria-selected"),r.removeAttribute("aria-describedby"));return n&&cLe(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),o=this.space;if(!o){let s=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return i.top>Math.min(o.bottom,n.bottom)-10||i.bottom<Math.max(o.top,n.top)+10?null:this.view.state.facet(Zt).positionInfo(this.view,n,i,r,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",s=>{s.target==i&&s.preventDefault()});let o=null;for(let s=r.from;s<r.to;s++){let{completion:a,match:l}=t[s],{section:u}=a;if(u){let h=typeof u=="string"?u:u.name;if(h!=o&&(s>r.from||r.from==0))if(o=h,typeof u!="string"&&u.header)i.appendChild(u.header(u));else{let d=i.appendChild(document.createElement("completion-section"));d.textContent=h}}const c=i.appendChild(document.createElement("li"));c.id=n+"-"+s,c.setAttribute("role","option");let f=this.optionClass(a);f&&(c.className=f);for(let h of this.optionContent){let d=h(a,this.view.state,this.view,l);d&&c.appendChild(d)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function uLe(e,t){return n=>new lLe(n,e,t)}function cLe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function uD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function fLe(e,t){let n=[],r=null,i=null,o=c=>{n.push(c);let{section:f}=c.completion;if(f){r||(r=[]);let h=typeof f=="string"?f:f.name;r.some(d=>d.name==h)||r.push(typeof f=="string"?{name:h}:f)}},s=t.facet(Zt);for(let c of e)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let h of c.result.options)o(new sD(h,c.source,f?f(h):[],1e9-n.length));else{let h=t.sliceDoc(c.from,c.to),d,p=s.filterStrict?new oLe(h):new iLe(h);for(let m of c.result.options)if(d=p.match(m.label)){let v=m.displayLabel?f?f(m,d.matched):[]:d.matched,b=d.score+(m.boost||0);if(o(new sD(m,c.source,v,b)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:y}=m.section;i||(i=Object.create(null)),i[y]=Math.max(b,i[y]||-1e9)}}}}if(r){let c=Object.create(null),f=0,h=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?i[p.name]-i[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of r.sort(h))f-=1e5,c[d.name]=f;for(let d of n){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let a=[],l=null,u=s.compareCompletions;for(let c of n.sort((f,h)=>h.score-f.score||u(f.completion,h.completion))){let f=c.completion;!l||l.label!=f.label||l.detail!=f.detail||l.type!=null&&f.type!=null&&l.type!=f.type||l.apply!=f.apply||l.boost!=f.boost?a.push(c):uD(c.completion)>uD(l)&&(a[a.length-1]=c),l=c.completion}return a}class cu{constructor(t,n,r,i,o,s){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=o,this.disabled=s}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new cu(this.options,cD(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,o,s){if(i&&!s&&t.some(u=>u.isPending))return i.setDisabled();let a=fLe(t,n);if(!a.length)return i&&t.some(u=>u.isPending)?i.setDisabled():null;let l=n.facet(Zt).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let u=i.options[i.selected].completion;for(let c=0;c<a.length;c++)if(a[c].completion==u){l=c;break}}return new cu(a,cD(r,l),{pos:t.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:yLe,above:o.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new cu(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new cu(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Av{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new Av(mLe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Zt),o=(r.override||n.languageDataAt("autocomplete",Wa(n)).map(rLe)).map(l=>(this.active.find(c=>c.source==l)||new Ur(l,this.active.some(c=>c.state!=0)?1:0)).update(t,r));o.length==this.active.length&&o.every((l,u)=>l==this.active[u])&&(o=this.active);let s=this.open,a=t.effects.some(l=>l.is(aE));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||o.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!hLe(o,this.active)||a?s=cu.build(o,n,this.id,s,r,a):s&&s.disabled&&!o.some(l=>l.isPending)&&(s=null),!s&&o.every(l=>!l.isPending)&&o.some(l=>l.hasResult())&&(o=o.map(l=>l.hasResult()?new Ur(l.source,0):l));for(let l of t.effects)l.is(sE)&&(s=s&&s.setSelected(l.value,this.id));return o==this.active&&s==this.open?this:new Av(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?dLe:pLe}}function hLe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}const dLe={"aria-autocomplete":"list"},pLe={};function cD(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const mLe=[];function VW(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(HW);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Ur{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=VW(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Ur(i.source,0)),r&4&&i.state==0&&(i=new Ur(this.source,1)),i=i.updateFor(t,r);for(let o of t.effects)if(o.is(Cv))i=new Ur(i.source,1,o.value);else if(o.is(Fd))i=new Ur(i.source,0);else if(o.is(aE))for(let s of o.value)s.source==i.source&&(i=s);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Wa(t.state))}}class _u extends Ur{constructor(t,n,r,i,o,s){super(t,3,n),this.limit=r,this.result=i,this.from=o,this.to=s}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let o=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),a=Wa(t.state);if(a>s||!i||n&2&&(Wa(t.startState)==this.from||a<this.limit))return new Ur(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return gLe(i.validFor,t.state,o,s)?new _u(this.source,this.explicit,l,i,o,s):i.update&&(i=i.update(i,o,s,new WW(t.state,a,!1)))?new _u(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Wa(t.state)):new Ur(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new _u(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Ur(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function gLe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):UW(e,!0).test(i)}const aE=ke.define({map(e,t){return e.map(n=>n.map(t))}}),Wn=kn.define({create(){return Av.start()},update(e,t){return e.update(t)},provide:e=>[VP.from(e,t=>t.tooltip),ie.contentAttributes.from(e,t=>t.attrs)]});function lE(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Wn).active.find(i=>i.source==t.source);return r instanceof _u?(typeof n=="string"?e.dispatch({...nLe(e.state,n,r.from,r.to),annotations:HW.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}const yLe=uLe(Wn,lE);function Tm(e,t="option"){return n=>{let r=n.state.field(Wn,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Zt).interactionDelay)return!1;let i=1,o;t=="page"&&(o=k9(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:s-1;return a<0?a=t=="page"?0:s-1:a>=s&&(a=t=="page"?s-1:0),n.dispatch({effects:sE.of(a)}),!0}}const vLe=e=>{let t=e.state.field(Wn,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Zt).interactionDelay?!1:lE(e,t.open.options[t.open.selected])},j1=e=>e.state.field(Wn,!1)?(e.dispatch({effects:Cv.of(!0)}),!0):!1,bLe=e=>{let t=e.state.field(Wn,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Fd.of(null)}),!0)};class xLe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const wLe=50,SLe=1e3,kLe=Et.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Wn).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Wn),n=e.state.facet(Zt);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Wn)==t)return;let r=e.transactions.some(o=>{let s=VW(o,n);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;o<this.running.length;o++){let s=this.running[o];if(r||s.context.abortOnDocChange&&e.docChanged||s.updates.length+e.transactions.length>wLe&&Date.now()-s.time>SLe){for(let a of s.context.abortListeners)try{a()}catch(l){Gn(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(o=>o.effects.some(s=>s.is(Cv)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let o of e.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Wn);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Zt).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Wa(t),r=new WW(t,n,e.explicit,this.view),i=new xLe(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Fd.of(null)}),Gn(this.view.state,o)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Zt).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Zt),r=this.view.state.field(Wn);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(o.done===void 0)continue;if(this.running.splice(i--,1),o.done){let a=Wa(o.updates.length?o.updates[0].startState:this.view.state),l=Math.min(a,o.done.from+(o.active.explicit?0:1)),u=new _u(o.active.source,o.active.explicit,l,o.done,o.done.from,(e=o.done.to)!==null&&e!==void 0?e:a);for(let c of o.updates)u=u.update(c,n);if(u.hasResult()){t.push(u);continue}}let s=r.active.find(a=>a.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new Ur(o.active.source,0);for(let l of o.updates)a=a.update(l,n);a.isPending||t.push(a)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:aE.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Wn,!1);if(t&&t.tooltip&&this.view.state.facet(Zt).closeOnBlur){let n=t.open&&k9(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Fd.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Cv.of(!1)}),20),this.composing=0}}}),OLe=typeof navigator=="object"&&/Win/.test(navigator.platform),CLe=bl.highest(ie.domEventHandlers({keydown(e,t){let n=t.state.field(Wn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(OLe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(s=>s.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&lE(t,r),!1}})),ALe=ie.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),zd={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ea=ke.define({map(e,t){let n=t.mapPos(e,-1,jn.TrackAfter);return n??void 0}}),uE=new class extends js{};uE.startSide=1;uE.endSide=-1;const qW=kn.define({create(){return _e.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(Ea)&&(e=e.update({add:[uE.range(n.value,n.value+1)]}));return e}});function PLe(){return[TLe,qW]}const M1="()[]{}<>«»»«[]{}";function KW(e){for(let t=0;t<M1.length;t+=2)if(M1.charCodeAt(t)==e)return M1.charAt(t+1);return EP(e<128?e:e+1)}function GW(e,t){return e.languageDataAt("closeBrackets",t)[0]||zd}const ELe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),TLe=ie.inputHandler.of((e,t,n,r)=>{if((ELe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Ni(zn(r,0))==1||t!=i.from||n!=i.to)return!1;let o=MLe(e.state,r);return o?(e.dispatch(o),!0):!1}),_Le=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=GW(e,e.selection.main.head).brackets||zd.brackets,i=null,o=e.changeByRange(s=>{if(s.empty){let a=ILe(e.doc,s.head);for(let l of r)if(l==a&&xb(e.doc,s.head)==KW(zn(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:V.cursor(s.head-l.length)}}return{range:i=s}});return i||t(e.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},jLe=[{key:"Backspace",run:_Le}];function MLe(e,t){let n=GW(e,e.selection.main.head),r=n.brackets||zd.brackets;for(let i of r){let o=KW(zn(i,0));if(t==i)return o==i?DLe(e,i,r.indexOf(i+i+i)>-1,n):NLe(e,i,o,n.before||zd.before);if(t==o&&QW(e,e.selection.main.from))return RLe(e,i,o)}return null}function QW(e,t){let n=!1;return e.field(qW).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function xb(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Ni(zn(n,0)))}function ILe(e,t){let n=e.sliceString(t-2,t);return Ni(zn(n,0))==n.length?n:n.slice(1)}function NLe(e,t,n,r){let i=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:Ea.of(s.to+t.length),range:V.range(s.anchor+t.length,s.head+t.length)};let a=xb(e.doc,s.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:t+n,from:s.head},effects:Ea.of(s.head+t.length),range:V.cursor(s.head+t.length)}:{range:i=s}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function RLe(e,t,n){let r=null,i=e.changeByRange(o=>o.empty&&xb(e.doc,o.head)==n?{changes:{from:o.head,to:o.head+n.length,insert:n},range:V.cursor(o.head+n.length)}:r={range:o});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function DLe(e,t,n,r){let i=r.stringPrefixes||zd.stringPrefixes,o=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:t,from:a.to}],effects:Ea.of(a.to+t.length),range:V.range(a.anchor+t.length,a.head+t.length)};let l=a.head,u=xb(e.doc,l),c;if(u==t){if(fD(e,l))return{changes:{insert:t+t,from:l},effects:Ea.of(l+t.length),range:V.cursor(l+t.length)};if(QW(e,l)){let h=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+h.length,insert:h},range:V.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(c=hD(e,l-2*t.length,i))>-1&&fD(e,c))return{changes:{insert:t+t+t+t,from:l},effects:Ea.of(l+t.length),range:V.cursor(l+t.length)};if(e.charCategorizer(l)(u)!=yt.Word&&hD(e,l,i)>-1&&!LLe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Ea.of(l+t.length),range:V.cursor(l+t.length)}}return{range:o=a}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function fD(e,t){let n=xn(e).resolveInner(t+1);return n.parent&&n.from==t}function LLe(e,t,n,r){let i=xn(e).resolveInner(t,-1),o=r.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let c=i.firstChild;for(;c&&c.from==i.from&&c.to-c.from>n.length+l;){if(e.sliceDoc(c.to-n.length,c.to)==n)return!1;c=c.firstChild}return!0}let u=i.to==t&&i.parent;if(!u)break;i=u}return!1}function hD(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=yt.Word)return t;for(let i of n){let o=t-i.length;if(e.sliceDoc(o,t)==i&&r(e.sliceDoc(o-1,o))!=yt.Word)return o}return-1}function $Le(e={}){return[CLe,Wn,Zt.of(e),kLe,BLe,ALe]}const XW=[{key:"Ctrl-Space",run:j1},{mac:"Alt-`",run:j1},{mac:"Alt-i",run:j1},{key:"Escape",run:bLe},{key:"ArrowDown",run:Tm(!0)},{key:"ArrowUp",run:Tm(!1)},{key:"PageDown",run:Tm(!0,"page")},{key:"PageUp",run:Tm(!1,"page")},{key:"Enter",run:vLe}],BLe=bl.highest(fb.computeN([Zt],e=>e.facet(Zt).defaultKeymap?[XW]:[]));class dD{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class ma{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let i=r.facet(Wd).markerFilter;i&&(t=i(t,r));let o=t.slice().sort((d,p)=>d.from-p.from||d.to-p.to),s=new Io,a=[],l=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let d=0;;){let p=d==o.length?null:o[d];if(!p&&!a.length)break;let m,v;if(a.length)m=l,v=a.reduce((x,k)=>Math.min(x,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;v=p.to,a.push(p),d++}for(;d<o.length;){let x=o[d];if(x.from==m&&(x.to>x.from||x.to==m))a.push(x),d++,v=Math.min(x.to,v);else{v=Math.min(x.from,v);break}}v=Math.min(v,f);let b=!1;if(a.some(x=>x.from==m&&(x.to==v||v==f))&&(b=m==v,!b&&v-m<10)){let x=m-(c+u.value.length);x>0&&(u.next(x),c=m);for(let k=m;;){if(k>=v){b=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let y=ZLe(a);if(b)s.add(m,m,de.widget({widget:new GLe(y),diagnostics:a.slice()}));else{let x=a.reduce((k,w)=>w.markClass?k+" "+w.markClass:k,"");s.add(m,v,de.mark({class:"cm-lintRange cm-lintRange-"+y+x,diagnostics:a.slice(),inclusiveEnd:a.some(k=>k.to>v)}))}if(l=v,l==f)break;for(let x=0;x<a.length;x++)a[x].to<=l&&a.splice(x--,1)}let h=s.finish();return new ma(h,n,Ls(h))}}function Ls(e,t=null,n=0){let r=null;return e.between(n,1e9,(i,o,{spec:s})=>{if(!(t&&s.diagnostics.indexOf(t)<0))if(!r)r=new dD(i,o,t||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new dD(r.from,o,r.diagnostic)}}),r}function FLe(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Wd).hideOn(e,n,r);if(i!=null)return i;let o=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(s=>s.is(YW))||e.changes.touchesRange(o.from,Math.max(o.to,r)))}function zLe(e,t){return e.field(wr,!1)?t:t.concat(ke.appendConfig.of(JLe))}const YW=ke.define(),cE=ke.define(),ZW=ke.define(),wr=kn.define({create(){return new ma(de.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);r=Ls(n,e.selected.diagnostic,o)||Ls(n,null,o)}!n.size&&i&&t.state.facet(Wd).autoPanel&&(i=null),e=new ma(n,i,r)}for(let n of t.effects)if(n.is(YW)){let r=t.state.facet(Wd).autoPanel?n.value.length?Ud.open:null:e.panel;e=ma.init(n.value,r,t.state)}else n.is(cE)?e=new ma(e.diagnostics,n.value?Ud.open:null,e.selected):n.is(ZW)&&(e=new ma(e.diagnostics,e.panel,n.value));return e},provide:e=>[Rd.from(e,t=>t.panel),ie.decorations.from(e,t=>t.diagnostics)]}),WLe=de.mark({class:"cm-lintRange cm-lintRange-active"});function ULe(e,t,n){let{diagnostics:r}=e.state.field(wr),i,o=-1,s=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(l,u,{spec:c})=>{if(t>=l&&t<=u&&(l==u||(t>l||n>0)&&(t<u||n<0)))return i=c.diagnostics,o=l,s=u,!1});let a=e.state.facet(Wd).tooltipFilter;return i&&a&&(i=a(i,e.state)),i?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create(){return{dom:HLe(e,i)}}}:null}function HLe(e,t){return Ke("ul",{class:"cm-tooltip-lint"},t.map(n=>eU(e,n,!1)))}const VLe=e=>{let t=e.state.field(wr,!1);(!t||!t.panel)&&e.dispatch({effects:zLe(e.state,[cE.of(!0)])});let n=qP(e,Ud.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},pD=e=>{let t=e.state.field(wr,!1);return!t||!t.panel?!1:(e.dispatch({effects:cE.of(!1)}),!0)},qLe=e=>{let t=e.state.field(wr,!1);if(!t)return!1;let n=e.state.selection.main,r=Ls(t.diagnostics,null,n.to+1);return!r&&(r=Ls(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},KLe=[{key:"Mod-Shift-m",run:VLe,preventDefault:!0},{key:"F8",run:qLe}],Wd=se.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Ji(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:mD,tooltipFilter:mD,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,i,o)=>t(r,i,o)||n(r,i,o):t:n,autoPanel:(t,n)=>t||n})}}});function mD(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function JW(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!t.some(o=>o.toLowerCase()==i.toLowerCase())){t.push(i);continue e}}t.push("")}return t}function eU(e,t,n){var r;let i=n?JW(t.actions):[];return Ke("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Ke("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((o,s)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=Ls(e.state.field(wr).diagnostics,t);p&&o.apply(e,p.from,p.to)},{name:u}=o,c=i[s]?u.indexOf(i[s]):-1,f=c<0?u:[u.slice(0,c),Ke("u",u.slice(c,c+1)),u.slice(c+1)],h=o.markClass?" "+o.markClass:"";return Ke("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[s]})"`}.`},f)}),t.source&&Ke("div",{class:"cm-diagnosticSource"},t.source))}class GLe extends eo{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Ke("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class gD{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=eU(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ud{constructor(t){this.view=t,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)pD(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=JW(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=Ls(this.view.state.field(wr).diagnostics,o);l&&o.actions[a].apply(t,l.from,l.to)}}else return;i.preventDefault()}},r=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=Ke("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=Ke("div",{class:"cm-panel-lint"},this.list,Ke("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>pD(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(wr).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(wr),r=0,i=!1,o=null,s=new Set;for(t.between(0,this.view.state.doc.length,(a,l,{spec:u})=>{for(let c of u.diagnostics){if(s.has(c))continue;s.add(c);let f=-1,h;for(let d=r;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(h=new gD(this.view,c),this.items.splice(r,0,h),i=!0):(h=this.items[f],f>r&&(this.items.splice(r,f-r),i=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new gD(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let u=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/u:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(wr),r=Ls(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:ZW.of(r)})}static open(t){return new Ud(t)}}function QLe(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function _m(e){return QLe(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const XLe=ie.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:_m("#d11")},".cm-lintRange-warning":{backgroundImage:_m("orange")},".cm-lintRange-info":{backgroundImage:_m("#999")},".cm-lintRange-hint":{backgroundImage:_m("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function YLe(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function ZLe(e){let t="hint",n=1;for(let r of e){let i=YLe(r.severity);i>n&&(n=i,t=r.severity)}return t}const JLe=[wr,ie.decorations.compute([wr],e=>{let{selected:t,panel:n}=e.field(wr);return!t||!n||t.from==t.to?de.none:de.set([WLe.range(t.from,t.to)])}),UIe(ULe,{hideOn:FLe}),XLe];var yD=function(t){t===void 0&&(t={});var{crosshairCursor:n=!1}=t,r=[];t.closeBracketsKeymap!==!1&&(r=r.concat(jLe)),t.defaultKeymap!==!1&&(r=r.concat(kDe)),t.searchKeymap!==!1&&(r=r.concat(XDe)),t.historyKeymap!==!1&&(r=r.concat(_Re)),t.foldKeymap!==!1&&(r=r.concat(HNe)),t.completionKeymap!==!1&&(r=r.concat(XW)),t.lintKeymap!==!1&&(r=r.concat(KLe));var i=[];return t.lineNumbers!==!1&&i.push(nNe()),t.highlightActiveLineGutter!==!1&&i.push(oNe()),t.highlightSpecialChars!==!1&&i.push(vIe()),t.history!==!1&&i.push(wRe()),t.foldGutter!==!1&&i.push(GNe()),t.drawSelection!==!1&&i.push(aIe()),t.dropCursor!==!1&&i.push(hIe()),t.allowMultipleSelections!==!1&&i.push(Ne.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(NNe()),t.syntaxHighlighting!==!1&&i.push(X9(ZNe,{fallback:!0})),t.bracketMatching!==!1&&i.push(oRe()),t.closeBrackets!==!1&&i.push(PLe()),t.autocompletion!==!1&&i.push($Le()),t.rectangularSelection!==!1&&i.push(MIe()),n!==!1&&i.push(RIe()),t.highlightActiveLine!==!1&&i.push(OIe()),t.highlightSelectionMatches!==!1&&i.push(TDe()),t.tabSize&&typeof t.tabSize=="number"&&i.push(db.of(" ".repeat(t.tabSize))),i.concat([fb.of(r.flat())]).filter(Boolean)};const e$e="#e5c07b",vD="#e06c75",t$e="#56b6c2",n$e="#ffffff",ag="#abb2bf",NO="#7d8799",r$e="#61afef",i$e="#98c379",bD="#d19a66",o$e="#c678dd",s$e="#21252b",xD="#2c313a",wD="#282c34",I1="#353a42",a$e="#3E4451",SD="#528bff",l$e=ie.theme({"&":{color:ag,backgroundColor:wD},".cm-content":{caretColor:SD},".cm-cursor, .cm-dropCursor":{borderLeftColor:SD},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:a$e},".cm-panels":{backgroundColor:s$e,color:ag},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:wD,color:NO,border:"none"},".cm-activeLineGutter":{backgroundColor:xD},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:I1},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:I1,borderBottomColor:I1},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:xD,color:ag}}},{dark:!0}),u$e=dp.define([{tag:W.keyword,color:o$e},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:vD},{tag:[W.function(W.variableName),W.labelName],color:r$e},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:bD},{tag:[W.definition(W.name),W.separator],color:ag},{tag:[W.typeName,W.className,W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:e$e},{tag:[W.operator,W.operatorKeyword,W.url,W.escape,W.regexp,W.link,W.special(W.string)],color:t$e},{tag:[W.meta,W.comment],color:NO},{tag:W.strong,fontWeight:"bold"},{tag:W.emphasis,fontStyle:"italic"},{tag:W.strikethrough,textDecoration:"line-through"},{tag:W.link,color:NO,textDecoration:"underline"},{tag:W.heading,fontWeight:"bold",color:vD},{tag:[W.atom,W.bool,W.special(W.variableName)],color:bD},{tag:[W.processingInstruction,W.string,W.inserted],color:i$e},{tag:W.invalid,color:n$e}]),c$e=[l$e,X9(u$e)];var f$e=ie.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),h$e=function(t){t===void 0&&(t={});var{indentWithTab:n=!0,editable:r=!0,readOnly:i=!1,theme:o="light",placeholder:s="",basicSetup:a=!0}=t,l=[];switch(n&&l.unshift(fb.of([ODe])),a&&(typeof a=="boolean"?l.unshift(yD()):l.unshift(yD(a))),s&&l.unshift(EIe(s)),o){case"light":l.push(f$e);break;case"dark":l.push(c$e);break;case"none":break;default:l.push(o);break}return r===!1&&l.push(ie.editable.of(!1)),i&&l.push(Ne.readOnly.of(!0)),[...l]},d$e=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class p$e{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class kD{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var N1=null,m$e=()=>typeof window>"u"?new kD:(N1||(N1=new kD),N1),OD=Zi.define(),g$e=200,y$e=[];function v$e(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:o,onUpdate:s,extensions:a=y$e,autoFocus:l,theme:u="light",height:c=null,minHeight:f=null,maxHeight:h=null,width:d=null,minWidth:p=null,maxWidth:m=null,placeholder:v="",editable:b=!0,readOnly:y=!1,indentWithTab:x=!0,basicSetup:k=!0,root:w,initialState:S}=e,[O,A]=C.useState(),[P,M]=C.useState(),[j,E]=C.useState(),D=C.useState(()=>({current:null}))[0],R=C.useState(()=>({current:null}))[0],N=ie.theme({"&":{height:c,minHeight:f,maxHeight:h,width:d,minWidth:p,maxWidth:m},"& .cm-scroller":{height:"100% !important"}}),B=ie.updateListener.of(z=>{if(z.docChanged&&typeof r=="function"&&!z.transactions.some(I=>I.annotation(OD))){D.current?D.current.reset():(D.current=new p$e(()=>{if(R.current){var I=R.current;R.current=null,I()}D.current=null},g$e),m$e().add(D.current));var T=z.state.doc,q=T.toString();r(q,z)}i&&i(d$e(z))}),F=h$e({theme:u,editable:b,readOnly:y,placeholder:v,indentWithTab:x,basicSetup:k}),$=[B,N,...F];return s&&typeof s=="function"&&$.push(ie.updateListener.of(s)),$=$.concat(a),C.useLayoutEffect(()=>{if(O&&!j){var z={doc:t,selection:n,extensions:$},T=S?Ne.fromJSON(S.json,z,S.fields):Ne.create(z);if(E(T),!P){var q=new ie({state:T,parent:O,root:w});M(q),o&&o(q,T)}}return()=>{P&&(E(void 0),M(void 0))}},[O,j]),C.useEffect(()=>{e.container&&A(e.container)},[e.container]),C.useEffect(()=>()=>{P&&(P.destroy(),M(void 0)),D.current&&(D.current.cancel(),D.current=null)},[P]),C.useEffect(()=>{l&&P&&P.focus()},[l,P]),C.useEffect(()=>{P&&P.dispatch({effects:ke.reconfigure.of($)})},[u,a,c,f,h,d,p,m,v,b,y,x,k,r,s]),C.useEffect(()=>{if(t!==void 0){var z=P?P.state.doc.toString():"";if(P&&t!==z){var T=D.current&&!D.current.isDone,q=()=>{P&&t!==P.state.doc.toString()&&P.dispatch({changes:{from:0,to:P.state.doc.toString().length,insert:t||""},annotations:[OD.of(!0)]})};T?R.current=q:q()}}},[t,P]),{state:j,setState:E,view:P,setView:M,container:O,setContainer:A}}var b$e=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],tU=C.forwardRef((e,t)=>{var{className:n,value:r="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:l,onUpdate:u,autoFocus:c,theme:f="light",height:h,minHeight:d,maxHeight:p,width:m,minWidth:v,maxWidth:b,basicSetup:y,placeholder:x,indentWithTab:k,editable:w,readOnly:S,root:O,initialState:A}=e,P=Rve(e,b$e),M=C.useRef(null),{state:j,view:E,container:D,setContainer:R}=v$e({root:O,value:r,autoFocus:c,theme:f,height:h,minHeight:d,maxHeight:p,width:m,minWidth:v,maxWidth:b,basicSetup:y,placeholder:x,indentWithTab:k,editable:w,readOnly:S,selection:i,onChange:s,onStatistics:a,onCreateEditor:l,onUpdate:u,extensions:o,initialState:A});C.useImperativeHandle(t,()=>({editor:M.current,state:j,view:E}),[M,D,j,E]);var N=C.useCallback(F=>{M.current=F,R(F)},[R]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var B=typeof f=="string"?"cm-theme-"+f:"cm-theme";return g.jsx("div",QS({ref:N,className:""+B+(n?" "+n:"")},P))});tU.displayName="CodeMirror";var CD={};class Pv{constructor(t,n,r,i,o,s,a,l,u,c=0,f){this.p=t,this.stack=n,this.state=r,this.reducePos=i,this.pos=o,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((t,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,n,r=0){let i=t.parser.context;return new Pv(t,[],n,r,r,0,[],0,i?new AD(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var n;let r=t>>19,i=t&65535,{parser:o}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=o.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){i<o.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(o.getGoto(this.state,i,!0),this.reducePos),i<o.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(t&262144?6:0),u=l?this.stack[l-2]:this.p.ranges[0].from;i<o.minRepeatTerm&&u==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-u;c>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let f=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-f;if(i<o.minRepeatTerm||t&131072){let d=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,u,d,h+4,!0)}if(t&262144)this.state=this.stack[l];else{let d=this.stack[l-3];this.state=o.getGoto(d,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,u)}storeNode(t,n,r,i=4,o=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this.buffer.length;if(s>0&&this.buffer[s-4]==0&&this.buffer[s-1]>-1){if(n==r)return;if(this.buffer[s-2]>=n){this.buffer[s-2]=r;return}}}if(!o||this.pos==r)this.buffer.push(t,n,r,i);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>r;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4)}this.buffer[s]=t,this.buffer[s+1]=n,this.buffer[s+2]=r,this.buffer[s+3]=i}}shift(t,n,r,i){if(t&131072)this.pushState(t&65535,this.pos);else if(t&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let o=t,{parser:s}=this.p;this.pos=i;let a=s.stateFlag(o,1);!a&&(i>r||n<=s.maxNode)&&(this.reducePos=i),this.pushState(o,a?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=s.maxNode&&this.buffer.push(n,r,i,4)}}apply(t,n,r,i){t&65536?this.reduce(t):this.shift(t,n,r,i)}useNode(t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=t)&&(this.p.reused.push(t),r++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new Pv(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,n){let r=t<=this.p.parser.maxNode;r&&this.storeNode(t,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(t){for(let n=new x$e(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,t);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(t){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let o=0,s;o<n.length;o+=2)(s=n[o+1])!=this.state&&this.p.parser.hasAction(s,t)&&i.push(n[o],s);if(this.stack.length<120)for(let o=0;i.length<8&&o<n.length;o+=2){let s=n[o+1];i.some((a,l)=>l&1&&a==s)||i.push(n[o],s)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let o=n[i+1];if(o==this.state)continue;let s=this.split();s.pushState(o,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[i],this.pos),s.reducePos=this.pos,s.score-=200,r.push(s)}return r}forceReduce(){let{parser:t}=this.p,n=t.stateSlot(this.state,5);if(!(n&65536))return!1;if(!t.validAction(this.state,n)){let r=n>>19,i=n&65535,o=this.stack.length-r*3;if(o<0||t.getGoto(this.stack[o],i,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:t}=this.p,n=[],r=(i,o)=>{if(!n.includes(i))return n.push(i),t.allActions(i,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-o;if(a>1){let l=s&65535,u=this.stack.length-a*3;if(u>=0&&t.getGoto(this.stack[u],l,!1)>=0)return a<<19|65536|l}}else{let a=r(s,o+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=t.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(n)))}reduceContext(t,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(n)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let n=new AD(this.curContext.tracker,t);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class AD{constructor(t,n){this.tracker=t,this.context=n,this.hash=t.strict?t.hash(n):0}}class x$e{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let n=t&65535,r=t>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Ev{constructor(t,n,r){this.stack=t,this.pos=n,this.index=r,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new Ev(t,n,n-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Ev(this.stack,this.pos,this.index)}}function jm(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let s=e.charCodeAt(r++),a=!1;if(s==126){o=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),o+=l,a)break;o*=46}n?n[i++]=o:n=new t(o)}return n}class lg{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const PD=new lg;class w$e{constructor(t,n){this.input=t,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=PD,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(t,n){let r=this.range,i=this.rangeIndex,o=this.pos+t;for(;o<r.from;){if(!i)return null;let s=this.ranges[--i];o-=r.from-s.to,r=s}for(;n<0?o>r.to:o>=r.to;){if(i==this.ranges.length-1)return null;let s=this.ranges[++i];o+=s.from-r.to,r=s}return o}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let n of this.ranges)if(n.to>t)return Math.max(t,n.from);return this.end}peek(t){let n=this.chunkOff+t,r,i;if(n>=0&&n<this.chunk.length)r=this.pos+t,i=this.chunk.charCodeAt(n);else{let o=this.resolveOffset(t,1);if(o==null)return-1;if(r=o,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(t,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=r}acceptTokenTo(t,n){this.token.value=t,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),n=this.pos+t.length;this.chunk=n>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,n){if(n?(this.token=n,n.start=t,n.lookAhead=t+1,n.value=n.extended=-1):this.token=PD,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,n){if(t>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,n-this.chunkPos);if(t>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,n-this.chunk2Pos);if(t>=this.range.from&&n<=this.range.to)return this.input.read(t,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>t&&(r+=this.input.read(Math.max(i.from,t),Math.min(i.to,n)))}return r}}class ju{constructor(t,n){this.data=t,this.id=n}token(t,n){let{parser:r}=n.p;S$e(this.data,t,n,this.id,r.data,r.tokenPrecTable)}}ju.prototype.contextual=ju.prototype.fallback=ju.prototype.extend=!1;ju.prototype.fallback=ju.prototype.extend=!1;class wb{constructor(t,n={}){this.token=t,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function S$e(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;a&e[s];){let u=e[s+1];for(let d=s+3;d<u;d+=2)if((e[d+1]&a)>0){let p=e[d];if(l.allows(p)&&(t.token.value==-1||t.token.value==p||k$e(p,t.token.value,i,o))){t.acceptToken(p);break}}let c=t.next,f=0,h=e[s+2];if(t.next<0&&h>f&&e[u+h*3-3]==65535){s=e[u+h*3-1];continue e}for(;f<h;){let d=f+h>>1,p=u+d+(d<<1),m=e[p],v=e[p+1]||65536;if(c<m)h=d;else if(c>=v)f=d+1;else{s=e[p+2],t.advance();continue e}}break}}function ED(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function k$e(e,t,n,r){let i=ED(n,r,t);return i<0||ED(n,r,e)<i}const ur=typeof process<"u"&&CD&&/\bparse\b/.test(CD.LOG);let R1=null;function TD(e,t,n){let r=e.cursor(At.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}class O$e{constructor(t,n){this.fragments=t,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?TD(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?TD(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=r.children[i],s=this.start[n]+r.positions[i];if(s>t)return this.nextStart=s,null;if(o instanceof jt){if(s==t){if(s<this.safeFrom)return null;let a=s+o.length;if(a<=this.safeTo){let l=o.prop(Te.lookAhead);if(!l||a+l<this.fragment.to)return o}}this.index[n]++,s+o.length>=Math.max(this.safeFrom,t)&&(this.trees.push(o),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+o.length}}}class C$e{constructor(t,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(r=>new lg)}getActions(t){let n=0,r=null,{parser:i}=t.p,{tokenizers:o}=i,s=i.stateSlot(t.state,3),a=t.curContext?t.curContext.hash:0,l=0;for(let u=0;u<o.length;u++){if(!(1<<u&s))continue;let c=o[u],f=this.tokens[u];if(!(r&&!c.fallback)&&((c.contextual||f.start!=t.pos||f.mask!=s||f.context!=a)&&(this.updateCachedToken(f,c,t),f.mask=s,f.context=a),f.lookAhead>f.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let h=n;if(f.extended>-1&&(n=this.addActions(t,f.extended,f.end,n)),n=this.addActions(t,f.value,f.end,n),!c.extend&&(r=f,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return l&&t.setLookAhead(l),!r&&t.pos==this.stream.end&&(r=new lg,r.value=t.p.parser.eofTerm,r.start=r.end=t.pos,n=this.addActions(t,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let n=new lg,{pos:r,p:i}=t;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(t,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,t),r),t.value>-1){let{parser:o}=r.p;for(let s=0;s<o.specialized.length;s++)if(o.specialized[s]==t.value){let a=o.specializers[s](this.stream.read(t.start,t.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?t.extended=a>>1:t.value=a>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,n,r,i){for(let o=0;o<i;o+=3)if(this.actions[o]==t)return i;return this.actions[i++]=t,this.actions[i++]=n,this.actions[i++]=r,i}addActions(t,n,r,i){let{state:o}=t,{parser:s}=t.p,{data:a}=s;for(let l=0;l<2;l++)for(let u=s.stateSlot(o,l?2:1);;u+=3){if(a[u]==65535)if(a[u+1]==1)u=uo(a,u+2);else{i==0&&a[u+1]==2&&(i=this.putAction(uo(a,u+2),n,r,i));break}a[u]==n&&(i=this.putAction(uo(a,u+1),n,r,i))}return i}}class A$e{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new w$e(n,i),this.tokens=new C$e(t,this.stream),this.topTerm=t.top[1];let{from:o}=i[0];this.stacks=[Pv.start(this,t.top[0],o)],this.fragments=r.length&&this.stream.end-o>t.bufferLength*4?new O$e(r,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,n=this.minStackPos,r=this.stacks=[],i,o;if(this.bigReductionCount>300&&t.length==1){let[s]=t;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<t.length;s++){let a=t[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,t))continue;{i||(i=[],o=[]),i.push(a);let l=this.tokens.getMainToken(a);o.push(l.value,l.end)}}break}}if(!r.length){let s=i&&T$e(i);if(s)return ur&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw ur&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let s=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,o,r);if(s)return ur&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(r.length>s)for(r.sort((a,l)=>l.score-a.score);r.length>s;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let s=0;s<r.length-1;s++){let a=r[s];for(let l=s+1;l<r.length;l++){let u=r[l];if(a.sameState(u)||a.buffer.length>500&&u.buffer.length>500)if((a.score-u.score||a.buffer.length-u.buffer.length)>0)r.splice(l--,1);else{r.splice(s--,1);continue e}}}r.length>12&&(r.sort((s,a)=>a.score-s.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let s=1;s<r.length;s++)r[s].pos<this.minStackPos&&(this.minStackPos=r[s].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,n,r){let i=t.pos,{parser:o}=this,s=ur?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let u=t.curContext&&t.curContext.tracker.strict,c=u?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?o.getGoto(t.state,f.type.id):-1;if(h>-1&&f.length&&(!u||(f.prop(Te.contextHash)||0)==c))return t.useNode(f,h),ur&&console.log(s+this.stackID(t)+` (via reuse of ${o.getName(f.type.id)})`),!0;if(!(f instanceof jt)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof jt&&f.positions[0]==0)f=d;else break}}let a=o.stateSlot(t.state,4);if(a>0)return t.reduce(a),ur&&console.log(s+this.stackID(t)+` (via always-reduce ${o.getName(a&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let u=0;u<l.length;){let c=l[u++],f=l[u++],h=l[u++],d=u==l.length||!r,p=d?t:t.split(),m=this.tokens.mainToken;if(p.apply(c,f,m?m.start:p.pos,h),ur&&console.log(s+this.stackID(p)+` (via ${c&65536?`reduce of ${o.getName(c&65535)}`:"shift"} for ${o.getName(f)} @ ${i}${p==t?"":", split"})`),d)return!0;p.pos>i?n.push(p):r.push(p)}return!1}advanceFully(t,n){let r=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>r)return _D(t,n),!0}}runRecovery(t,n,r){let i=null,o=!1;for(let s=0;s<t.length;s++){let a=t[s],l=n[s<<1],u=n[(s<<1)+1],c=ur?this.stackID(a)+" -> ":"";if(a.deadEnd&&(o||(o=!0,a.restart(),ur&&console.log(c+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let f=a.split(),h=c;for(let d=0;d<10&&f.forceReduce()&&(ur&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));d++)ur&&(h=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))ur&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,r);this.stream.end>a.pos?(u==a.pos&&(u++,l=0),a.recoverByDelete(l,u),ur&&console.log(c+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),_D(a,r)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),jt.build({buffer:Ev.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let n=(R1||(R1=new WeakMap)).get(t);return n||R1.set(t,n=String.fromCodePoint(this.nextStackID++)),n+t}}function _D(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}class P$e{constructor(t,n,r){this.source=t,this.flags=n,this.disabled=r}allows(t){return!this.disabled||this.disabled[t]==0}}const D1=e=>e;class E$e{constructor(t){this.start=t.start,this.shift=t.shift||D1,this.reduce=t.reduce||D1,this.reuse=t.reuse||D1,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class Tv extends I9{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<t.repeatNodeCount;a++)n.push("");let r=Object.keys(t.topRules).map(a=>t.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function o(a,l,u){i[a].push([l,l.deserialize(String(u))])}if(t.nodeProps)for(let a of t.nodeProps){let l=a[0];typeof l=="string"&&(l=Te[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)o(c,l,a[u++]);else{let f=a[u+-c];for(let h=-c;h>0;h--)o(a[u++],l,f);u++}}}this.nodeSet=new KP(n.map((a,l)=>nr.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(l)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=T9;let s=jm(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(jD),this.states=jm(t.states,Uint32Array),this.data=jm(t.stateData),this.goto=jm(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new ju(s,a):a),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,n,r){let i=new A$e(this,t,n,r);for(let o of this.wrappers)i=o(i,t,n,r);return i}getGoto(t,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let o=i[n+1];;){let s=i[o++],a=s&1,l=i[o++];if(a&&r)return l;for(let u=o+(s>>1);o<u;o++)if(i[o]==t)return l;if(a)return-1}}hasAction(t,n){let r=this.data;for(let i=0;i<2;i++)for(let o=this.stateSlot(t,i?2:1),s;;o+=3){if((s=r[o])==65535)if(r[o+1]==1)s=r[o=uo(r,o+2)];else{if(r[o+1]==2)return uo(r,o+2);break}if(s==n||s==0)return uo(r,o+1)}return 0}stateSlot(t,n){return this.states[t*6+n]}stateFlag(t,n){return(this.stateSlot(t,0)&n)>0}validAction(t,n){return!!this.allActions(t,r=>r==n?!0:null)}allActions(t,n){let r=this.stateSlot(t,4),i=r?n(r):void 0;for(let o=this.stateSlot(t,1);i==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=uo(this.data,o+2);else break;i=n(uo(this.data,o+1))}return i}nextStates(t){let n=[];for(let r=this.stateSlot(t,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=uo(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((o,s)=>s&1&&o==i)||n.push(this.data[r],i)}}return n}configure(t){let n=Object.assign(Object.create(Tv.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let r=this.topRules[t.top];if(!r)throw new RangeError(`Invalid top rule name ${t.top}`);n.top=r}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=t.tokenizers.find(o=>o.from==r);return i?i.to:r})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let o=t.specializers.find(a=>a.from==r.external);if(!o)return r;let s=Object.assign(Object.assign({},r),{external:o.to});return n.specializers[i]=jD(s),s})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let n=this.dynamicPrecedences;return n==null?0:n[t]||0}parseDialect(t){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(t)for(let o of t.split(" ")){let s=n.indexOf(o);s>=0&&(r[s]=!0)}let i=null;for(let o=0;o<n.length;o++)if(!r[o])for(let s=this.dialects[n[o]],a;(a=this.data[s++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new P$e(t,r,i)}static deserialize(t){return new Tv(t)}}function uo(e,t){return e[t]|e[t+1]<<16}function T$e(e){let t=null;for(let n of e){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function jD(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const zl=63,MD=64,_$e=1,j$e=2,nU=3,M$e=4,rU=5,I$e=6,N$e=7,iU=65,R$e=66,D$e=8,L$e=9,$$e=10,B$e=11,F$e=12,oU=13,z$e=19,W$e=20,U$e=29,H$e=33,V$e=34,q$e=47,K$e=0,fE=1,RO=2,Hd=3,DO=4;class ga{constructor(t,n,r){this.parent=t,this.depth=n,this.type=r,this.hash=(t?t.hash+t.hash<<8:0)+n+(n<<4)+r}}ga.top=new ga(null,-1,K$e);function mh(e,t){for(let n=0,r=t-e.pos-1;;r--,n++){let i=e.peek(r);if(Do(i)||i==-1)return n}}function LO(e){return e==32||e==9}function Do(e){return e==10||e==13}function sU(e){return LO(e)||Do(e)}function Ta(e){return e<0||sU(e)}const G$e=new E$e({start:ga.top,reduce(e,t){return e.type==Hd&&(t==W$e||t==V$e)?e.parent:e},shift(e,t,n,r){if(t==nU)return new ga(e,mh(r,r.pos),fE);if(t==iU||t==rU)return new ga(e,mh(r,r.pos),RO);if(t==zl)return e.parent;if(t==z$e||t==H$e)return new ga(e,0,Hd);if(t==oU&&e.type==DO)return e.parent;if(t==q$e){let i=/[1-9]/.exec(r.read(r.pos,n.pos));if(i)return new ga(e,e.depth+ +i[0],DO)}return e},hash(e){return e.hash}});function Sc(e,t,n=0){return e.peek(n)==t&&e.peek(n+1)==t&&e.peek(n+2)==t&&Ta(e.peek(n+3))}const Q$e=new wb((e,t)=>{if(e.next==-1&&t.canShift(MD))return e.acceptToken(MD);let n=e.peek(-1);if((Do(n)||n<0)&&t.context.type!=Hd){if(Sc(e,45))if(t.canShift(zl))e.acceptToken(zl);else return e.acceptToken(_$e,3);if(Sc(e,46))if(t.canShift(zl))e.acceptToken(zl);else return e.acceptToken(j$e,3);let r=0;for(;e.next==32;)r++,e.advance();(r<t.context.depth||r==t.context.depth&&t.context.type==fE&&(e.next!=45||!Ta(e.peek(1))))&&e.next!=-1&&!Do(e.next)&&e.next!=35&&e.acceptToken(zl,-r)}},{contextual:!0}),X$e=new wb((e,t)=>{if(t.context.type==Hd){e.next==63&&(e.advance(),Ta(e.next)&&e.acceptToken(N$e));return}if(e.next==45)e.advance(),Ta(e.next)&&e.acceptToken(t.context.type==fE&&t.context.depth==mh(e,e.pos-1)?M$e:nU);else if(e.next==63)e.advance(),Ta(e.next)&&e.acceptToken(t.context.type==RO&&t.context.depth==mh(e,e.pos-1)?I$e:rU);else{let n=e.pos;for(;;)if(LO(e.next)){if(e.pos==n)return;e.advance()}else if(e.next==33)aU(e);else if(e.next==38)$O(e);else if(e.next==42){$O(e);break}else if(e.next==39||e.next==34){if(hE(e,!0))break;return}else if(e.next==91||e.next==123){if(!Z$e(e))return;break}else{lU(e,!0,!1,0);break}for(;LO(e.next);)e.advance();if(e.next==58){if(e.pos==n&&t.canShift(U$e))return;let r=e.peek(1);Ta(r)&&e.acceptTokenTo(t.context.type==RO&&t.context.depth==mh(e,n)?R$e:iU,n)}}},{contextual:!0});function Y$e(e){return e>32&&e<127&&e!=34&&e!=37&&e!=44&&e!=60&&e!=62&&e!=92&&e!=94&&e!=96&&e!=123&&e!=124&&e!=125}function ID(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function ND(e,t){return e.next==37?(e.advance(),ID(e.next)&&e.advance(),ID(e.next)&&e.advance(),!0):Y$e(e.next)||t&&e.next==44?(e.advance(),!0):!1}function aU(e){if(e.advance(),e.next==60){for(e.advance();;)if(!ND(e,!0)){e.next==62&&e.advance();break}}else for(;ND(e,!1););}function $O(e){for(e.advance();!Ta(e.next)&&_v(e.next)!="f";)e.advance()}function hE(e,t){let n=e.next,r=!1,i=e.pos;for(e.advance();;){let o=e.next;if(o<0)break;if(e.advance(),o==n)if(o==39)if(e.next==39)e.advance();else break;else break;else if(o==92&&n==34)e.next>=0&&e.advance();else if(Do(o)){if(t)return!1;r=!0}else if(t&&e.pos>=i+1024)return!1}return!r}function Z$e(e){for(let t=[],n=e.pos+1024;;)if(e.next==91||e.next==123)t.push(e.next),e.advance();else if(e.next==39||e.next==34){if(!hE(e,!0))return!1}else if(e.next==93||e.next==125){if(t[t.length-1]!=e.next-2)return!1;if(t.pop(),e.advance(),!t.length)return!0}else{if(e.next<0||e.pos>n||Do(e.next))return!1;e.advance()}}const J$e="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function _v(e){return e<33?"u":e>125?"s":J$e[e-33]}function L1(e,t){let n=_v(e);return n!="u"&&!(t&&n=="f")}function lU(e,t,n,r){if(_v(e.next)=="s"||(e.next==63||e.next==58||e.next==45)&&L1(e.peek(1),n))e.advance();else return!1;let i=e.pos;for(;;){let o=e.next,s=0,a=r+1;for(;sU(o);){if(Do(o)){if(t)return!1;a=0}else a++;o=e.peek(++s)}if(!(o>=0&&(o==58?L1(e.peek(s+1),n):o==35?e.peek(s-1)!=32:L1(o,n)))||!n&&a<=r||a==0&&!n&&(Sc(e,45,s)||Sc(e,46,s)))break;if(t&&_v(o)=="f")return!1;for(let u=s;u>=0;u--)e.advance();if(t&&e.pos>i+1024)return!1}return!0}const eBe=new wb((e,t)=>{if(e.next==33)aU(e),e.acceptToken(F$e);else if(e.next==38||e.next==42){let n=e.next==38?$$e:B$e;$O(e),e.acceptToken(n)}else e.next==39||e.next==34?(hE(e,!1),e.acceptToken(L$e)):lU(e,!1,t.context.type==Hd,t.context.depth)&&e.acceptToken(D$e)}),tBe=new wb((e,t)=>{let n=t.context.type==DO?t.context.depth:-1,r=e.pos;e:for(;;){let i=0,o=e.next;for(;o==32;)o=e.peek(++i);if(!i&&(Sc(e,45,i)||Sc(e,46,i))||!Do(o)&&(n<0&&(n=Math.max(t.context.depth+1,i)),i<n))break;for(;;){if(e.next<0)break e;let s=Do(e.next);if(e.advance(),s)continue e;r=e.pos}}e.acceptTokenTo(oU,r)}),nBe=N9({DirectiveName:W.keyword,DirectiveContent:W.attributeValue,"DirectiveEnd DocEnd":W.meta,QuotedLiteral:W.string,BlockLiteralHeader:W.special(W.string),BlockLiteralContent:W.content,Literal:W.content,"Key/Literal Key/QuotedLiteral":W.definition(W.propertyName),"Anchor Alias":W.labelName,Tag:W.typeName,Comment:W.lineComment,": , -":W.separator,"?":W.punctuation,"[ ]":W.squareBracket,"{ }":W.brace}),rBe=Tv.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:G$e,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[nBe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Q$e,X$e,eBe,tBe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),iBe=pv.define({name:"yaml",parser:rBe.configure({props:[$9.add({Stream:e=>{for(let t=e.node.resolve(e.pos,-1);t&&t.to>=e.pos;t=t.parent){if(t.name=="BlockLiteralContent"&&t.from<t.to)return e.baseIndentFor(t);if(t.name=="BlockLiteral")return e.baseIndentFor(t)+e.unit;if(t.name=="BlockSequence"||t.name=="BlockMapping")return e.column(t.firstChild.from,1);if(t.name=="QuotedLiteral")return null;if(t.name=="Literal"){let n=e.column(t.from,1);if(n==e.lineIndent(t.from,1))return n;if(t.to>e.pos)return null}}return null},FlowMapping:zR({closing:"}"}),FlowSequence:zR({closing:"]"})}),z9.add({"FlowMapping FlowSequence":DNe,"Item Pair BlockLiteral":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function oBe(){return new CNe(iBe)}function kt({label:e,helper:t,error:n,required:r,children:i}){const o=C.useId(),s=`${o}-input`,a=`${o}-helper`,l=`${o}-error`;return g.jsxs("div",{className:"flex flex-col gap-1.5",children:[g.jsxs("label",{htmlFor:s,className:"text-[12px] font-medium text-[var(--color-text)]",children:[e,r?g.jsx("span",{className:"ml-0.5 text-[var(--color-fail)]",children:"*"}):null]}),i({id:s,helperId:a,errorId:l}),n?g.jsx("p",{id:l,className:"text-[12px] text-[var(--color-fail)]",children:n}):t?g.jsx("p",{id:a,className:"text-[12px] text-[var(--color-text-muted)]",children:t}):null]})}const _f={enabled:!1,provider:"anthropic",mode:"auto",auth:{anthropic:"auto"},budget:{maxFileReads:25,maxContextBytes:5e4,maxDurationSeconds:180},cache:{enabled:!0},maxOutputTokens:16384},RD=[{value:"subscription",label:"Claude subscription (browser login)",helper:"Runs on your Claude plan. No API key needed. Sign in with `squad auth login`."},{value:"api-key",label:"Anthropic API key",helper:"Uses ANTHROPIC_API_KEY or the key saved in Secrets."},{value:"auto",label:"Automatic",helper:"Prefers your Claude login when signed in, otherwise falls back to the API key."}];function sBe(){const e=yi(),{toast:t}=Qr(),n=wt({queryKey:["config"],queryFn:()=>Me("/api/config")}),r=wP(),[i,o]=C.useState(null),[s,a]=C.useState(null);C.useEffect(()=>{n.data&&o(structuredClone(n.data))},[n.data]);const l=Ps({mutationFn:y=>Me("/api/config",{method:"PUT",body:JSON.stringify(y)}),onSuccess:()=>{a(null),e.invalidateQueries({queryKey:["config"]}),e.invalidateQueries({queryKey:["meta"]}),e.invalidateQueries({queryKey:rb}),t({tone:"success",title:"Config saved"})},onError:y=>a(y.message)}),u=C.useMemo(()=>i?Q_e.dump(i,{lineWidth:100,noRefs:!0,sortKeys:!1}):"",[i]);if(n.isPending||!i)return g.jsx(Ce,{title:"Config",description:"Visual editor for .squad/config.yaml.",children:g.jsx(Tn,{className:"h-96 w-full"})});const c=i.planner?{..._f,...i.planner,budget:{..._f.budget,...i.planner.budget}}:{..._f,enabled:!1};function f(y){o(x=>x&&{...x,planner:y})}const h=c.auth?.anthropic??"auto",d=RD.find(y=>y.value===h)?.helper??"",p=c.enabled&&c.provider==="anthropic",m=r.data?.loginCommand??"squad auth login",v=p&&h==="subscription"&&r.data?.login.present===!1,b=p&&h==="subscription"?r.data?.runtimeConflict??null:null;return g.jsxs(Ce,{title:"Config",description:"Edit workspace settings. Saving runs the same validation as the CLI. YAML tab is read-only — use your editor for raw edits.",children:[s?g.jsx(Ae,{tone:"danger",title:"Could not save",children:s}):null,g.jsx(bP,{tabs:[{id:"form",label:"Form",panel:g.jsxs("div",{className:"space-y-4",children:[g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--color-text)]",children:"Project"}),g.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[g.jsx(kt,{label:"Name",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,value:i.project.name,onChange:k=>o({...i,project:{...i.project,name:k.target.value}})})}),g.jsx(kt,{label:"Primary language",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,value:i.project.primaryLanguage??"",onChange:k=>o({...i,project:{...i.project,primaryLanguage:k.target.value}})})}),g.jsx("div",{className:"sm:col-span-2",children:g.jsx(kt,{label:"Project roots (comma-separated)",helper:"Paths relative to the workspace root.",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,className:"font-mono",value:(i.project.projectRoots??["."]).join(", "),onChange:k=>o({...i,project:{...i.project,projectRoots:k.target.value.split(",").map(w=>w.trim()).filter(Boolean)}})})})})]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Tracker"}),g.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[g.jsx("div",{className:"sm:col-span-2",children:g.jsx(kt,{label:"Type",children:({id:y,helperId:x})=>g.jsxs(La,{id:y,"aria-describedby":x,className:"mt-0 w-full",value:i.tracker.type,onChange:k=>o({...i,tracker:{...i.tracker,type:k.target.value}}),children:[g.jsx("option",{value:"none",children:"none"}),g.jsx("option",{value:"github",children:"github"}),g.jsx("option",{value:"jira",children:"jira"}),g.jsx("option",{value:"azure",children:"azure"})]})})}),g.jsx(kt,{label:"Workspace",helper:"Jira host or Azure org.",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,placeholder:"host (Jira) or org (Azure)",value:i.tracker.workspace??"",onChange:k=>o({...i,tracker:{...i.tracker,workspace:k.target.value||void 0}})})}),g.jsx(kt,{label:"Project",helper:"Azure project name if applicable.",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,placeholder:"Azure project name if applicable",value:i.tracker.project??"",onChange:k=>o({...i,tracker:{...i.tracker,project:k.target.value||void 0}})})})]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Naming"}),g.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[g.jsx("input",{type:"checkbox",checked:i.naming.includeTrackerId,onChange:y=>o({...i,naming:{...i.naming,includeTrackerId:y.target.checked}})}),"includeTrackerId"]}),g.jsxs("label",{className:"mt-2 flex items-center gap-2 text-sm",children:[g.jsx("input",{type:"checkbox",checked:i.naming.globalSequence,onChange:y=>o({...i,naming:{...i.naming,globalSequence:y.target.checked}})}),"globalSequence"]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Agents"}),g.jsx(kt,{label:"Agent ids",helper:"One id per line.",children:({id:y,helperId:x})=>g.jsx("textarea",{id:y,"aria-describedby":x,className:"w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-bg-elevated)] px-3 py-2 font-mono text-sm text-[var(--color-text)]",rows:4,placeholder:"One agent id per line",value:i.agents.join(`
|
|
441
441
|
`),onChange:k=>o({...i,agents:k.target.value.split(`
|
|
442
|
-
`).map(w=>w.trim()).filter(Boolean)})})})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Planner"}),g.jsxs("label",{className:"mb-2 flex items-center gap-2 text-sm",children:[g.jsx("input",{type:"checkbox",checked:c.enabled,onChange:y=>{y.target.checked?f({..._f,...i.planner,enabled:!0,budget:{..._f.budget,...i.planner?.budget}}):f({...c,enabled:!1})}}),"Enabled"]}),c.enabled&&g.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[g.jsx(kt,{label:"Provider",children:({id:y,helperId:x})=>g.jsxs(La,{id:y,"aria-describedby":x,className:"w-full",value:c.provider,onChange:k=>f({...c,provider:k.target.value}),children:[g.jsx("option",{value:"anthropic",children:"anthropic"}),g.jsx("option",{value:"openai",children:"openai"}),g.jsx("option",{value:"google",children:"google"})]})}),c.provider==="anthropic"?g.jsx(kt,{label:"Authentication",helper:d,children:({id:y,helperId:x})=>g.jsx(La,{id:y,"aria-describedby":x,className:"w-full",value:h,onChange:k=>f({...c,auth:{...c.auth,anthropic:k.target.value}}),children:RD.map(k=>g.jsx("option",{value:k.value,children:k.label},k.value))})}):null,v?g.jsx("div",{className:"sm:col-span-2",children:g.jsxs(Ae,{tone:"warning",title:"No Claude login detected",children:[g.jsx("p",{children:"Subscription mode is fine to save now — the next run will fail until you sign in."}),g.jsx(xP,{className:"mt-2",command:m})]})}):null,b?g.jsx("div",{className:"sm:col-span-2",children:g.jsx(Ae,{tone:"danger",title:"Subscription auth cannot use this runtime",children:b})}):null,g.jsx(kt,{label:"Max output tokens",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.maxOutputTokens??16384,onChange:k=>f({...c,maxOutputTokens:Number(k.target.value)||16384})})}),g.jsx("div",{className:"sm:col-span-2",children:g.jsx(kt,{label:"Model overrides (optional)",helper:"Provider → model id.",children:({id:y,helperId:x})=>g.jsxs("div",{id:y,"aria-describedby":x,className:"mt-0 grid gap-2 sm:grid-cols-3",children:[g.jsx(ct,{placeholder:"anthropic",className:"font-mono text-xs",value:c.modelOverride?.anthropic??"",onChange:k=>f({...c,modelOverride:{...c.modelOverride,anthropic:k.target.value||void 0}})}),g.jsx(ct,{placeholder:"openai",className:"font-mono text-xs",value:c.modelOverride?.openai??"",onChange:k=>f({...c,modelOverride:{...c.modelOverride,openai:k.target.value||void 0}})}),g.jsx(ct,{placeholder:"google",className:"font-mono text-xs",value:c.modelOverride?.google??"",onChange:k=>f({...c,modelOverride:{...c.modelOverride,google:k.target.value||void 0}})})]})})}),g.jsx(kt,{label:"Budget: max file reads",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.budget.maxFileReads,onChange:k=>f({...c,budget:{...c.budget,maxFileReads:Number(k.target.value)||1}})})}),g.jsx(kt,{label:"Max context bytes",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.budget.maxContextBytes,onChange:k=>f({...c,budget:{...c.budget,maxContextBytes:Number(k.target.value)||1}})})}),g.jsx(kt,{label:"Max duration (sec)",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.budget.maxDurationSeconds,onChange:k=>f({...c,budget:{...c.budget,maxDurationSeconds:Number(k.target.value)||1}})})}),g.jsxs("label",{className:"flex items-center gap-2 text-sm sm:col-span-2",children:[g.jsx("input",{type:"checkbox",checked:c.cache?.enabled!==!1,onChange:y=>f({...c,cache:{enabled:y.target.checked}})}),"Prompt cache enabled"]})]})]}),g.jsx("div",{className:"flex justify-end",children:g.jsx(fe,{type:"button",disabled:!!b,onClick:()=>l.mutate({...i,planner:c}),loading:l.isPending,children:"Save changes"})})]})},{id:"yaml",label:"YAML",panel:g.jsx("div",{className:"overflow-hidden rounded-lg border border-[var(--color-border)]",children:g.jsx(tU,{value:u,height:"min(60vh, 480px)",theme:"dark",extensions:[oBe()],editable:!1})})}]})]})}async function Mm(e){const t=sessionStorage.getItem("squad.console.token");if(!t)throw new kr;const n=await fetch(e,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"}});if(n.status===401)throw new kr;return await n.json()}function Ml({label:e,helper:t,display:n,onSave:r}){const[i,o]=C.useState(!1),[s,a]=C.useState("");return i?g.jsx(kt,{label:e,helper:t,children:({id:l,helperId:u})=>g.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[g.jsx(ct,{id:l,"aria-describedby":u,type:"password",className:"flex-1",value:s,onChange:c=>a(c.target.value),autoComplete:"off"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>{r(s),o(!1),a("")},children:"Save"}),g.jsx(fe,{type:"button",variant:"secondary",onClick:()=>{o(!1),a("")},children:"Cancel"})]})]})}):g.jsxs("div",{children:[g.jsx("div",{className:"text-[12px] font-medium text-[var(--color-text)]",children:e}),g.jsx("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:t}),g.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[g.jsx("code",{className:"max-w-full break-all rounded bg-[var(--color-surface)] px-2 py-1 text-sm",children:n??"—"}),g.jsx(fe,{type:"button",variant:"secondary",onClick:()=>{a(""),o(!0)},children:"Edit"})]})]})}function aBe({auth:e,storedToken:t,onRemoveToken:n,removing:r}){const i=wTe();if(e.provider!=="anthropic")return null;if(e.resolved?.mode==="api-key")return g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-2 text-sm font-semibold",children:"Claude account"}),g.jsxs("p",{className:"text-[13px] text-[var(--color-text-muted)]",children:["Using an Anthropic API key. Switch to your Claude subscription in"," ",g.jsx(vt,{to:"/config",className:"text-[var(--color-accent)] underline",children:"Config"}),"."]})]});const o=STe(e),s=kTe(e),a=OTe(e),l=e.login.hint==="oauth-token-env"&&t!==null;return g.jsxs(He,{variant:"default",children:[g.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[g.jsx("h2",{className:"text-sm font-semibold",children:"Claude account"}),g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:i.isPending,onClick:()=>i.mutate(),children:"Check again"})]}),o?g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]",children:[g.jsx(Ee,{tone:"success",dot:!0,children:"Signed in"}),i.isPending?g.jsxs("span",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[g.jsx(Yd,{}),"Checking…"]}):g.jsx("span",{className:"text-[var(--color-text)]",children:a??e.resolved?.credentialHint??"—"})]}),e.apiKeySource?g.jsxs("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:["apiKeySource: ",e.apiKeySource]}):null,s?g.jsx("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:s}):null,t?g.jsxs("div",{className:"pt-1",children:[g.jsx("div",{className:"text-[12px] font-medium text-[var(--color-text)]",children:"Stored token"}),g.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[g.jsx("code",{className:"rounded bg-[var(--color-surface)] px-2 py-1 text-sm",children:t}),g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:r,onClick:n,children:"Remove"})]}),l?g.jsx("p",{className:"mt-1 text-[12px] text-[var(--color-text-muted)]",children:"CLAUDE_CODE_OAUTH_TOKEN is set in the environment and takes precedence over this stored token."}):null]}):null]}):g.jsxs("div",{className:"space-y-2",children:[g.jsx(Ee,{tone:"muted",dot:!0,children:"Not signed in"}),g.jsx("p",{className:"text-[13px] text-[var(--color-text-muted)]",children:"No Claude login was found on this machine, so subscription runs have nothing to authenticate with. Sign in from your terminal — the console cannot open the browser login for you."}),g.jsx(xP,{command:e.loginCommand}),s?g.jsx("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:s}):null]})]})}function lBe(){const e=yi(),{toast:t}=Qr(),[n,r]=C.useState(null),[i,o]=C.useState(""),[s,a]=C.useState(""),[l,u]=C.useState(""),[c,f]=C.useState(""),[h,d]=C.useState(""),[p,m]=C.useState(null),[v,b]=C.useState(null),[y,x]=C.useState(null),[k,w]=C.useState(null),[S,O]=C.useState(null),[A,P]=C.useState(null),[M,j]=C.useState(null),E=wt({queryKey:["secrets"],queryFn:()=>Me("/api/secrets")}),D=wP(),R=C.useRef(!1),N=Ps({mutationFn:I=>Me("/api/secrets",{method:"PUT",body:JSON.stringify(I)}),onSuccess:()=>{r(null),e.invalidateQueries({queryKey:["secrets"]}),e.invalidateQueries({queryKey:rb}),t({tone:"success",title:"Secrets saved"})},onError:I=>r(I.message)});C.useEffect(()=>{!E.data||R.current||(R.current=!0,o(E.data.tracker.jira.host??""),a(E.data.tracker.jira.email??""),u(E.data.tracker.azure.organization??""),f(E.data.tracker.azure.project??""),d(E.data.tracker.github.host??""))},[E.data]);async function B(I,_){j(I),_(null);try{const K=await Mm(`/api/secrets/test/${I}`);if(K&&"ok"in K&&K.ok)_({ok:!0,message:`${K.modelCount} models accessible`});else{const Q=K.detail??"failed",te=K.status;_({ok:!1,message:te?`HTTP ${te} — ${Q}`:String(Q)})}}catch(K){_({ok:!1,message:K.message})}finally{j(null)}}async function F(){j("jira"),w(null);try{const I=await Mm("/api/secrets/test/jira");I.ok?w({ok:!0,message:"Jira reachable"}):w({ok:!1,message:I.detail?`Jira: ${I.detail}`:"unreachable"})}catch(I){w({ok:!1,message:I.message})}finally{j(null)}}async function $(){j("azure"),O(null);try{const I=await Mm("/api/secrets/test/azure");I.ok?O({ok:!0,message:"Azure DevOps reachable"}):O({ok:!1,message:I.detail?`Azure: ${I.detail}`:"unreachable"})}catch(I){O({ok:!1,message:I.message})}finally{j(null)}}async function z(){j("github"),P(null);try{const I=await Mm("/api/secrets/test/github");I.ok?P({ok:!0,message:"GitHub reachable"}):P({ok:!1,message:I.detail?`GitHub: ${I.detail}`:"unreachable"})}catch(I){P({ok:!1,message:I.message})}finally{j(null)}}if(E.isPending||!E.data)return g.jsx(Ce,{title:"Secrets",description:"Stored in .squad/secrets.yaml. Never committed.",children:g.jsx("p",{className:"text-[var(--color-text-muted)]",children:"Loading…"})});const T=E.data,q=D.data?.resolved?.mode==="subscription";return g.jsxs(Ce,{title:"Secrets",description:"Stored in .squad/secrets.yaml. Never committed.",children:[g.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Values are masked on read. For provider tests, save the key first, then test (the server only uses stored secrets)."}),n?g.jsx(Ae,{tone:"danger",children:n}):null,g.jsxs("div",{className:"space-y-4",children:[D.data?g.jsx(aBe,{auth:D.data,storedToken:T.planner.anthropicOauthToken,removing:N.isPending,onRemoveToken:()=>N.mutate({planner:{anthropicOauthToken:""}})}):null,g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Planner"}),g.jsxs("div",{className:"space-y-4",children:[g.jsx("div",{className:q?"opacity-60":void 0,children:g.jsx(Ml,{label:"Anthropic API key",helper:"Stored in .squad/secrets.yaml; never committed.",display:T.planner.anthropic,onSave:I=>N.mutate({planner:{anthropic:I}})})}),p?g.jsx(Ee,{tone:p.ok?"success":"danger",children:p.ok?"reachable":"failed"}):null,g.jsx("div",{className:"flex flex-wrap gap-2",children:g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:M==="anthropic",onClick:async()=>{m(null),await B("anthropic",m)},children:"Test connection"})}),g.jsx(Ml,{label:"OpenAI API key",helper:"Stored in .squad/secrets.yaml; never committed.",display:T.planner.openai,onSave:I=>N.mutate({planner:{openai:I}})}),v?g.jsx(Ee,{tone:v.ok?"success":"danger",children:v.ok?"reachable":"failed"}):null,g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:M==="openai",onClick:async()=>{b(null),await B("openai",b)},children:"Test connection"}),g.jsx(Ml,{label:"Google API key",helper:"Stored in .squad/secrets.yaml; never committed.",display:T.planner.google,onSave:I=>N.mutate({planner:{google:I}})}),y?g.jsx(Ee,{tone:y.ok?"success":"danger",children:y.ok?"reachable":"failed"}):null,g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:M==="google",onClick:async()=>{x(null),await B("google",x)},children:"Test connection"})]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Jira"}),g.jsxs("div",{className:"grid max-w-lg gap-3",children:[g.jsx(kt,{label:"Host",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:i,onChange:K=>o(K.target.value)})}),g.jsx(kt,{label:"Email",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:s,onChange:K=>a(K.target.value)})}),g.jsx(Ml,{label:"Token",helper:"Jira API token; stored in secrets.",display:T.tracker.jira.token,onSave:I=>N.mutate({tracker:{jira:{token:I}}})}),g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>N.mutate({tracker:{jira:{host:i,email:s}}}),loading:N.isPending,children:"Save Jira fields"}),g.jsx(fe,{type:"button",variant:"secondary",loading:M==="jira"||N.isPending,onClick:async()=>{w(null);try{await N.mutateAsync({tracker:{jira:{host:i,email:s}}}),await F()}catch{}},children:"Save and test"})]}),k?g.jsx(Ee,{tone:k.ok?"success":"danger",children:k.message}):null]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Azure"}),g.jsxs("div",{className:"grid max-w-lg gap-3",children:[g.jsx(kt,{label:"Organization",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:l,onChange:K=>u(K.target.value)})}),g.jsx(kt,{label:"Project",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:c,onChange:K=>f(K.target.value)})}),g.jsx(Ml,{label:"PAT",helper:"Azure DevOps personal access token.",display:T.tracker.azure.pat,onSave:I=>N.mutate({tracker:{azure:{pat:I}}})}),g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>N.mutate({tracker:{azure:{organization:l,project:c}}}),loading:N.isPending,children:"Save Azure fields"}),g.jsx(fe,{type:"button",variant:"secondary",loading:M==="azure"||N.isPending,onClick:async()=>{O(null);try{await N.mutateAsync({tracker:{azure:{organization:l,project:c}}}),await $()}catch{}},children:"Save and test"})]}),S?g.jsx(Ee,{tone:S.ok?"success":"danger",children:S.message}):null]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"GitHub"}),g.jsxs("p",{className:"mb-3 text-[12px] text-[var(--color-text-muted)]",children:["Owner and repo come from ",g.jsx("code",{children:"tracker.workspace"})," and ",g.jsx("code",{children:"tracker.project"})," on the Config page."]}),g.jsxs("div",{className:"grid max-w-lg gap-3",children:[g.jsx(kt,{label:"Host",helper:"Leave blank for github.com; set for GitHub Enterprise Server (e.g. ghes.example.com).",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",placeholder:"api.github.com",value:h,onChange:K=>d(K.target.value)})}),g.jsx(Ml,{label:"Personal access token",helper:"GitHub PAT with repo (or fine-grained Issues: read) scope.",display:T.tracker.github.pat,onSave:I=>N.mutate({tracker:{github:{pat:I}}})}),g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>N.mutate({tracker:{github:{host:h}}}),loading:N.isPending,children:"Save GitHub fields"}),g.jsx(fe,{type:"button",variant:"secondary",loading:M==="github"||N.isPending,onClick:async()=>{P(null);try{await N.mutateAsync({tracker:{github:{host:h}}}),await z()}catch{}},children:"Save and test"})]}),A?g.jsx(Ee,{tone:A.ok?"success":"danger",children:A.message}):null]})]})]})]})}function uBe(e){return e.toLowerCase().trim().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,80)}function cBe(){const e=_r(),{toast:t}=Qr(),[n,r]=C.useState(""),[i,o]=C.useState(""),[s,a]=C.useState(null),[l,u]=C.useState(null),[c,f]=C.useState(!1),[h,d]=C.useState(!1),[p,m]=C.useState(null),[v,b]=C.useState(""),[y,x]=C.useState(!0),[k,w]=C.useState(!1);C.useEffect(()=>{const A=setTimeout(()=>o(n),300);return()=>clearTimeout(A)},[n]),C.useEffect(()=>{let A=!1;return(async()=>{if(i!==void 0){f(!0),u(null);try{const P=sessionStorage.getItem("squad.console.token");if(!P)throw new kr;const M=await fetch(`/api/tracker/search?q=${encodeURIComponent(i)}`,{headers:{authorization:`Bearer ${P}`}});if(M.status===400){const E=await M.json();u(E.detail||E.error||"Search unavailable"),a(null);return}if(!M.ok){u(`HTTP ${M.status}`),a(null);return}const j=await M.json();if(A)return;j.ok&&j.results?a(j.results):(a([]),j.detail&&u(j.detail))}catch(P){A||u(P.message)}finally{A||f(!1)}}})(),()=>{A=!0}},[i]);function S(A){m(A),b(uBe(A.type??"imported")||"imported"),x(!0),d(!0)}async function O(){if(p){w(!0);try{const A=await Me("/api/tracker/import",{method:"POST",body:JSON.stringify({issueId:p.id,feature:v,withAttachments:y})});d(!1);const P=`${A.feature}/${A.id}`;t({tone:"success",title:"Imported as story",description:P}),e({to:"/stories/$feature/$id",params:{feature:A.feature,id:A.id}})}catch(A){u(A.message)}finally{w(!1)}}}return g.jsxs(Ce,{title:"Tracker",description:"Search Jira, Azure, or GitHub issues and import as stories. Configure the tracker in Config and credentials in Secrets.",children:[g.jsx("div",{className:"max-w-2xl",children:g.jsx(ct,{leftSlot:g.jsx(n0,{size:14}),placeholder:"Search issues…",value:n,onChange:A=>r(A.target.value)})}),l&&!c&&g.jsx(Ae,{tone:"warning",title:"Search",children:l}),c&&g.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((A,P)=>g.jsx(Tn,{className:"h-9"},P))}),!c&&s&&s.length===0&&!l&&g.jsx(Ae,{tone:"info",children:"No results. Try a different query or check tracker configuration."}),!c&&s&&s.length>0&&g.jsx("ul",{className:"overflow-hidden rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)]",children:s.map((A,P)=>g.jsxs("li",{className:`flex items-center gap-3 border-[var(--color-border)] px-3 py-[var(--space-row-y)] text-[13px] ${P>0?"border-t":""}`,children:[g.jsx("a",{href:A.url,target:"_blank",rel:"noreferrer",className:"w-24 shrink-0 font-mono text-[12px] text-[var(--color-accent)] hover:underline",children:A.id}),g.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--color-text)]",children:A.title}),g.jsxs(Ee,{tone:"default",children:[A.type??"—"," · ",A.status??"—"]}),g.jsx(fe,{type:"button",size:"sm",onClick:()=>S(A),children:"Import"})]},A.id))}),g.jsxs("p",{className:"text-[12px] text-[var(--color-text-dim)]",children:["Configure the tracker in"," ",g.jsx(vt,{to:"/config",className:"text-[var(--color-accent)] underline",children:"Config"})," ","and credentials in"," ",g.jsx(vt,{to:"/secrets",className:"text-[var(--color-accent)] underline",children:"Secrets"}),"."]}),g.jsx(Tc,{open:h,onClose:()=>d(!1),title:"Import as story",footer:g.jsxs("div",{className:"flex w-full flex-wrap justify-end gap-2",children:[g.jsx(fe,{type:"button",variant:"secondary",onClick:()=>d(!1),children:"Cancel"}),g.jsx(fe,{type:"button",onClick:O,disabled:k||!v.trim(),loading:k,children:"Import"})]}),children:g.jsxs("div",{className:"space-y-3 text-sm",children:[g.jsxs("p",{children:["Issue: ",p?.id," — ",p?.title]}),g.jsxs("label",{className:"block text-[var(--color-text-muted)]",children:["Feature slug",g.jsx(ct,{className:"mt-1",value:v,onChange:A=>b(A.target.value)})]}),g.jsxs("label",{className:"flex items-center gap-2",children:[g.jsx("input",{type:"checkbox",checked:y,onChange:A=>x(A.target.checked)}),"Download attachments"]})]})})]})}function fBe(e){return{ok:"var(--color-ok)",warn:"var(--color-warn)",fail:"var(--color-fail)",skip:"var(--color-text-dim)"}[e]}function hBe(e){return{ok:"success",warn:"warning",fail:"danger",skip:"default"}[e]}function dBe(){const[e,t]=C.useState(null),[n,r]=C.useState({}),[i,o]=C.useState(!1),[s,a]=C.useState(!1),[l,u]=C.useState(null);async function c(f){u(null),f?a(!0):o(!0);try{const h=await Me(f?"/api/doctor/fix":"/api/doctor",{method:f?"POST":"GET"});t(h)}catch(h){u(h.message)}finally{o(!1),a(!1)}}return g.jsxs(Ce,{title:"Doctor",description:"Graphical view of the same checks as `squad doctor`.",actions:g.jsx(fe,{type:"button",onClick:()=>void c(!1),loading:i,leftIcon:g.jsx(lX,{size:14}),children:"Run checks"}),children:[l?g.jsx(Ae,{tone:"danger",children:l}):null,i&&!e&&g.jsx("div",{className:"space-y-2",children:Array.from({length:12}).map((f,h)=>g.jsx(Tn,{className:"h-10 w-full"},h))}),e&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex flex-wrap gap-3 text-[13px]",children:[g.jsxs(Ee,{tone:"success",children:[e.summary.ok," ok"]}),g.jsxs(Ee,{tone:"warning",children:[e.summary.warn," warn"]}),g.jsxs(Ee,{tone:"danger",children:[e.summary.fail," fail"]}),g.jsxs(Ee,{tone:"default",children:[e.summary.skip," skip"]})]}),g.jsx(He,{variant:"flat",className:"p-0 overflow-hidden",children:g.jsx("ul",{children:e.checks.map(f=>g.jsxs("li",{className:"border-t border-[var(--color-border)] first:border-t-0",children:[g.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-3 py-3 text-left transition-colors hover:bg-[var(--gray-4)]",onClick:()=>r(h=>({...h,[f.id]:!h[f.id]})),children:[g.jsx("span",{"aria-hidden":!0,style:{background:fBe(f.status)},className:"mt-1 h-2 w-2 shrink-0 rounded-full"}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Ee,{tone:hBe(f.status),children:f.status}),g.jsx("span",{className:"text-[13px] font-medium",children:f.name})]}),n[f.id]&&f.detail?g.jsx("pre",{className:"mt-2 whitespace-pre-wrap break-words text-[12px] text-[var(--color-text-muted)]",children:f.detail}):null]})]}),f.fixable&&f.status==="warn"?g.jsx("div",{className:"px-3 pb-3",children:g.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>void c(!0),loading:s,leftIcon:g.jsx(TF,{size:14}),children:"Apply repair"})}):null]},f.id+f.name))})})]})]})}const DD=[{inputTokens:12e3,outputTokens:2e3,durationMs:14200},{inputTokens:8200,outputTokens:1100,durationMs:9400},{inputTokens:15e3,outputTokens:3200,durationMs:22e3}];function pBe(){const{design:e}=Ec({from:"/__design"}),{toast:t}=Qr(),n=r0();return e!=="1"?g.jsx(Ce,{title:"Design playground",description:"Internal only — add the query param to view.",children:g.jsxs(Ae,{tone:"info",children:["Append ",g.jsx(Wi,{children:"design=1"})," to the URL to open the internal design playground."]})}):g.jsxs(Ce,{title:"Design playground",description:"Internal: every primitive on one page. Visit /__design?design=1.",children:[g.jsx(He,{header:"Buttons",children:g.jsxs("div",{className:"flex flex-wrap gap-3",children:[g.jsx(fe,{children:"Primary"}),g.jsx(fe,{variant:"secondary",children:"Secondary"}),g.jsx(fe,{variant:"ghost",leftIcon:g.jsx(ZC,{size:14}),children:"Ghost"}),g.jsx(fe,{variant:"danger",leftIcon:g.jsx(zh,{size:14}),children:"Danger"}),g.jsx(fe,{loading:!0,children:"Loading"}),g.jsx(fe,{size:"sm",children:"Small"})]})}),g.jsx(He,{header:"Badges",children:g.jsx("div",{className:"flex flex-wrap gap-2",children:["default","success","warning","danger","info"].map(r=>g.jsx(Ee,{tone:r,dot:!0,children:r},r))})}),g.jsx(He,{header:"Callouts",children:g.jsx("div",{className:"space-y-2",children:["default","info","success","warning","danger"].map(r=>g.jsxs(Ae,{tone:r,title:`${r} callout`,children:["This is the body of a ",r," callout."]},r))})}),g.jsx(He,{header:"Inputs",children:g.jsxs("div",{className:"space-y-3",children:[g.jsx(kt,{label:"Name",helper:"Lowercase only.",children:({id:r,helperId:i})=>g.jsx(ct,{id:r,"aria-describedby":i,placeholder:"story-id"})}),g.jsx(kt,{label:"Search",helper:"Optional.",children:({id:r})=>g.jsx(ct,{id:r,leftSlot:g.jsx(n0,{size:14}),placeholder:"Find issues…"})}),g.jsxs(La,{defaultValue:"anthropic",children:[g.jsx("option",{value:"anthropic",children:"Anthropic"}),g.jsx("option",{value:"openai",children:"OpenAI"}),g.jsx("option",{value:"google",children:"Google"})]})]})}),g.jsx(He,{header:"Toast & Confirm",children:g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{onClick:()=>t({title:"Saved",tone:"success"}),children:"Show toast"}),g.jsx(fe,{variant:"danger",onClick:async()=>{const r=await n({title:"Delete?",description:"This cannot be undone.",tone:"danger"});t({title:r?"Confirmed":"Cancelled"})},children:"Confirm…"})]})}),g.jsxs(He,{header:"Tabs / Skeleton / Spinner / Kbd / Tooltip / IconButton",children:[g.jsx(bP,{tabs:[{id:"one",label:"Tab one",panel:g.jsx("p",{children:"Panel one"})},{id:"two",label:"Tab two",panel:g.jsx(Tn,{className:"h-9 w-1/2"})}]}),g.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[g.jsx(Yd,{}),g.jsx(Wi,{children:"⌘"}),g.jsx(Wi,{children:"K"}),g.jsx(Wg,{label:"Hello",children:g.jsx("span",{className:"text-sm",children:"Hover me"})}),g.jsx(Nk,{icon:g.jsx(zh,{size:14}),label:"Trash"})]})]}),g.jsx(He,{header:"Charts (sample data)",children:g.jsxs("div",{className:"flex flex-wrap items-center gap-6",children:[g.jsx(nP,{ratio:.74}),g.jsx("div",{className:"min-w-0 flex-1 basis-[min(100%,240px)]",children:g.jsx(xz,{runs:DD})}),g.jsx("div",{className:"min-w-0 flex-1 basis-[min(100%,240px)]",children:g.jsx(bz,{runs:DD})})]})})]})}function mBe(e){const t=e.plannerRuntime?.kind;return t==="agent-sdk"?"Agent SDK":t==="vercel"?"Vercel":"—"}function gBe({mode:e}){return e?g.jsx(Ee,{tone:e==="subscription"?"info":"muted",title:e,children:e==="subscription"?"sub":"key"}):g.jsx("span",{className:"text-[var(--color-text-muted)]",children:"—"})}function yBe(){const e=_r(),t=wt({queryKey:["runs"],queryFn:()=>Me("/api/runs")});if(t.isPending)return g.jsx(Ce,{title:"Runs",description:"The last 20 planner runs on this project.",children:g.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((r,i)=>g.jsx(Tn,{className:"h-9 w-full"},i))})});if(t.isError)return g.jsx(Ce,{title:"Runs",description:"The last 20 planner runs on this project.",children:g.jsx(Ae,{tone:"danger",children:t.error.message})});const n=t.data??[];return g.jsx(Ce,{title:"Runs",description:"The last 20 planner runs on this project.",children:n.length===0?g.jsxs(Ae,{tone:"info",title:"No runs yet",children:[g.jsx("p",{className:"mb-4 text-[13px] text-[var(--color-text-muted)]",children:"Go to Generate to start one."}),g.jsx(vt,{to:"/generate",children:g.jsx(fe,{type:"button",variant:"primary",children:"Open Generate"})})]}):g.jsx("div",{className:"overflow-auto rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)]",children:g.jsxs("table",{className:"w-full min-w-[940px] table-fixed border-collapse text-left text-[13px]",children:[g.jsx("thead",{className:"bg-[var(--gray-2)] text-[var(--color-text-muted)]",children:g.jsxs("tr",{children:[g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[10rem]",children:"Started"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[220px]",children:"Feature / story"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium",children:"Model"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[6rem]",children:"Runtime"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[5rem]",children:"Auth"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium tabular text-right w-[5rem]",children:"Duration"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium tabular text-right w-[6rem]",children:"Tokens"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium tabular text-right w-[5rem]",children:"Cache"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[7rem]",children:"Validation"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[6rem]",children:"Status"})]})}),g.jsx("tbody",{children:n.map((r,i)=>{const o=r.stats?.inputTokens??0,s=r.stats?.outputTokens??0,a=o+s,l=r.stats?.cacheHitRatio!=null?Math.round(r.stats.cacheHitRatio*100):null,u=Math.max(1,Math.round(r.durationMs/1e3)),c=r.validation?.issuesCount??0,f=r.success?"success":r.partial?"warning":"danger";return g.jsxs("tr",{"aria-label":`Run ${r.runId}`,tabIndex:0,role:"link",onClick:()=>void e({to:"/runs/$runId",params:{runId:r.runId},search:{tab:"plan"}}),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&e({to:"/runs/$runId",params:{runId:r.runId},search:{tab:"plan"}})},className:`${i>0?"border-t border-[var(--color-border)] ":""}cursor-pointer transition-colors hover:bg-[var(--gray-3)]`,children:[g.jsx("td",{className:"truncate px-3 py-[var(--space-row-y)] text-[var(--color-text-muted)] tabular whitespace-nowrap",children:vBe(r.startedAt)}),g.jsxs("td",{className:"truncate px-3 py-[var(--space-row-y)] font-mono text-[12px]",children:[g.jsx("span",{title:`${r.feature}/${r.storyId}`,children:r.feature})," ",g.jsx("span",{className:"text-[var(--color-text-muted)]",children:"/"})," ",g.jsx("span",{children:r.storyId})]}),g.jsx("td",{className:"truncate px-3 py-[var(--space-row-y)] font-mono text-[12px] text-[var(--color-text-muted)]",children:r.model}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:mBe(r)}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:g.jsx(gBe,{mode:r.authMode})}),g.jsxs("td",{className:"px-3 py-[var(--space-row-y)] tabular text-right",children:[u,"s"]}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)] tabular text-right",children:a}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)] tabular text-right",children:l!=null?`${l}%`:"—"}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:g.jsxs(vt,{to:"/runs/$runId",params:{runId:r.runId},search:{tab:"issues"},onClick:h=>h.stopPropagation(),className:`${c?"font-medium text-[var(--color-accent)] hover:underline":"text-[var(--color-text-muted)] hover:underline"}`,children:[c," ",c===1?"issue":"issues"]})}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:g.jsx(Ee,{tone:f,children:r.success?"success":r.partial?"partial":"failed"})})]},r.runId)})})]})})})}function vBe(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}const bBe=8192;function xBe(e){return e instanceof Error&&/\b404\b/.test(e.message)}function wBe(e){const t=e.toLowerCase();return t==="openai"||t==="google"||t==="anthropic"?t:"anthropic"}function uU(e){return e.slice(0,8)}function cU(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function fU(e){const t=e.stats,n=t?.inputTokens??0,r=t?.outputTokens??0,i=n+r,o=Math.max(Math.ceil(i*1.15),bBe),s={maxFileReads:500,maxContextBytes:4194304,maxDurationSeconds:3600},a=e.model?{provider:wBe(e.provider),model:e.model,runtimeKind:e.plannerRuntime?.kind??"agent-sdk",cacheEnabled:e.cacheEnabled??!0,scoutEnabled:!0,validationEnabled:!0,budgetCaps:s,providerOptions:e.providerOptionsSnapshot}:null,l=Number.isFinite(Date.parse(e.startedAt))?Date.parse(e.startedAt):Date.now(),u=e.authMode?{mode:e.authMode}:null;return{...Xy,phase:"streaming",runId:e.runId,feature:e.feature,storyId:e.storyId,mode:"api",startedAtMs:l,runtime:a,auth:u,budget:a?{caps:s,fileReadsCompleted:0,contextBytesApprox:0}:{caps:null,fileReadsCompleted:0,contextBytesApprox:0},tokens:{input:n,output:r,sum:i,ceiling:o,perTurn:[]},cacheHitPct:t?.cacheHitRatio!=null?Math.round(t.cacheHitRatio*100):null,cacheHitPctPerTurn:[],planFile:e.planFile,turn:t?.turns??0,activities:[],tools:[],thinking:{blocks:[]},scout:{selected:null,reasoning:null},validation:[],assistantMd:"",error:null}}function SBe(e){const t=fU(e);let n="done";return!e.success&&e.partial?n="cancelled":e.success||(n="failed"),{...t,phase:n}}function kBe(e){return e.kind==="tool_call_completed"?{...e,isError:e.isError??!1}:e}function OBe({record:e,incompleteTimeline:t}){const{toast:n}=Qr();async function r(){try{await navigator.clipboard.writeText(e.runId),n({tone:"success",title:"Run ID copied"})}catch{n({tone:"warning",title:"Copy failed"})}}return g.jsxs("div",{className:"mb-6 flex flex-wrap items-start gap-4",children:[g.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsx(Ee,{tone:"default",title:"Truncated planner id",children:uU(e.runId)}),t?g.jsxs(Ee,{tone:"warning",children:["Run did not complete cleanly — last seen at ",cU(e.completedAt)]}):null,e.planFile?null:g.jsx(Ee,{tone:"default",children:"No plan file written"})]}),g.jsx("div",{className:"flex flex-wrap gap-3 text-[13px]",children:g.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[e.feature," / ",g.jsx("span",{className:"font-medium text-[var(--color-text)]",children:e.storyId})]})})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.planFile?g.jsx(vt,{to:"/plans/$feature/$planFile",params:{feature:e.feature,planFile:e.planFile},className:"btn-secondary inline-flex items-center rounded-[var(--radius-md)] px-3 py-1.5 text-[13px] font-medium",children:"Open plan"}):null,g.jsxs(vt,{to:"/stories/$feature/$id",params:{feature:e.feature,id:e.storyId},className:"btn-secondary inline-flex items-center gap-2 rounded-[var(--radius-md)] px-3 py-1.5 text-[13px] font-medium",children:[g.jsx(rX,{size:14,"aria-hidden":!0}),"Open intake"]}),g.jsx(fe,{type:"button",variant:"secondary",leftIcon:g.jsx(QC,{size:14,"aria-hidden":!0}),onClick:()=>void r(),children:"Copy run ID"})]})]})}function CBe({record:e}){const t=`.squad/runs/${e.runId}.events.jsonl`;return g.jsxs("footer",{className:"mt-8 border-t border-[var(--color-border)] pt-4 text-[12px] text-[var(--color-text-muted)]",children:[g.jsxs("details",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--gray-2)] p-3",children:[g.jsx("summary",{className:"cursor-pointer select-none font-medium text-[var(--color-text)]",children:"Summary record (JSON)"}),g.jsx("pre",{className:"mt-3 max-h-48 overflow-auto rounded-md bg-[var(--gray-3)] p-3 font-mono text-[11px]",spellCheck:!1,children:JSON.stringify(e,null,2)})]}),g.jsxs("p",{className:"mt-3",children:["Timeline file on disk (may be gzipped after rotation): ",g.jsx("code",{className:"font-mono text-[var(--color-text)]",children:t})]})]})}function ABe(){const e=_r(),{toast:t}=Qr(),{runId:n}=Pc({from:"/runs/$runId"}),{tab:r}=Ec({from:"/runs/$runId"}),i=C.useRef(!1),[o,s]=C.useState(null),a=C.useCallback(O=>{s(O),window.setTimeout(()=>s(null),320)},[]),l=wt({queryKey:["runs","active",n],queryFn:()=>Me("/api/runs/active")}),u=wt({queryKey:["run-detail",n],enabled:!!n,queryFn:()=>Me(`/api/runs/${encodeURIComponent(n)}`),retry:!1}),[c,f]=C.useState(null),[h,d]=C.useState(!1),[p,m]=C.useState(!1),[v,b]=C.useState(!1);if(C.useEffect(()=>{i.current=!1},[n]),C.useEffect(()=>{!n||!l.data||l.data.some(O=>O.runId===n)&&(i.current||(i.current=!0,t({tone:"info",title:"Still active run",description:"This run is still active — opened the live view instead."}),e({to:"/generate",search:{feature:"",storyId:""}})))},[n,l.data,e,t]),C.useEffect(()=>{const O=u.data;if(!O||!n||i.current)return;m(!1),b(!1),d(!0),yTe();let A=fU(O);f(A);let P=!1;return(async()=>{try{let M=0;const j=2e3;let E=!1;for(;!P;){const D=await Me(`/api/runs/${encodeURIComponent(n)}/events?from=${M}&limit=${j}`),R=Date.now();for(const N of D.events){const B=kBe(N);A=m8(A,B,R),B.kind==="done"&&(E=!0)}if(P)return;if(f(A),M+=D.events.length,D.events.length<j)break}!P&&!E&&b(!0)}catch{if(P)return;m(!0),b(!1),f(SBe(O))}finally{P||d(!1)}})(),()=>{P=!0}},[u.data,n]),!n)return g.jsx(Ce,{title:"Run",description:"Missing run identifier.",children:g.jsx(Ae,{tone:"warning",children:"No run selected."})});if(u.error instanceof kr)return g.jsx(Ce,{title:"Run report",description:"Persisted planner run.",children:g.jsx(Ae,{tone:"warning",title:"Session expired",children:"Reopen squad console from your project."})});if(u.isPending||l.isPending)return g.jsx(Ce,{title:"Run",description:"Loading…",children:g.jsx(Tn,{className:"h-36 w-full"})});if(i.current&&l.data?.some(O=>O.runId===n))return null;if(u.error&&xBe(u.error)&&!l.isPending&&!(l.data??[]).some(O=>O.runId===n))return g.jsx(Ce,{title:"Run not found",description:"This planner run id is unknown to the server.",children:g.jsx(Ae,{tone:"warning",children:"Run not found — it may have rotated out (we keep the last 20 summaries on disk)."})});if(u.error)return g.jsx(Ce,{title:"Run report",description:"",children:g.jsx(Ae,{tone:"danger",children:u.error instanceof Error?u.error.message:String(u.error)})});const y=u.data,x=c;if(!y||!x)return g.jsx(Ce,{title:"Run",description:"",children:g.jsx(Tn,{className:"h-36 w-full"})});const k=Math.max(1,Math.round(y.durationMs/1e3)),w=r==="issues"||r==="telemetry"||r==="plan"?r:"plan",S=w==="issues"&&p?"plan":w;return g.jsxs(g.Fragment,{children:[h?g.jsx("div",{className:"fixed left-0 right-0 top-0 z-[var(--z-overlay)] h-1 overflow-hidden bg-[var(--gray-4)] motion-safe:animate-pulse",role:"progressbar","aria-label":"Loading event timeline",children:g.jsx("div",{className:"h-full w-1/2 bg-[var(--color-info)]"})}):null,g.jsxs(Ce,{title:`Run ${uU(y.runId)}`,description:`${y.feature} / ${y.storyId} — ${cU(y.completedAt)}`,children:[g.jsx(OBe,{record:y,incompleteTimeline:v}),p?g.jsx(Ae,{tone:"warning",title:"Event timeline unavailable",children:"The events JSONL could not be read (missing or unreadable after rotation). Showing summary statistics only — Activity and Issues replay are disabled."}):null,g.jsx(d8,{state:x,elapsedSec:k,frozen:!0}),g.jsx(p8,{runtime:x.runtime,auth:x.auth,telemetryPartial:!1}),g.jsx(g8,{stages:x.stages,onJump:a}),g.jsx(f8,{budget:x.budget,startedAtMs:x.startedAtMs,replayWallSec:k}),g.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[p?g.jsx(Ae,{tone:"info",children:"Activity feed requires a readable events file."}):g.jsx(c8,{rows:x.activities,jumpStage:o,replayed:!0}),g.jsx(h8,{state:x,replayed:!0,initialTab:S,hideIssuesTab:p})]}),g.jsx(CBe,{record:y})]})]})}const Qs=hK({component:DX});function Xs(e,t){return cl({getParentRoute:()=>Qs,path:e,component:t})}const PBe=Xs("/",GSe),EBe=Xs("/stories",YSe),TBe=cl({getParentRoute:()=>Qs,path:"/stories/$feature/$id",component:VEe}),_Be=Xs("/plans",QEe),jBe=cl({getParentRoute:()=>Qs,path:"/plans/$feature/$planFile",component:XEe}),MBe=cl({getParentRoute:()=>Qs,path:"/plans/$feature/diff",validateSearch:e=>({a:typeof e.a=="string"?e.a:"",b:typeof e.b=="string"?e.b:""}),component:tTe}),IBe=cl({getParentRoute:()=>Qs,path:"/generate",validateSearch:e=>({feature:typeof e.feature=="string"?e.feature:"",storyId:typeof e.storyId=="string"?e.storyId:""}),component:TTe}),NBe=Xs("/config",sBe),RBe=Xs("/secrets",lBe),DBe=Xs("/tracker",cBe);Xs("/doctor",dBe);const LBe=Xs("/runs",yBe),$Be=cl({getParentRoute:()=>Qs,path:"/runs/$runId",validateSearch:e=>{const t=typeof e.tab=="string"?e.tab:"";return{tab:t==="plan"||t==="issues"||t==="telemetry"?t:"plan"}},component:ABe}),BBe=cl({getParentRoute:()=>Qs,path:"/__design",validateSearch:e=>({design:typeof e.design=="string"?e.design:void 0}),component:pBe}),FBe=Qs.addChildren([PBe,EBe,TBe,_Be,jBe,MBe,IBe,NBe,RBe,DBe,LBe,$Be,BBe]),zBe=OK({routeTree:FBe});function WBe(){return g.jsx("div",{className:"flex min-h-screen flex-col bg-[var(--color-bg)] px-6 py-12 text-[var(--color-text)]",children:g.jsx(Ce,{title:"Session not available",description:"The console must be opened with a fresh link from the CLI.",children:g.jsxs(Ae,{tone:"warning",title:"Session expired",children:[g.jsxs("p",{children:["The console URL must include a fresh token from the terminal. Run ",g.jsx(Wi,{children:"squad console"})," again and open the link it prints (or paste ",g.jsx(Wi,{children:"?t=…"})," into the address bar)."]}),g.jsxs("p",{className:"mt-2 text-[var(--color-text-dim)]",children:["If you closed the terminal, start ",g.jsx(Wi,{children:"squad console"})," from your project root."]})]})})})}const UBe=new cV({defaultOptions:{queries:{staleTime:5e3,retry:1,refetchOnWindowFocus:!1}}}),BO=document.getElementById("root");if(!BO)throw new Error("missing #root");const HBe=EK();HBe?_w(BO).render(g.jsx(C.StrictMode,{children:g.jsx(fV,{client:UBe,children:g.jsx(kX,{children:g.jsxs(vX,{children:[g.jsx(PK,{router:zBe}),g.jsx(dX,{}),g.jsx(xX,{})]})})})})):_w(BO).render(g.jsx(C.StrictMode,{children:g.jsx(WBe,{})}));
|
|
442
|
+
`).map(w=>w.trim()).filter(Boolean)})})})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Planner"}),g.jsxs("label",{className:"mb-2 flex items-center gap-2 text-sm",children:[g.jsx("input",{type:"checkbox",checked:c.enabled,onChange:y=>{y.target.checked?f({..._f,...i.planner,enabled:!0,budget:{..._f.budget,...i.planner?.budget}}):f({...c,enabled:!1})}}),"Enabled"]}),c.enabled&&g.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[g.jsx(kt,{label:"Provider",children:({id:y,helperId:x})=>g.jsxs(La,{id:y,"aria-describedby":x,className:"w-full",value:c.provider,onChange:k=>f({...c,provider:k.target.value}),children:[g.jsx("option",{value:"anthropic",children:"anthropic"}),g.jsx("option",{value:"openai",children:"openai"}),g.jsx("option",{value:"google",children:"google"})]})}),c.provider==="anthropic"?g.jsx(kt,{label:"Authentication",helper:d,children:({id:y,helperId:x})=>g.jsx(La,{id:y,"aria-describedby":x,className:"w-full",value:h,onChange:k=>f({...c,auth:{...c.auth,anthropic:k.target.value}}),children:RD.map(k=>g.jsx("option",{value:k.value,children:k.label},k.value))})}):null,v?g.jsx("div",{className:"sm:col-span-2",children:g.jsxs(Ae,{tone:"warning",title:"No Claude login detected",children:[g.jsx("p",{children:"Subscription mode is fine to save now — the next run will fail until you sign in."}),g.jsx(xP,{className:"mt-2",command:m})]})}):null,b?g.jsx("div",{className:"sm:col-span-2",children:g.jsx(Ae,{tone:"danger",title:"Subscription auth cannot use this runtime",children:b})}):null,g.jsx(kt,{label:"Max output tokens",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.maxOutputTokens??16384,onChange:k=>f({...c,maxOutputTokens:Number(k.target.value)||16384})})}),g.jsx("div",{className:"sm:col-span-2",children:g.jsx(kt,{label:"Model overrides (optional)",helper:"Provider → model id.",children:({id:y,helperId:x})=>g.jsxs("div",{id:y,"aria-describedby":x,className:"mt-0 grid gap-2 sm:grid-cols-3",children:[g.jsx(ct,{placeholder:"anthropic",className:"font-mono text-xs",value:c.modelOverride?.anthropic??"",onChange:k=>f({...c,modelOverride:{...c.modelOverride,anthropic:k.target.value||void 0}})}),g.jsx(ct,{placeholder:"openai",className:"font-mono text-xs",value:c.modelOverride?.openai??"",onChange:k=>f({...c,modelOverride:{...c.modelOverride,openai:k.target.value||void 0}})}),g.jsx(ct,{placeholder:"google",className:"font-mono text-xs",value:c.modelOverride?.google??"",onChange:k=>f({...c,modelOverride:{...c.modelOverride,google:k.target.value||void 0}})})]})})}),g.jsx(kt,{label:"Budget: max file reads",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.budget.maxFileReads,onChange:k=>f({...c,budget:{...c.budget,maxFileReads:Number(k.target.value)||1}})})}),g.jsx(kt,{label:"Max context bytes",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.budget.maxContextBytes,onChange:k=>f({...c,budget:{...c.budget,maxContextBytes:Number(k.target.value)||1}})})}),g.jsx(kt,{label:"Max duration (sec)",children:({id:y,helperId:x})=>g.jsx(ct,{id:y,"aria-describedby":x,type:"number",value:c.budget.maxDurationSeconds,onChange:k=>f({...c,budget:{...c.budget,maxDurationSeconds:Number(k.target.value)||1}})})}),g.jsxs("label",{className:"flex items-center gap-2 text-sm sm:col-span-2",children:[g.jsx("input",{type:"checkbox",checked:c.cache?.enabled!==!1,onChange:y=>f({...c,cache:{enabled:y.target.checked}})}),"Prompt cache enabled"]})]})]}),g.jsx("div",{className:"flex justify-end",children:g.jsx(fe,{type:"button",disabled:!!b,onClick:()=>l.mutate({...i,planner:c}),loading:l.isPending,children:"Save changes"})})]})},{id:"yaml",label:"YAML",panel:g.jsx("div",{className:"overflow-hidden rounded-lg border border-[var(--color-border)]",children:g.jsx(tU,{value:u,height:"min(60vh, 480px)",theme:"dark",extensions:[oBe()],editable:!1})})}]})]})}async function Mm(e){const t=sessionStorage.getItem("squad.console.token");if(!t)throw new kr;const n=await fetch(e,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"}});if(n.status===401)throw new kr;return await n.json()}function Ml({label:e,helper:t,display:n,onSave:r}){const[i,o]=C.useState(!1),[s,a]=C.useState("");return i?g.jsx(kt,{label:e,helper:t,children:({id:l,helperId:u})=>g.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[g.jsx(ct,{id:l,"aria-describedby":u,type:"password",className:"flex-1",value:s,onChange:c=>a(c.target.value),autoComplete:"off"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>{r(s),o(!1),a("")},children:"Save"}),g.jsx(fe,{type:"button",variant:"secondary",onClick:()=>{o(!1),a("")},children:"Cancel"})]})]})}):g.jsxs("div",{children:[g.jsx("div",{className:"text-[12px] font-medium text-[var(--color-text)]",children:e}),g.jsx("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:t}),g.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[g.jsx("code",{className:"max-w-full break-all rounded bg-[var(--color-surface)] px-2 py-1 text-sm",children:n??"—"}),g.jsx(fe,{type:"button",variant:"secondary",onClick:()=>{a(""),o(!0)},children:"Edit"})]})]})}function aBe({auth:e,storedToken:t,onRemoveToken:n,removing:r}){const i=wTe();if(e.provider!=="anthropic")return null;if(e.resolved?.mode==="api-key")return g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-2 text-sm font-semibold",children:"Claude account"}),g.jsxs("p",{className:"text-[13px] text-[var(--color-text-muted)]",children:["Using an Anthropic API key. Switch to your Claude subscription in"," ",g.jsx(vt,{to:"/config",className:"text-[var(--color-accent)] underline",children:"Config"}),"."]})]});const o=STe(e),s=kTe(e),a=OTe(e),l=e.login.hint==="oauth-token-env"&&t!==null;return g.jsxs(He,{variant:"default",children:[g.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[g.jsx("h2",{className:"text-sm font-semibold",children:"Claude account"}),g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:i.isPending,onClick:()=>i.mutate(),children:"Check again"})]}),o?g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]",children:[g.jsx(Ee,{tone:"success",dot:!0,children:"Signed in"}),i.isPending?g.jsxs("span",{className:"flex items-center gap-2 text-[var(--color-text-muted)]",children:[g.jsx(Yd,{}),"Checking…"]}):g.jsx("span",{className:"text-[var(--color-text)]",children:a??e.resolved?.credentialHint??"—"})]}),e.apiKeySource?g.jsxs("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:["apiKeySource: ",e.apiKeySource]}):null,s?g.jsx("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:s}):null,t?g.jsxs("div",{className:"pt-1",children:[g.jsx("div",{className:"text-[12px] font-medium text-[var(--color-text)]",children:"Stored token"}),g.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[g.jsx("code",{className:"rounded bg-[var(--color-surface)] px-2 py-1 text-sm",children:t}),g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:r,onClick:n,children:"Remove"})]}),l?g.jsx("p",{className:"mt-1 text-[12px] text-[var(--color-text-muted)]",children:"CLAUDE_CODE_OAUTH_TOKEN is set in the environment and takes precedence over this stored token."}):null]}):null]}):g.jsxs("div",{className:"space-y-2",children:[g.jsx(Ee,{tone:"muted",dot:!0,children:"Not signed in"}),g.jsx("p",{className:"text-[13px] text-[var(--color-text-muted)]",children:"No Claude login was found on this machine, so subscription runs have nothing to authenticate with. Sign in from your terminal — the console cannot open the browser login for you."}),g.jsx(xP,{command:e.loginCommand}),s?g.jsx("p",{className:"text-[12px] text-[var(--color-text-muted)]",children:s}):null]})]})}function lBe(){const e=yi(),{toast:t}=Qr(),[n,r]=C.useState(null),[i,o]=C.useState(""),[s,a]=C.useState(""),[l,u]=C.useState(""),[c,f]=C.useState(""),[h,d]=C.useState(""),[p,m]=C.useState(null),[v,b]=C.useState(null),[y,x]=C.useState(null),[k,w]=C.useState(null),[S,O]=C.useState(null),[A,P]=C.useState(null),[M,j]=C.useState(null),E=wt({queryKey:["secrets"],queryFn:()=>Me("/api/secrets")}),D=wP(),R=C.useRef(!1),N=Ps({mutationFn:I=>Me("/api/secrets",{method:"PUT",body:JSON.stringify(I)}),onSuccess:()=>{r(null),e.invalidateQueries({queryKey:["secrets"]}),e.invalidateQueries({queryKey:rb}),t({tone:"success",title:"Secrets saved"})},onError:I=>r(I.message)});C.useEffect(()=>{!E.data||R.current||(R.current=!0,o(E.data.tracker.jira.host??""),a(E.data.tracker.jira.email??""),u(E.data.tracker.azure.organization??""),f(E.data.tracker.azure.project??""),d(E.data.tracker.github.host??""))},[E.data]);async function B(I,_){j(I),_(null);try{const K=await Mm(`/api/secrets/test/${I}`);if(K&&"ok"in K&&K.ok)_({ok:!0,message:`${K.modelCount} models accessible`});else{const Q=K.detail??"failed",te=K.status;_({ok:!1,message:te?`HTTP ${te} — ${Q}`:String(Q)})}}catch(K){_({ok:!1,message:K.message})}finally{j(null)}}async function F(){j("jira"),w(null);try{const I=await Mm("/api/secrets/test/jira");I.ok?w({ok:!0,message:"Jira reachable"}):w({ok:!1,message:I.detail?`Jira: ${I.detail}`:"unreachable"})}catch(I){w({ok:!1,message:I.message})}finally{j(null)}}async function $(){j("azure"),O(null);try{const I=await Mm("/api/secrets/test/azure");I.ok?O({ok:!0,message:"Azure DevOps reachable"}):O({ok:!1,message:I.detail?`Azure: ${I.detail}`:"unreachable"})}catch(I){O({ok:!1,message:I.message})}finally{j(null)}}async function z(){j("github"),P(null);try{const I=await Mm("/api/secrets/test/github");I.ok?P({ok:!0,message:"GitHub reachable"}):P({ok:!1,message:I.detail?`GitHub: ${I.detail}`:"unreachable"})}catch(I){P({ok:!1,message:I.message})}finally{j(null)}}if(E.isPending||!E.data)return g.jsx(Ce,{title:"Secrets",description:"Stored in .squad/secrets.yaml. Never committed.",children:g.jsx("p",{className:"text-[var(--color-text-muted)]",children:"Loading…"})});const T=E.data,q=D.data?.resolved?.mode==="subscription";return g.jsxs(Ce,{title:"Secrets",description:"Stored in .squad/secrets.yaml. Never committed.",children:[g.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Values are masked on read. For provider tests, save the key first, then test (the server only uses stored secrets)."}),n?g.jsx(Ae,{tone:"danger",children:n}):null,g.jsxs("div",{className:"space-y-4",children:[D.data?g.jsx(aBe,{auth:D.data,storedToken:T.planner.anthropicOauthToken,removing:N.isPending,onRemoveToken:()=>N.mutate({planner:{anthropicOauthToken:""}})}):null,g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Planner"}),g.jsxs("div",{className:"space-y-4",children:[g.jsx("div",{className:q?"opacity-60":void 0,children:g.jsx(Ml,{label:"Anthropic API key",helper:"Stored in .squad/secrets.yaml; never committed.",display:T.planner.anthropic,onSave:I=>N.mutate({planner:{anthropic:I}})})}),p?g.jsx(Ee,{tone:p.ok?"success":"danger",children:p.ok?"reachable":"failed"}):null,g.jsx("div",{className:"flex flex-wrap gap-2",children:g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:M==="anthropic",onClick:async()=>{m(null),await B("anthropic",m)},children:"Test connection"})}),g.jsx(Ml,{label:"OpenAI API key",helper:"Stored in .squad/secrets.yaml; never committed.",display:T.planner.openai,onSave:I=>N.mutate({planner:{openai:I}})}),v?g.jsx(Ee,{tone:v.ok?"success":"danger",children:v.ok?"reachable":"failed"}):null,g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:M==="openai",onClick:async()=>{b(null),await B("openai",b)},children:"Test connection"}),g.jsx(Ml,{label:"Google API key",helper:"Stored in .squad/secrets.yaml; never committed.",display:T.planner.google,onSave:I=>N.mutate({planner:{google:I}})}),y?g.jsx(Ee,{tone:y.ok?"success":"danger",children:y.ok?"reachable":"failed"}):null,g.jsx(fe,{type:"button",variant:"secondary",size:"sm",loading:M==="google",onClick:async()=>{x(null),await B("google",x)},children:"Test connection"})]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Jira"}),g.jsxs("div",{className:"grid max-w-lg gap-3",children:[g.jsx(kt,{label:"Host",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:i,onChange:K=>o(K.target.value)})}),g.jsx(kt,{label:"Email",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:s,onChange:K=>a(K.target.value)})}),g.jsx(Ml,{label:"Token",helper:"Jira API token; stored in secrets.",display:T.tracker.jira.token,onSave:I=>N.mutate({tracker:{jira:{token:I}}})}),g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>N.mutate({tracker:{jira:{host:i,email:s}}}),loading:N.isPending,children:"Save Jira fields"}),g.jsx(fe,{type:"button",variant:"secondary",loading:M==="jira"||N.isPending,onClick:async()=>{w(null);try{await N.mutateAsync({tracker:{jira:{host:i,email:s}}}),await F()}catch{}},children:"Save and test"})]}),k?g.jsx(Ee,{tone:k.ok?"success":"danger",children:k.message}):null]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"Azure"}),g.jsxs("div",{className:"grid max-w-lg gap-3",children:[g.jsx(kt,{label:"Organization",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:l,onChange:K=>u(K.target.value)})}),g.jsx(kt,{label:"Project",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",value:c,onChange:K=>f(K.target.value)})}),g.jsx(Ml,{label:"PAT",helper:"Azure DevOps personal access token.",display:T.tracker.azure.pat,onSave:I=>N.mutate({tracker:{azure:{pat:I}}})}),g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>N.mutate({tracker:{azure:{organization:l,project:c}}}),loading:N.isPending,children:"Save Azure fields"}),g.jsx(fe,{type:"button",variant:"secondary",loading:M==="azure"||N.isPending,onClick:async()=>{O(null);try{await N.mutateAsync({tracker:{azure:{organization:l,project:c}}}),await $()}catch{}},children:"Save and test"})]}),S?g.jsx(Ee,{tone:S.ok?"success":"danger",children:S.message}):null]})]}),g.jsxs(He,{variant:"default",children:[g.jsx("h2",{className:"mb-3 text-sm font-semibold",children:"GitHub"}),g.jsxs("p",{className:"mb-3 text-[12px] text-[var(--color-text-muted)]",children:["Owner and repo come from ",g.jsx("code",{children:"tracker.workspace"})," and ",g.jsx("code",{children:"tracker.project"})," on the Config page."]}),g.jsxs("div",{className:"grid max-w-lg gap-3",children:[g.jsx(kt,{label:"Host",helper:"Leave blank for github.com; set for GitHub Enterprise Server (e.g. ghes.example.com).",children:({id:I,helperId:_})=>g.jsx(ct,{id:I,"aria-describedby":_,className:"mt-0",placeholder:"api.github.com",value:h,onChange:K=>d(K.target.value)})}),g.jsx(Ml,{label:"Personal access token",helper:"GitHub PAT with repo (or fine-grained Issues: read) scope.",display:T.tracker.github.pat,onSave:I=>N.mutate({tracker:{github:{pat:I}}})}),g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{type:"button",onClick:()=>N.mutate({tracker:{github:{host:h}}}),loading:N.isPending,children:"Save GitHub fields"}),g.jsx(fe,{type:"button",variant:"secondary",loading:M==="github"||N.isPending,onClick:async()=>{P(null);try{await N.mutateAsync({tracker:{github:{host:h}}}),await z()}catch{}},children:"Save and test"})]}),A?g.jsx(Ee,{tone:A.ok?"success":"danger",children:A.message}):null]})]})]})]})}function uBe(e){return e.toLowerCase().trim().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,80)}function cBe(){const e=_r(),{toast:t}=Qr(),[n,r]=C.useState(""),[i,o]=C.useState(""),[s,a]=C.useState(null),[l,u]=C.useState(null),[c,f]=C.useState(!1),[h,d]=C.useState(!1),[p,m]=C.useState(null),[v,b]=C.useState(""),[y,x]=C.useState(!0),[k,w]=C.useState(!1);C.useEffect(()=>{const A=setTimeout(()=>o(n),300);return()=>clearTimeout(A)},[n]),C.useEffect(()=>{let A=!1;return(async()=>{if(i!==void 0){f(!0),u(null);try{const P=sessionStorage.getItem("squad.console.token");if(!P)throw new kr;const M=await fetch(`/api/tracker/search?q=${encodeURIComponent(i)}`,{headers:{authorization:`Bearer ${P}`}});if(M.status===400){const E=await M.json();u(E.detail||E.error||"Search unavailable"),a(null);return}if(!M.ok){u(`HTTP ${M.status}`),a(null);return}const j=await M.json();if(A)return;j.ok&&j.results?a(j.results):(a([]),j.detail&&u(j.detail))}catch(P){A||u(P.message)}finally{A||f(!1)}}})(),()=>{A=!0}},[i]);function S(A){m(A),b(uBe(A.type??"imported")||"imported"),x(!0),d(!0)}async function O(){if(p){w(!0);try{const A=await Me("/api/tracker/import",{method:"POST",body:JSON.stringify({issueId:p.id,feature:v,withAttachments:y})});d(!1);const P=`${A.feature}/${A.id}`;t({tone:"success",title:"Imported as story",description:P}),e({to:"/stories/$feature/$id",params:{feature:A.feature,id:A.id}})}catch(A){u(A.message)}finally{w(!1)}}}return g.jsxs(Ce,{title:"Tracker",description:"Search Jira, Azure, or GitHub issues and import as stories. Configure the tracker in Config and credentials in Secrets.",children:[g.jsx("div",{className:"max-w-2xl",children:g.jsx(ct,{leftSlot:g.jsx(n0,{size:14}),placeholder:"Search issues…",value:n,onChange:A=>r(A.target.value)})}),l&&!c&&g.jsx(Ae,{tone:"warning",title:"Search",children:l}),c&&g.jsx("div",{className:"space-y-2",children:Array.from({length:4}).map((A,P)=>g.jsx(Tn,{className:"h-9"},P))}),!c&&s&&s.length===0&&!l&&g.jsx(Ae,{tone:"info",children:"No results. Try a different query or check tracker configuration."}),!c&&s&&s.length>0&&g.jsx("ul",{className:"overflow-hidden rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)]",children:s.map((A,P)=>g.jsxs("li",{className:`flex items-center gap-3 border-[var(--color-border)] px-3 py-[var(--space-row-y)] text-[13px] ${P>0?"border-t":""}`,children:[g.jsx("a",{href:A.url,target:"_blank",rel:"noreferrer",className:"w-24 shrink-0 font-mono text-[12px] text-[var(--color-accent)] hover:underline",children:A.id}),g.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--color-text)]",children:A.title}),g.jsxs(Ee,{tone:"default",children:[A.type??"—"," · ",A.status??"—"]}),g.jsx(fe,{type:"button",size:"sm",onClick:()=>S(A),children:"Import"})]},A.id))}),g.jsxs("p",{className:"text-[12px] text-[var(--color-text-dim)]",children:["Configure the tracker in"," ",g.jsx(vt,{to:"/config",className:"text-[var(--color-accent)] underline",children:"Config"})," ","and credentials in"," ",g.jsx(vt,{to:"/secrets",className:"text-[var(--color-accent)] underline",children:"Secrets"}),"."]}),g.jsx(Tc,{open:h,onClose:()=>d(!1),title:"Import as story",footer:g.jsxs("div",{className:"flex w-full flex-wrap justify-end gap-2",children:[g.jsx(fe,{type:"button",variant:"secondary",onClick:()=>d(!1),children:"Cancel"}),g.jsx(fe,{type:"button",onClick:O,disabled:k||!v.trim(),loading:k,children:"Import"})]}),children:g.jsxs("div",{className:"space-y-3 text-sm",children:[g.jsxs("p",{children:["Issue: ",p?.id," — ",p?.title]}),g.jsxs("label",{className:"block text-[var(--color-text-muted)]",children:["Feature slug",g.jsx(ct,{className:"mt-1",value:v,onChange:A=>b(A.target.value)})]}),g.jsxs("label",{className:"flex items-center gap-2",children:[g.jsx("input",{type:"checkbox",checked:y,onChange:A=>x(A.target.checked)}),"Download attachments"]})]})})]})}function fBe(e){return{ok:"var(--color-ok)",warn:"var(--color-warn)",fail:"var(--color-fail)",skip:"var(--color-text-dim)"}[e]}function hBe(e){return{ok:"success",warn:"warning",fail:"danger",skip:"default"}[e]}function dBe(){const[e,t]=C.useState(null),[n,r]=C.useState({}),[i,o]=C.useState(!1),[s,a]=C.useState(!1),[l,u]=C.useState(null);async function c(f){u(null),f?a(!0):o(!0);try{const h=await Me(f?"/api/doctor/fix":"/api/doctor",{method:f?"POST":"GET"});t(h)}catch(h){u(h.message)}finally{o(!1),a(!1)}}return g.jsxs(Ce,{title:"Doctor",description:"Graphical view of the same checks as `squad doctor`.",actions:g.jsx(fe,{type:"button",onClick:()=>void c(!1),loading:i,leftIcon:g.jsx(lX,{size:14}),children:"Run checks"}),children:[l?g.jsx(Ae,{tone:"danger",children:l}):null,i&&!e&&g.jsx("div",{className:"space-y-2",children:Array.from({length:12}).map((f,h)=>g.jsx(Tn,{className:"h-10 w-full"},h))}),e&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex flex-wrap gap-3 text-[13px]",children:[g.jsxs(Ee,{tone:"success",children:[e.summary.ok," ok"]}),g.jsxs(Ee,{tone:"warning",children:[e.summary.warn," warn"]}),g.jsxs(Ee,{tone:"danger",children:[e.summary.fail," fail"]}),g.jsxs(Ee,{tone:"default",children:[e.summary.skip," skip"]})]}),g.jsx(He,{variant:"flat",className:"p-0 overflow-hidden",children:g.jsx("ul",{children:e.checks.map(f=>g.jsxs("li",{className:"border-t border-[var(--color-border)] first:border-t-0",children:[g.jsxs("button",{type:"button",className:"flex w-full items-start gap-3 px-3 py-3 text-left transition-colors hover:bg-[var(--gray-4)]",onClick:()=>r(h=>({...h,[f.id]:!h[f.id]})),children:[g.jsx("span",{"aria-hidden":!0,style:{background:fBe(f.status)},className:"mt-1 h-2 w-2 shrink-0 rounded-full"}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Ee,{tone:hBe(f.status),children:f.status}),g.jsx("span",{className:"text-[13px] font-medium",children:f.name})]}),n[f.id]&&f.detail?g.jsx("pre",{className:"mt-2 whitespace-pre-wrap break-words text-[12px] text-[var(--color-text-muted)]",children:f.detail}):null]})]}),f.fixable&&f.status==="warn"?g.jsx("div",{className:"px-3 pb-3",children:g.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>void c(!0),loading:s,leftIcon:g.jsx(TF,{size:14}),children:"Apply repair"})}):null]},f.id+f.name))})})]})]})}const DD=[{inputTokens:12e3,outputTokens:2e3,durationMs:14200},{inputTokens:8200,outputTokens:1100,durationMs:9400},{inputTokens:15e3,outputTokens:3200,durationMs:22e3}];function pBe(){const{design:e}=Ec({from:"/__design"}),{toast:t}=Qr(),n=r0();return e!=="1"?g.jsx(Ce,{title:"Design playground",description:"Internal only — add the query param to view.",children:g.jsxs(Ae,{tone:"info",children:["Append ",g.jsx(Wi,{children:"design=1"})," to the URL to open the internal design playground."]})}):g.jsxs(Ce,{title:"Design playground",description:"Internal: every primitive on one page. Visit /__design?design=1.",children:[g.jsx(He,{header:"Buttons",children:g.jsxs("div",{className:"flex flex-wrap gap-3",children:[g.jsx(fe,{children:"Primary"}),g.jsx(fe,{variant:"secondary",children:"Secondary"}),g.jsx(fe,{variant:"ghost",leftIcon:g.jsx(ZC,{size:14}),children:"Ghost"}),g.jsx(fe,{variant:"danger",leftIcon:g.jsx(zh,{size:14}),children:"Danger"}),g.jsx(fe,{loading:!0,children:"Loading"}),g.jsx(fe,{size:"sm",children:"Small"})]})}),g.jsx(He,{header:"Badges",children:g.jsx("div",{className:"flex flex-wrap gap-2",children:["default","success","warning","danger","info"].map(r=>g.jsx(Ee,{tone:r,dot:!0,children:r},r))})}),g.jsx(He,{header:"Callouts",children:g.jsx("div",{className:"space-y-2",children:["default","info","success","warning","danger"].map(r=>g.jsxs(Ae,{tone:r,title:`${r} callout`,children:["This is the body of a ",r," callout."]},r))})}),g.jsx(He,{header:"Inputs",children:g.jsxs("div",{className:"space-y-3",children:[g.jsx(kt,{label:"Name",helper:"Lowercase only.",children:({id:r,helperId:i})=>g.jsx(ct,{id:r,"aria-describedby":i,placeholder:"story-id"})}),g.jsx(kt,{label:"Search",helper:"Optional.",children:({id:r})=>g.jsx(ct,{id:r,leftSlot:g.jsx(n0,{size:14}),placeholder:"Find issues…"})}),g.jsxs(La,{defaultValue:"anthropic",children:[g.jsx("option",{value:"anthropic",children:"Anthropic"}),g.jsx("option",{value:"openai",children:"OpenAI"}),g.jsx("option",{value:"google",children:"Google"})]})]})}),g.jsx(He,{header:"Toast & Confirm",children:g.jsxs("div",{className:"flex flex-wrap gap-2",children:[g.jsx(fe,{onClick:()=>t({title:"Saved",tone:"success"}),children:"Show toast"}),g.jsx(fe,{variant:"danger",onClick:async()=>{const r=await n({title:"Delete?",description:"This cannot be undone.",tone:"danger"});t({title:r?"Confirmed":"Cancelled"})},children:"Confirm…"})]})}),g.jsxs(He,{header:"Tabs / Skeleton / Spinner / Kbd / Tooltip / IconButton",children:[g.jsx(bP,{tabs:[{id:"one",label:"Tab one",panel:g.jsx("p",{children:"Panel one"})},{id:"two",label:"Tab two",panel:g.jsx(Tn,{className:"h-9 w-1/2"})}]}),g.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[g.jsx(Yd,{}),g.jsx(Wi,{children:"⌘"}),g.jsx(Wi,{children:"K"}),g.jsx(Wg,{label:"Hello",children:g.jsx("span",{className:"text-sm",children:"Hover me"})}),g.jsx(Nk,{icon:g.jsx(zh,{size:14}),label:"Trash"})]})]}),g.jsx(He,{header:"Charts (sample data)",children:g.jsxs("div",{className:"flex flex-wrap items-center gap-6",children:[g.jsx(nP,{ratio:.74}),g.jsx("div",{className:"min-w-0 flex-1 basis-[min(100%,240px)]",children:g.jsx(xz,{runs:DD})}),g.jsx("div",{className:"min-w-0 flex-1 basis-[min(100%,240px)]",children:g.jsx(bz,{runs:DD})})]})})]})}function mBe(e){const t=e.plannerRuntime?.kind;return t==="agent-sdk"?"Agent SDK":t==="vercel"?"Vercel":"—"}function gBe({mode:e}){return e?g.jsx(Ee,{tone:e==="subscription"?"info":"muted",title:e,children:e==="subscription"?"sub":"key"}):g.jsx("span",{className:"text-[var(--color-text-muted)]",children:"—"})}function yBe(){const e=_r(),t=wt({queryKey:["runs"],queryFn:()=>Me("/api/runs")});if(t.isPending)return g.jsx(Ce,{title:"Runs",description:"The last 20 planner runs on this project.",children:g.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((r,i)=>g.jsx(Tn,{className:"h-9 w-full"},i))})});if(t.isError)return g.jsx(Ce,{title:"Runs",description:"The last 20 planner runs on this project.",children:g.jsx(Ae,{tone:"danger",children:t.error.message})});const n=t.data??[];return g.jsx(Ce,{title:"Runs",description:"The last 20 planner runs on this project.",children:n.length===0?g.jsxs(Ae,{tone:"info",title:"No runs yet",children:[g.jsx("p",{className:"mb-4 text-[13px] text-[var(--color-text-muted)]",children:"Go to Generate to start one."}),g.jsx(vt,{to:"/generate",children:g.jsx(fe,{type:"button",variant:"primary",children:"Open Generate"})})]}):g.jsx("div",{className:"overflow-auto rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)]",children:g.jsxs("table",{className:"w-full min-w-[940px] table-fixed border-collapse text-left text-[13px]",children:[g.jsx("thead",{className:"bg-[var(--gray-2)] text-[var(--color-text-muted)]",children:g.jsxs("tr",{children:[g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[10rem]",children:"Started"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[220px]",children:"Feature / story"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium",children:"Model"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[6rem]",children:"Runtime"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[5rem]",children:"Auth"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium tabular text-right w-[5rem]",children:"Duration"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium tabular text-right w-[6rem]",children:"Tokens"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium tabular text-right w-[5rem]",children:"Cache"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[7rem]",children:"Validation"}),g.jsx("th",{className:"border-b border-[var(--color-border)] px-3 py-2 font-medium w-[6rem]",children:"Status"})]})}),g.jsx("tbody",{children:n.map((r,i)=>{const o=r.stats?.inputTokens??0,s=r.stats?.outputTokens??0,a=o+s,l=r.stats?.cacheHitRatio!=null?Math.round(r.stats.cacheHitRatio*100):null,u=Math.max(1,Math.round(r.durationMs/1e3)),c=r.validation?.issuesCount??0,f=r.success?"success":r.partial?"warning":"danger";return g.jsxs("tr",{"aria-label":`Run ${r.runId}`,tabIndex:0,role:"link",onClick:()=>void e({to:"/runs/$runId",params:{runId:r.runId},search:{tab:"plan"}}),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&e({to:"/runs/$runId",params:{runId:r.runId},search:{tab:"plan"}})},className:`${i>0?"border-t border-[var(--color-border)] ":""}cursor-pointer transition-colors hover:bg-[var(--gray-3)]`,children:[g.jsx("td",{className:"truncate px-3 py-[var(--space-row-y)] text-[var(--color-text-muted)] tabular whitespace-nowrap",children:vBe(r.startedAt)}),g.jsxs("td",{className:"truncate px-3 py-[var(--space-row-y)] font-mono text-[12px]",children:[g.jsx("span",{title:`${r.feature}/${r.storyId}`,children:r.feature})," ",g.jsx("span",{className:"text-[var(--color-text-muted)]",children:"/"})," ",g.jsx("span",{children:r.storyId})]}),g.jsx("td",{className:"truncate px-3 py-[var(--space-row-y)] font-mono text-[12px] text-[var(--color-text-muted)]",children:r.model}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:mBe(r)}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:g.jsx(gBe,{mode:r.authMode})}),g.jsxs("td",{className:"px-3 py-[var(--space-row-y)] tabular text-right",children:[u,"s"]}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)] tabular text-right",children:a}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)] tabular text-right",children:l!=null?`${l}%`:"—"}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:g.jsxs(vt,{to:"/runs/$runId",params:{runId:r.runId},search:{tab:"issues"},onClick:h=>h.stopPropagation(),className:`${c?"font-medium text-[var(--color-accent)] hover:underline":"text-[var(--color-text-muted)] hover:underline"}`,children:[c," ",c===1?"issue":"issues"]})}),g.jsx("td",{className:"px-3 py-[var(--space-row-y)]",children:g.jsx(Ee,{tone:f,children:r.success?"success":r.partial?"partial":"failed"})})]},r.runId)})})]})})})}function vBe(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}const bBe=8192;function xBe(e){return e instanceof Error&&/\b404\b/.test(e.message)}function wBe(e){const t=e.toLowerCase();return t==="openai"||t==="google"||t==="anthropic"?t:"anthropic"}function uU(e){return e.slice(0,8)}function cU(e){const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function fU(e){const t=e.stats,n=t?.inputTokens??0,r=t?.outputTokens??0,i=n+r,o=Math.max(Math.ceil(i*1.15),bBe),s={maxFileReads:500,maxContextBytes:4194304,maxDurationSeconds:3600},a=e.model?{provider:wBe(e.provider),model:e.model,runtimeKind:e.plannerRuntime?.kind??"agent-sdk",cacheEnabled:e.cacheEnabled??!0,scoutEnabled:!0,validationEnabled:!0,budgetCaps:s,providerOptions:e.providerOptionsSnapshot}:null,l=Number.isFinite(Date.parse(e.startedAt))?Date.parse(e.startedAt):Date.now(),u=e.authMode?{mode:e.authMode}:null;return{...Xy,phase:"streaming",runId:e.runId,feature:e.feature,storyId:e.storyId,mode:"api",startedAtMs:l,runtime:a,auth:u,budget:a?{caps:s,fileReadsCompleted:0,contextBytesApprox:0}:{caps:null,fileReadsCompleted:0,contextBytesApprox:0},tokens:{input:n,output:r,sum:i,ceiling:o,perTurn:[]},cacheHitPct:t?.cacheHitRatio!=null?Math.round(t.cacheHitRatio*100):null,cacheHitPctPerTurn:[],planFile:e.planFile,turn:t?.turns??0,activities:[],tools:[],thinking:{blocks:[]},scout:{selected:null,reasoning:null},validation:[],assistantMd:"",error:null}}function SBe(e){const t=fU(e);let n="done";return!e.success&&e.partial?n="cancelled":e.success||(n="failed"),{...t,phase:n}}function kBe(e){return e.kind==="tool_call_completed"?{...e,isError:e.isError??!1}:e}function OBe({record:e,incompleteTimeline:t}){const{toast:n}=Qr();async function r(){try{await navigator.clipboard.writeText(e.runId),n({tone:"success",title:"Run ID copied"})}catch{n({tone:"warning",title:"Copy failed"})}}return g.jsxs("div",{className:"mb-6 flex flex-wrap items-start gap-4",children:[g.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g.jsx(Ee,{tone:"default",title:"Truncated planner id",children:uU(e.runId)}),t?g.jsxs(Ee,{tone:"warning",children:["Run did not complete cleanly — last seen at ",cU(e.completedAt)]}):null,e.planFile?null:g.jsx(Ee,{tone:"default",children:"No plan file written"})]}),g.jsx("div",{className:"flex flex-wrap gap-3 text-[13px]",children:g.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[e.feature," / ",g.jsx("span",{className:"font-medium text-[var(--color-text)]",children:e.storyId})]})})]}),g.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.planFile?g.jsx(vt,{to:"/plans/$feature/$planFile",params:{feature:e.feature,planFile:e.planFile},className:"btn-secondary inline-flex items-center rounded-[var(--radius-md)] px-3 py-1.5 text-[13px] font-medium",children:"Open plan"}):null,g.jsxs(vt,{to:"/stories/$feature/$id",params:{feature:e.feature,id:e.storyId},className:"btn-secondary inline-flex items-center gap-2 rounded-[var(--radius-md)] px-3 py-1.5 text-[13px] font-medium",children:[g.jsx(rX,{size:14,"aria-hidden":!0}),"Open intake"]}),g.jsx(fe,{type:"button",variant:"secondary",leftIcon:g.jsx(QC,{size:14,"aria-hidden":!0}),onClick:()=>void r(),children:"Copy run ID"})]})]})}function CBe({record:e}){const t=`.squad/runs/${e.runId}.events.jsonl`;return g.jsxs("footer",{className:"mt-8 border-t border-[var(--color-border)] pt-4 text-[12px] text-[var(--color-text-muted)]",children:[g.jsxs("details",{className:"rounded-lg border border-[var(--color-border)] bg-[var(--gray-2)] p-3",children:[g.jsx("summary",{className:"cursor-pointer select-none font-medium text-[var(--color-text)]",children:"Summary record (JSON)"}),g.jsx("pre",{className:"mt-3 max-h-48 overflow-auto rounded-md bg-[var(--gray-3)] p-3 font-mono text-[11px]",spellCheck:!1,children:JSON.stringify(e,null,2)})]}),g.jsxs("p",{className:"mt-3",children:["Timeline file on disk (may be gzipped after rotation): ",g.jsx("code",{className:"font-mono text-[var(--color-text)]",children:t})]})]})}function ABe(){const e=_r(),{toast:t}=Qr(),{runId:n}=Pc({from:"/runs/$runId"}),{tab:r}=Ec({from:"/runs/$runId"}),i=C.useRef(!1),[o,s]=C.useState(null),a=C.useCallback(O=>{s(O),window.setTimeout(()=>s(null),320)},[]),l=wt({queryKey:["runs","active",n],queryFn:()=>Me("/api/runs/active")}),u=wt({queryKey:["run-detail",n],enabled:!!n,queryFn:()=>Me(`/api/runs/${encodeURIComponent(n)}`),retry:!1}),[c,f]=C.useState(null),[h,d]=C.useState(!1),[p,m]=C.useState(!1),[v,b]=C.useState(!1);if(C.useEffect(()=>{i.current=!1},[n]),C.useEffect(()=>{!n||!l.data||l.data.some(O=>O.runId===n)&&(i.current||(i.current=!0,t({tone:"info",title:"Still active run",description:"This run is still active — opened the live view instead."}),e({to:"/generate",search:{feature:"",storyId:""}})))},[n,l.data,e,t]),C.useEffect(()=>{const O=u.data;if(!O||!n||i.current)return;m(!1),b(!1),d(!0),yTe();let A=fU(O);f(A);let P=!1;return(async()=>{try{let M=0;const j=2e3;let E=!1;for(;!P;){const D=await Me(`/api/runs/${encodeURIComponent(n)}/events?from=${M}&limit=${j}`),R=Date.now();for(const N of D.events){const B=kBe(N);A=m8(A,B,R),B.kind==="done"&&(E=!0)}if(P)return;if(f(A),M+=D.events.length,D.events.length<j)break}!P&&!E&&b(!0)}catch{if(P)return;m(!0),b(!1),f(SBe(O))}finally{P||d(!1)}})(),()=>{P=!0}},[u.data,n]),!n)return g.jsx(Ce,{title:"Run",description:"Missing run identifier.",children:g.jsx(Ae,{tone:"warning",children:"No run selected."})});if(u.error instanceof kr)return g.jsx(Ce,{title:"Run report",description:"Persisted planner run.",children:g.jsx(Ae,{tone:"warning",title:"Session expired",children:"Reopen squad console from your project."})});if(u.isPending||l.isPending)return g.jsx(Ce,{title:"Run",description:"Loading…",children:g.jsx(Tn,{className:"h-36 w-full"})});if(i.current&&l.data?.some(O=>O.runId===n))return null;if(u.error&&xBe(u.error)&&!l.isPending&&!(l.data??[]).some(O=>O.runId===n))return g.jsx(Ce,{title:"Run not found",description:"This planner run id is unknown to the server.",children:g.jsx(Ae,{tone:"warning",children:"Run not found — it may have rotated out (we keep the last 20 summaries on disk)."})});if(u.error)return g.jsx(Ce,{title:"Run report",description:"",children:g.jsx(Ae,{tone:"danger",children:u.error instanceof Error?u.error.message:String(u.error)})});const y=u.data,x=c;if(!y||!x)return g.jsx(Ce,{title:"Run",description:"",children:g.jsx(Tn,{className:"h-36 w-full"})});const k=Math.max(1,Math.round(y.durationMs/1e3)),w=r==="issues"||r==="telemetry"||r==="plan"?r:"plan",S=w==="issues"&&p?"plan":w;return g.jsxs(g.Fragment,{children:[h?g.jsx("div",{className:"fixed left-0 right-0 top-0 z-[var(--z-overlay)] h-1 overflow-hidden bg-[var(--gray-4)] motion-safe:animate-pulse",role:"progressbar","aria-label":"Loading event timeline",children:g.jsx("div",{className:"h-full w-1/2 bg-[var(--color-info)]"})}):null,g.jsxs(Ce,{title:`Run ${uU(y.runId)}`,description:`${y.feature} / ${y.storyId} — ${cU(y.completedAt)}`,children:[g.jsx(OBe,{record:y,incompleteTimeline:v}),p?g.jsx(Ae,{tone:"warning",title:"Event timeline unavailable",children:"The events JSONL could not be read (missing or unreadable after rotation). Showing summary statistics only — Activity and Issues replay are disabled."}):null,g.jsx(d8,{state:x,elapsedSec:k,frozen:!0}),g.jsx(p8,{runtime:x.runtime,auth:x.auth,telemetryPartial:!1}),g.jsx(g8,{stages:x.stages,onJump:a}),g.jsx(f8,{budget:x.budget,startedAtMs:x.startedAtMs,replayWallSec:k}),g.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[p?g.jsx(Ae,{tone:"info",children:"Activity feed requires a readable events file."}):g.jsx(c8,{rows:x.activities,jumpStage:o,replayed:!0}),g.jsx(h8,{state:x,replayed:!0,initialTab:S,hideIssuesTab:p})]}),g.jsx(CBe,{record:y})]})]})}const Qs=hK({component:DX});function Xs(e,t){return cl({getParentRoute:()=>Qs,path:e,component:t})}const PBe=Xs("/",GSe),EBe=Xs("/stories",YSe),TBe=cl({getParentRoute:()=>Qs,path:"/stories/$feature/$id",component:VEe}),_Be=Xs("/plans",QEe),jBe=cl({getParentRoute:()=>Qs,path:"/plans/$feature/$planFile",component:XEe}),MBe=cl({getParentRoute:()=>Qs,path:"/plans/$feature/diff",validateSearch:e=>({a:typeof e.a=="string"?e.a:"",b:typeof e.b=="string"?e.b:""}),component:tTe}),IBe=cl({getParentRoute:()=>Qs,path:"/generate",validateSearch:e=>({feature:typeof e.feature=="string"?e.feature:"",storyId:typeof e.storyId=="string"?e.storyId:""}),component:TTe}),NBe=Xs("/config",sBe),RBe=Xs("/secrets",lBe),DBe=Xs("/tracker",cBe),LBe=Xs("/doctor",dBe),$Be=Xs("/runs",yBe),BBe=cl({getParentRoute:()=>Qs,path:"/runs/$runId",validateSearch:e=>{const t=typeof e.tab=="string"?e.tab:"";return{tab:t==="plan"||t==="issues"||t==="telemetry"?t:"plan"}},component:ABe}),FBe=cl({getParentRoute:()=>Qs,path:"/__design",validateSearch:e=>({design:typeof e.design=="string"?e.design:void 0}),component:pBe}),zBe=Qs.addChildren([PBe,EBe,TBe,_Be,jBe,MBe,IBe,NBe,RBe,DBe,$Be,BBe,LBe,FBe]),WBe=OK({routeTree:zBe});function UBe(){return g.jsx("div",{className:"flex min-h-screen flex-col bg-[var(--color-bg)] px-6 py-12 text-[var(--color-text)]",children:g.jsx(Ce,{title:"Session not available",description:"The console must be opened with a fresh link from the CLI.",children:g.jsxs(Ae,{tone:"warning",title:"Session expired",children:[g.jsxs("p",{children:["The console URL must include a fresh token from the terminal. Run ",g.jsx(Wi,{children:"squad console"})," again and open the link it prints (or paste ",g.jsx(Wi,{children:"?t=…"})," into the address bar)."]}),g.jsxs("p",{className:"mt-2 text-[var(--color-text-dim)]",children:["If you closed the terminal, start ",g.jsx(Wi,{children:"squad console"})," from your project root."]})]})})})}const HBe=new cV({defaultOptions:{queries:{staleTime:5e3,retry:1,refetchOnWindowFocus:!1}}}),BO=document.getElementById("root");if(!BO)throw new Error("missing #root");const VBe=EK();VBe?_w(BO).render(g.jsx(C.StrictMode,{children:g.jsx(fV,{client:HBe,children:g.jsx(kX,{children:g.jsxs(vX,{children:[g.jsx(PK,{router:WBe}),g.jsx(dX,{}),g.jsx(xX,{})]})})})})):_w(BO).render(g.jsx(C.StrictMode,{children:g.jsx(UBe,{})}));
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="icon" href="/favicon.ico" sizes="any" />
|
|
8
8
|
<link rel="icon" href="/logo.svg" type="image/svg+xml" />
|
|
9
9
|
<title>squad console</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-BasslIze.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-DP-vFdYe.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squad-kit",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"author": "Momen Yasser <momenysr@gmail.com>",
|
|
5
5
|
"description": "Plan once, execute cheap. A token-efficient, 3-step SDD workflow CLI (stories → plans → implementation).",
|
|
6
6
|
"keywords": [
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"bugs": {
|
|
88
88
|
"url": "https://github.com/AzmSquad/squad-kit/issues"
|
|
89
89
|
},
|
|
90
|
-
"packageManager": "pnpm@
|
|
90
|
+
"packageManager": "pnpm@9.15.9"
|
|
91
91
|
}
|