yamlite 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -686
- package/dist/ui/assets/{ErdView-CWmAQgo6.js → ErdView-C-Kg8blN.js} +3 -3
- package/dist/ui/assets/MarkdownField-DbmIyR2F.js +32 -0
- package/dist/ui/assets/PageView-BZ2TyXNJ.js +1 -0
- package/dist/ui/assets/{index-emolmw-f.js → index-Bfy1b8dm.js} +32 -32
- package/dist/ui/assets/{load-BsZuQtRZ.js → load-iZmRMple.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/ui-embed/{PageView-Bptfb1IR.js → PageView-BtwLoyjq.js} +181 -167
- package/dist/ui-embed/embed.js +3224 -3224
- package/dist/ui-embed/{pageFrame-vCls4cAs.js → pageFrame-_gi-jKkG.js} +204 -197
- package/package.json +2 -1
- package/dist/ui/assets/MarkdownField-DI3OMg7I.js +0 -32
- package/dist/ui/assets/PageView-BsEhcE48.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MarkdownField-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MarkdownField-DbmIyR2F.js","./rolldown-runtime-XKyaHtl9.js","./theme-CMaLONsO.js","./PageView-BZ2TyXNJ.js","./access-DV6K5419.js","./ErdView-C-Kg8blN.js","./ErdView-DLioOiRN.css","./load-iZmRMple.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-XKyaHtl9.js";import{C as r,E as i,S as a,T as o,_ as s,a as c,b as l,c as u,d,f,g as p,h as m,i as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D,y as O}from"./theme-CMaLONsO.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var k=`yamlite-locale`;r(`custom-storage`,{getLocale:()=>{try{return localStorage.getItem(k)??void 0}catch{return}},setLocale:e=>{try{localStorage.setItem(k,e)}catch{}}});var A=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),j=n(((e,t)=>{t.exports=A()})),M=n((e=>{var t=j(),n=a(),r=D();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function o(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function s(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function c(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(s(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=s(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return u(a),e;if(o===r)return u(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=o;break}if(l===r){c=!0,r=a,n=o;break}l=l.sibling}if(!c){for(l=o.child;l;){if(l===n){c=!0,n=o,r=a;break}if(l===r){c=!0,r=o,n=a;break}l=l.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function p(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&p(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function m(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function h(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function g(e){var t=[null,null],n=m(e);return n===null||_(t,e,n.child,{foundSelf:!1}),t}function _(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&_(e,t,n.child,r))return!0;n=n.sibling}return!1}function v(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var y=null,b=null;function x(e,t,n){return e===n||e===t&&(y=e,!0)}function S(e,t,n){return e===n?(b=e,!1):e===t&&(b!==null&&(y=e),!0)}function C(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function w(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var T=Object.assign,E=Symbol.for(`react.element`),O=Symbol.for(`react.transitional.element`),k=Symbol.for(`react.portal`),A=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),ee=Symbol.for(`react.forward_ref`),I=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.legacy_hidden`),oe=Symbol.for(`react.memo_cache_sentinel`),se=Symbol.for(`react.view_transition`),ce=Symbol.for(`react.recoverable`),le=Symbol.iterator;function ue(e){return typeof e!=`object`||!e?null:(e=le&&e[le]||e[`@@iterator`],typeof e==`function`?e:null)}var de=Symbol.for(`react.client.reference`);function fe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case A:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case I:return`Suspense`;case te:return`SuspenseList`;case ie:return`Activity`;case se:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case k:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?fe(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return fe(e(t))}catch{}}return null}var pe=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,me=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he={pending:!1,data:null,method:null,action:null},ge=[],_e=-1;function ve(e){return{current:e}}function ye(e){0>_e||(e.current=ge[_e],ge[_e]=null,_e--)}function be(e,t){_e++,ge[_e]=e.current,e.current=t}var xe=ve(null),Se=ve(null),Ce=ve(null),we=ve(null);function Te(e,t){switch(be(Ce,t),be(Se,e),be(xe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Cp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Cp(t),e=wp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ye(xe),be(xe,e)}function Ee(){ye(xe),ye(Se),ye(Ce)}function De(e){var t=e.memoizedState;t!==null&&(bh._currentValue=t.memoizedState,be(we,e)),t=xe.current;var n=wp(t,e.type);t!==n&&(be(Se,e),be(xe,n))}function Oe(e){Se.current===e&&(ye(xe),ye(Se)),we.current===e&&(ye(we),bh._currentValue=he)}var ke,Ae;function je(e){if(ke===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ke=t&&t[1]||``,Ae=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ke+e+Ae}var Me=!1;function Ne(e,t){if(!e||Me)return``;Me=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -66,20 +66,20 @@ Error generating stack: `+e.message+`
|
|
|
66
66
|
`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?G.cursor(i.from,-1):G.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function LI(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==XM.Space&&(i=t),i==t}}function RI(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return G.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=UI(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return G.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return G.cursor(i.pos,i.assoc,void 0,o)}}function zI(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function BI(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=zI(e,i.from,0);t!=i.from&&(a=G.cursor(t,-1))}else{let t=zI(e,i.from,-1),n=zI(e,i.to,1);(t!=i.from||n!=i.to)&&(a=i.undirectional?G.undirectionalRange(i.from,i.to):G.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?G.create(n,t.mainIndex):t}function VI(e,t,n){let r=zI(e.state.facet(LF).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:G.cursor(r,r<n.from?1:-1)}var HI=class{constructor(e,t){this.pos=e,this.assoc=t}};function UI(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new HI(0,1);if(c>e.viewState.docHeight)return new HI(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==iP.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==iP.Text){let t=NI(e,i,l,o,s);return new HI(t,t==l.from?1:-1)}}if(l.type!=iP.Text)return c<(l.top+l.bottom)/2?new HI(l.from,1):new HI(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new WI(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var WI=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[QP.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[QP.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){for(let e=1;e<n;e++){let t=f+e;if(t>=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e<p.length;e++){let t=p[e];if(!(t.width==0&&p.length>1)){if(t.bottom<this.y)(!s||s.bottom<t.bottom)&&(s=t),m=1;else if(t.top>this.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right<this.x?this.x-t.right:0,n=Math.abs(e);n<u&&(l=f,u=n,d=t),e&&(m=e<0==(this.baseDir==HP.LTR)?-1:1)}}}m==-1&&(!o||this.baseDirAt(e[f],1))?i=f:m==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}if(!d){if(!c&&!s)return{i:0,after:!1};let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==HP.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=Yj(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return PP(e.dom,i,a).getClientRects()});return r.after?new HI(n[r.i+1],-1):new HI(n[r.i],1)}scanTile(e,t){if(!e.length)return new HI(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(fP(n.dom)?n.dom:PP(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new HI(n[r.i+1],-1):new HI(a,1)}},GI=``,KI=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(tN.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=GI}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=KF.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=KF.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:bP(r))||bP(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!JI(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=KF.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else pP(e)?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():fP(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(pP(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(qI(e,n.node,n.offset)?t:0))}};function qI(e,t,n){for(;;){if(!t||n<SP(t))return!1;if(t==e)return!0;n=yP(t)+1,t=t.parentNode}}function JI(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=KF.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var YI=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},XI=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=ZI(e.docView.tile,t,n,0))){let t=i||a?[]:nL(e),n=new KI(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=rL(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!hP(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!hP(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((J.ios||J.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(G.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=G.create([G.cursor(n,r)])}else this.newSel=G.single(r,n)}}};function ZI(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return ZI(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function QI(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||J.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,GI),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:zj.of(t.text.slice(a.from-e,u).split(GI))}:(d=tL(l,t.text,s-e,c))&&(J.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==``&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:zj.of(t.text.slice(d.from,d.toB).split(GI))})}else r&&(!e.hasFocus&&i.facet(DF)||iL(r,a))&&(r=null);if(!n&&!r)return!1;if((J.mac||J.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=G.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:zj.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:J.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
67
67
|
`&&e.lineWrapping&&(r&&=G.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:zj.of([` `])}),n)return $I(e,n,r,o);if(r&&!iL(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=BI(i.facet(LF).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function $I(e,t,n,r=-1){if(J.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(J.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&FP(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&FP(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&FP(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=eL(e,t,n);return e.state.facet(gF).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function eL(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=zI(i.facet(LF).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:G.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&SI(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?G.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function tL(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function nL(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new YI(n,r)),(i!=n||a!=r)&&t.push(new YI(i,a))),t}function rL(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?G.create([G.cursor(r+t,-1)]):G.single(n+t,r+t)}function iL(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var aL=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,J.safari&&e.contentDOM.addEventListener(`input`,()=>null),J.gecko&&HL(e.contentDOM.ownerDocument)}handleEvent(e){yL(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=cL(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&dL.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),J.android&&J.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(J.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(lL.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||uL.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&J.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&oL(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,FP(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:J.safari&&!J.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function oL(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function sL(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){EF(n.state,e)}}}function cL(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(sL(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(sL(t.value,r))}}for(let e in bL)n(e).handlers.push(bL[e]);for(let e in xL)n(e).observers.push(xL[e]);return t}var lL=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],uL=`dthko`,dL=[16,17,18,20,91,92,224,225],fL=6;function pL(e){return Math.max(0,e)*.7+8}function mL(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var hL=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=DP(e.contentDOM),this.atoms=e.state.facet(LF).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(tN.allowMultipleSelections)&&gL(e,t),this.dragging=vL(e,t)&&jL(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&mL(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=VF(this.view);e.clientX-s.left<=r+fL?t=-pL(r-e.clientX):e.clientX+s.right>=a-fL&&(t=pL(e.clientX-a)),e.clientY-s.top<=i+fL?n=-pL(i-e.clientY):e.clientY+s.bottom>=o-fL&&(n=pL(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=BI(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function gL(e,t){let n=e.state.facet(dF);return n.length?n[0](t):J.mac?t.metaKey:t.ctrlKey}function _L(e,t){let n=e.state.facet(fF);return n.length?n[0](t):J.mac?!t.altKey:!t.ctrlKey}function vL(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=mP(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function yL(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=KF.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var bL=Object.create(null),xL=Object.create(null),SL=J.ie&&J.ie_version<15||J.ios&&J.webkit_version<604;function CL(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),TL(e,n.value)},50)}function wL(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function TL(e,t){t=wL(e.state,vF,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(LL!=null&&n.selection.ranges.every(e=>e.empty)&&LL==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:G.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:G.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}xL.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,J.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},xL.wheel=xL.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},bL.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),xL.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},xL.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},xL.touchend=(e,t)=>{e.inputState.touchActive=!1},bL.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(pF))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=ML(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new hL(e,t,n,r)),r&&e.observer.ignore(()=>{MP(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function EL(e,t,n,r){if(r==1)return G.cursor(t,n);if(r==2)return MI(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,G.undirectionalRange(a,o)}}var DL=J.ie&&J.ie_version<=11,OL=null,kL=0,AL=0;function jL(e){if(!DL)return e.detail;let t=OL,n=AL;return OL=e,AL=Date.now(),kL=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(kL+1)%3:1}function ML(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=jL(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=EL(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=EL(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?G.range(i,a,l.assoc):G.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=NL(i,s.pos))?c:o?i.addRange(l):G.create([l])}}}function NL(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return G.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}bL.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=G.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,wL(e.state,yF,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},bL.dragend=e=>(e.inputState.draggedContent=null,!1);function PL(e,t,n,r){if(n=wL(e.state,vF,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&_L(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}bL.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&PL(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return PL(e,t,n,!0),!0}return!1},bL.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=SL?null:t.clipboardData;return n?(TL(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(CL(e),!1)};function FL(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function IL(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:wL(e,yF,t.join(e.lineBreak)),ranges:n,linewise:r}}var LL=null;bL.copy=bL.cut=(e,t)=>{if(!gP(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=IL(e.state);if(!n&&!i)return!1;LL=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=SL?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(FL(e,n),!1)};var RL=RM.define();function zL(e,t){let n=[];for(let r of e.facet(_F)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:RL.of(!0)}):null}function BL(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=zL(e.state,t);n?e.dispatch(n):e.update([])}},10)}xL.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),BL(e)},xL.blur=e=>{e.observer.clearSelectionRange(),BL(e)},xL.compositionstart=xL.compositionupdate=(e,t)=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&!e.state.readOnly&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}},xL.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,J.chrome&&J.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},xL.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},bL.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return $I(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(J.chrome&&J.android&&(n=lL.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return J.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),J.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>xL.compositionend(e,t),20),!1};var VL=new Set;function HL(e){VL.has(e)||(VL.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var UL=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],WL=!1;function GL(){WL=!1}var KL=class{constructor(e){this.lineWrapping=e,this.doc=zj.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return UL.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=UL.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},qL=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},JL=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?iP.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof sP?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},YL=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(YL||={}),XL=.001,ZL=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>XL&&(WL=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,YL.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,YL.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,YL.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=oR.build(n.setDoc(a),e,l,u);i=QL(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new tR(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r){if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=!1;return t[n-1]==null?(o=!0,n--):t[n]??(o=!0,r++),new rR(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function QL(e,t){return e==t?e:(e.constructor!=t.constructor&&(WL=!0),t)}ZL.prototype.size=1;var $L=Y.replace({}),eR=class extends ZL{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new JL(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new JL(r,0,n,this.spaceAbove,$L):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,YL.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},tR=class e extends eR{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new JL(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof nR&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof nR?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):ZL.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},nR=class e extends ZL{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new JL(a.from,a.length,l,c,0)}{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new JL(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==YL.ByHeight)return this.blockAt(e,n,r,i);if(t==YL.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new JL(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new JL(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new JL(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return ZL.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=XL&&(s=-2);let c=new tR(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=ZL.of(r);return(s<0||Math.abs(c.height-this.height)>=XL||Math.abs(s-this.heightMetrics(t,n).perLine)>=XL)&&(WL=!0),QL(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},rR=class extends ZL{constructor(e,t,n){super(e.length+ +!!t+n.length,e.height+n.height,+!!t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==YL.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==YL.ByPosNoHeight?YL.ByPosNoHeight:YL.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,YL.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,Math.min(t,c.from-1),n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&iR(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),iR(i,e)}return ZL.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?ZL.of(this.break?[e,null,t]:[e,t]):(this.left=QL(this.left,e),this.right=QL(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function iR(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof nR&&(r=e[t+1])instanceof nR&&e.splice(t-1,3,new nR(n.length+1+r.length))}var aR=5,oR=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof tR?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new tR(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new eR(a,r,n)):(a||i||r>=aR)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new tR(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new nR(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof tR)return e;let t=new tR(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof tR)&&!this.isCovered?this.nodes.push(new tR(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof tR&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return cN.spans(n,r,i,a,0),a.finish(r)}};function sR(e,t,n){let r=new cR;return cN.compare(e,t,n,r,0),r.changes}var cR=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&uP(e,t,this.changes,5)}};function lR(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(fP(t)){let n=window.getComputedStyle(t);if((t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&n.overflow!=`visible`){let n=t.getBoundingClientRect();a=Math.max(a,n.left),o=Math.min(o,n.right),s=Math.max(s,n.top),c=Math.min(t==e.parentNode?i.innerHeight:c,n.bottom)}t=n.position==`absolute`||n.position==`fixed`?t.offsetParent:t.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function uR(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function dR(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var fR=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return Y.replace({widget:new pR(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},pR=class extends rP{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},mR=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=bR,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=HP.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(NF).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new KL(n),this.stateDeco=xR(t),this.heightMap=ZL.empty().applyChanges(this.stateDeco,zj.empty,this.heightOracle.setDoc(t.doc),[new UF(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Y.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new hR(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?bR:new SR(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(CR(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=xR(this.state);let r=e.changedRanges,i=UF.extendWithRanges(r,sR(n,this.stateDeco,e?e.changes:iM.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);GL(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||WL)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(xF)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?HP.RTL:HP.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=TP(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=DP(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=RP(this.scrollParent||e.win);let m=(this.printing?dR:lR)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!uR(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),GL();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?ZL.empty().applyChanges(this.stateDeco,zj.empty,this.heightOracle,[new UF(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new qL(n.from,i))}WL&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new hR(r.lineAt(a-n*1e3,YL.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,YL.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,YL.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new hR(r.lineAt(o-500,YL.ByHeight,i,0,0).from,r.lineAt(o+n+500,YL.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new hR(this.heightMap.lineAt(n,YL.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,YL.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,YL.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,YL.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new fR(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=HP.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=yR(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(G.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new fR(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=iP.Text)return;let i=gR(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=vR(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=_R(i,n),l=_R(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=vR(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=_R(i,f),l=_R(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=vR(r,n)-vR(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){fR.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Y.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];cN.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||CR(this.heightMap.lineAt(e,YL.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||CR(this.heightMap.lineAt(this.scaler.fromDOM(e),YL.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return CR(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},hR=class{constructor(e,t){this.from=e,this.to=t}};function gR(e,t,n){let r=[],i=e,a=0;return cN.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function _R({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function vR(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function yR(e,t){for(let n of e)if(t(n))return n}var bR={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function xR(e){let t=e.facet(PF).filter(e=>typeof e!=`function`),n=e.facet(IF).filter(e=>typeof e!=`function`);return n.length&&t.push(cN.join(n)),t}var SR=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,YL.ByPos,e,0,0).top,o=t.lineAt(i,YL.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function CR(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new JL(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>CR(e,t)):e._content)}var wR=K.define({combine:e=>e.join(` `)}),TR=K.define({combine:e=>e.indexOf(!0)>-1}),ER=ON.newName(),DR=ON.newName(),OR=ON.newName(),kR={"&light":`.`+DR,"&dark":`.`+OR};function AR(e,t,n){return new ON(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var jR=AR(`.`+ER,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{userSelect:`none`,position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},".cm-panels-top":{top:`0`},".cm-panels-bottom":{bottom:`0`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`baseline`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{background:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat`,backgroundSize:`.4em`,backgroundPosition:`calc(min(50%, 0px)) center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},kR),MR={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},NR=J.ie&&J.ie_version<=11,PR=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new OP,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(J.ie&&J.ie_version<=11||J.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&J.android&&e.constructor.EDIT_CONTEXT!==!1&&!(J.chrome&&J.chrome_version<126)&&(this.editContext=new RR(e),e.state.facet(DF)&&(e.contentDOM.editContext=this.editContext.editContext)),NR&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type!=`change`&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(DF)?n.root.activeElement!=this.dom:!gP(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(J.ie&&J.ie_version<=11||J.android&&J.chrome)&&!n.state.selection.main.empty&&r.focusNode&&vP(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=mP(e.root);if(!t)return!1;let n=J.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&LR(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=gP(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&LP(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(fP(n))!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,MR),NR&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),NR&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&FP(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&gP(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new XI(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=QI(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=FR(t,e.previousSibling||e.target.previousSibling,-1),r=FR(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return e.type==`characterData`?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(DF)!=e.state.facet(DF)&&(e.view.contentDOM.editContext=e.state.facet(DF)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function FR(e,t,n){for(;t;){let r=KF.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function IR(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return vP(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function LR(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return IR(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?IR(e,n):null}var RR=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=tL(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=G.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));iL(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:zj.of(n.text.slice(l.from,l.toB).split(`
|
|
68
68
|
`))};if((J.mac||J.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:zj.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);$I(e,u,G.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(Y.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:TF.of(Y.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=mP(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},X=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||IP(e.parent)||document,this.viewState=new mR(this,e.state||tN.create(e)),e.scrollTo&&e.scrollTo.is(wF)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(kF).map(e=>new jF(e));for(let e of this.plugins)e.update(this);this.observer=new PR(this),this.inputState=new aL(this),this.inputState.ensureHandlers(this.plugins),this.docView=new yI(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof VM?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(RL))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=zL(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(tN.phrases)!=this.state.facet(tN.phrases))return this.setState(a);i=WF.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new CF(t.empty?t:G.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(wF)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=VR.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(HF)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(wR)!=i.state.facet(wR)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(hF))try{e(i)}catch(e){EF(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!QI(this,u)&&l.force&&FP(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new mR(this,e),this.plugins=e.facet(kF).map(e=>new jF(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new yI(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(kF),n=e.state.facet(kF);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new jF(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){EF(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(RP(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return EF(this.state,e),BR}}),u=WF.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e<c.length;e++)if(l[e]!=BR)try{let t=c[e];t.write&&t.write(l[e],this)}catch(e){EF(this.state,e)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)/this.viewState.scaleY-a/o;if((e>1||e<-1)&&!(J.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(hF))e(t)}get themeClasses(){return ER+` `+(this.state.facet(TR)?OR:DR)+` `+this.state.facet(wR)}updateAttrs(){let e=HR(this,MF,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(DF)?`true`:`false`,class:`cm-content`,style:`${J.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),HR(this,NF,t);let n=this.observer.ignore(()=>{let n=tP(this.contentDOM,this.contentAttrs,t),r=tP(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(HF);let t=this.state.facet(e.cspNonce);ON.mount(this.root,this.styleModules.concat(jR).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return VI(this,e,II(this,e,t,n))}moveByGroup(e,t){return VI(this,e,II(this,e,t,t=>LI(this,e.head,t)))}visualLineSide(e,t){return t?G.cursor(e.to,1):G.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return FI(this,e,t,n)}moveVertically(e,t,n){return VI(this,e,RI(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=UI(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),UI(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[QP.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==HP.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(bF)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zR)return sF(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||$P(r.isolates,n=zF(this,e))))return r.order;n||=zF(this,e);let r=oF(e.text,t,n);return this.bidiCache.push(new VR(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||J.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{MP(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return wF.of(new CF(typeof e==`number`?G.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return wF.of(new CF(G.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return AF.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return AF.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=ON.newName(),r=[wR.of(n),HF.of(AR(`.${n}`,e))];return t&&t.dark&&r.push(TR.of(!0)),r}static baseTheme(e){return CM.lowest(HF.of(AR(`.`+ER,e,kR)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&KF.get(t)||KF.get(e))?.root?.view||null}};X.styleModule=HF,X.inputHandler=gF,X.clipboardInputFilter=vF,X.clipboardOutputFilter=yF,X.scrollHandler=SF,X.focusChangeEffect=_F,X.perLineTextDirection=bF,X.exceptionSink=mF,X.updateListener=hF,X.editable=DF,X.mouseSelectionStyle=pF,X.dragMovesSelection=fF,X.clickAddsSelectionRange=dF,X.decorations=PF,X.blockWrappers=FF,X.outerDecorations=IF,X.atomicRanges=LF,X.bidiIsolatedRanges=RF,X.cursorScrollMargin=K.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),X.scrollMargins=BF,X.darkTheme=TR,X.cspNonce=K.define({combine:e=>e.length?e[0]:``}),X.contentAttributes=NF,X.editorAttributes=MF,X.lineWrapping=X.contentAttributes.of({class:`cm-lineWrapping`}),X.announce=q.define();var zR=4096,BR={},VR=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:HP.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function HR(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&ZN(a,n)}return n}var UR=J.mac?`mac`:J.windows?`win`:J.linux?`linux`:`key`;function WR(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function GR(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var KR=CM.default(X.domEventHandlers({keydown(e,t){return tz(YR(t.state),e,t,`editor`)}})),qR=K.define({enables:KR}),JR=new WeakMap;function YR(e){let t=e.facet(qR),n=JR.get(t);return n||JR.set(t,n=$R(t.reduce((e,t)=>e.concat(t),[]))),n}function XR(e,t,n){return tz(YR(e.state),t,e,n)}var ZR=null,QR=4e3;function $R(e,t=UR){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>WR(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=ZR={view:t,prefix:n,scope:e};return setTimeout(()=>{ZR==r&&(ZR=null)},QR),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,ez))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var ez=null;function tz(e,t,n,r){ez=t;let i=LN(t),a=eM(Qj(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;ZR&&ZR.view==n&&ZR.scope==r&&(o=ZR.prefix+` `,dL.indexOf(t.keyCode)<0&&(c=!0,ZR=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+GR(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(J.windows&&t.ctrlKey&&t.altKey)&&!(J.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=jN[t.keyCode])&&p!=i?(d(f[o+GR(p,t,!0)])||t.shiftKey&&(m=MN[t.keyCode])!=i&&m!=p&&d(f[o+GR(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+GR(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),ez=null,s}var nz=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=rz(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}return az(t,n,r)}};function rz(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==HP.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function iz(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function az(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==HP.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=rz(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=PI(e,r,1),m=PI(e,i,-1),h=p.type==iP.Text?p:null,g=m.type==iP.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=iz(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=iz(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==iP.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new nz(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);p&&m&&(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==HP.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function oz(e,t){return e.constructor==t.constructor&&e.eq(t)}var sz=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(cz)!=e.state.facet(cz)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(cz);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!oz(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,J.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},cz=K.define();function lz(e){return[AF.define(t=>new sz(t,e)),cz.of(e)]}var uz=!J.ios,dz=K.define({combine(e){return nN(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function fz(e={}){return[dz.of(e),mz,gz,vz,xF.of(!0)]}function pz(e){return e.startState.facet(dz)!=e.state.facet(dz)}var mz=lz({above:!0,markers(e){let{state:t}=e,n=t.facet(dz),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&J.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:G.cursor(i.head,i.assoc);for(let i of nz.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=pz(e);return n&&hz(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){hz(t.state,e)},class:`cm-cursorLayer`});function hz(e,t){t.style.animationDuration=e.facet(dz).cursorBlinkRate+`ms`}var gz=lz({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let i of r)if(!i.empty&&(uz||i!=n))for(let n of nz.forRange(e,`cm-selectionBackground`,i))t.push(n);if(J.ios&&!n.empty&&e.state.facet(dz).iosSelectionHandles){for(let r of nz.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,G.cursor(n.from,1)))t.push(r);for(let r of nz.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,G.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||pz(e)},class:`cm-selectionLayer`}),_z=J.gecko&&J.gecko_version==153?`#ffffff01`:`transparent`,vz=CM.highest(X.theme({".cm-line":{...uz?{"& ::selection, &::selection":{backgroundColor:`${_z} !important`}}:{},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,...uz?{"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}:{}}}})),yz=q.define({map(e,t){return e==null?null:t.mapPos(e)}}),bz=bM.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(yz)?t.value:e,e)}}),xz=AF.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(bz);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(bz)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(bz),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(bz)!=e&&this.view.dispatch({effects:yz.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Sz(){return[bz,xz]}function Cz(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function wz(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}var Tz=class{constructor(e){let{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:a=1e3}=e;if(!t.global)throw RangeError(`The regular expression given to MatchDecorator should have its 'g' flag set`);if(this.regexp=t,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if(typeof n==`function`)this.addMatch=(e,t,r,i)=>{let a=n(e,t,r);a&&i(r,r+e[0].length,a)};else if(n)this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n);else throw RangeError(`Either 'decorate' or 'decoration' should be provided to MatchDecorator`);this.boundary=i,this.maxLength=a}createDeco(e){let t=new dN,n=t.add.bind(t);for(let{from:t,to:r}of wz(e,this.maxLength))Cz(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,a,o)=>{o>=e.view.viewport.from&&a<=e.view.viewport.to&&(n=Math.min(a,n),r=Math.max(o,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let a=Math.max(i.from,n),o=Math.min(i.to,r);if(o>=a){let n=e.state.doc.lineAt(a),r=n.to<o?e.state.doc.lineAt(o):n,s=Math.max(i.from,n.from),c=Math.min(i.to,r.to);if(this.boundary){for(;a>n.from;a--)if(this.boundary.test(n.text[a-1-n.from])){s=a;break}for(;o<r.to;o++)if(this.boundary.test(r.text[o-r.from])){c=o;break}}let l=[],u,d=(e,t,n)=>l.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=s-n.from;(u=this.regexp.exec(n.text))&&u.index<c-n.from;)this.addMatch(u,e,u.index+n.from,d);else Cz(e.state.doc,this.regexp,s,c,(t,n)=>this.addMatch(n,e,t,d));t=t.update({filterFrom:s,filterTo:c,filter:(e,t)=>e<s||t>c,add:l})}}return t}},Ez=/x/.unicode==null?`g`:`gu`,Dz=RegExp(`[\0-\b
|
|
69
|
-
--\u2028\u2029-]`,Ez),Oz={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`},kz=null;function Az(){if(kz==null&&typeof document<`u`&&document.body){let e=document.body.style;kz=(e.tabSize??e.MozTabSize)!=null}return kz||!1}var jz=K.define({combine(e){let t=nN(e,{render:null,specialChars:Dz,addSpecialChars:null});return(t.replaceTabs=!Az())&&(t.specialChars=RegExp(` |`+t.specialChars.source,Ez)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+`|`+t.addSpecialChars.source,Ez)),t}});function Mz(e={}){return[jz.of(e),Pz()]}var Nz=null;function Pz(){return Nz||=AF.fromClass(class{constructor(e){this.view=e,this.decorations=Y.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(jz)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Tz({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=Qj(t[0],0);if(a==9){let e=i.lineAt(r),t=n.state.tabSize,a=SN(e.text,t,r-e.from);return Y.replace({widget:new Rz((t-a%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=Y.replace({widget:new Lz(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(jz);e.startState.facet(jz)==t?this.decorations=this.decorator.updateDeco(e,this.decorations):(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view))}},{decorations:e=>e.decorations})}var Fz=`•`;function Iz(e){return e>=32?Fz:e==10?``:String.fromCharCode(9216+e)}var Lz=class extends rP{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Iz(this.code),n=e.state.phrase(`Control character`)+` `+(Oz[this.code]||`0x`+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement(`span`);return i.textContent=t,i.title=n,i.setAttribute(`aria-label`,n),i.className=`cm-specialChar`,i}ignoreEvent(){return!1}},Rz=class extends rP{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement(`span`);return e.textContent=` `,e.className=`cm-tab`,e.style.width=this.width+`px`,e}ignoreEvent(){return!1}};function zz(){return Vz}var Bz=Y.line({class:`cm-activeLine`}),Vz=AF.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(Bz.range(i.from)),t=i.from)}return Y.set(n)}},{decorations:e=>e.decorations}),Hz=class extends rP{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?_P(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=CP(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function Uz(e){let t=AF.fromClass(class{constructor(t){this.view=t,this.placeholder=e?Y.set([Y.widget({widget:new Hz(e),side:1}).range(0)]):Y.none}get decorations(){return this.view.state.doc.length?Y.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,X.contentAttributes.of({"aria-placeholder":e})]:t}var Wz=2e3;function Gz(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>Wz||n.off>Wz||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(G.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=CN(n.text,o,e.tabSize,!0);if(r<0)a.push(G.cursor(n.to));else{let t=CN(n.text,s,e.tabSize);a.push(G.range(n.from+r,n.from+t))}}}return a}function Kz(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function qz(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>Wz?-1:i==r.length?Kz(e,t.clientX):SN(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Jz(e,t){let n=qz(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=qz(e,t);if(!o)return r;let s=Gz(e.state,n,o);return s.length?a?G.create(s.concat(r.ranges)):G.create(s):r}}:null}function Yz(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return X.mouseSelectionStyle.of((e,n)=>t(n)?Jz(e,n):null)}var Xz={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Zz={style:`cursor: crosshair`};function Qz(e={}){let[t,n]=Xz[e.key||`Alt`],r=AF.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,X.contentAttributes.of(e=>e.plugin(r)?.isDown?Zz:null)]}var $z=`-10000px`,eB=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function tB(e){let t=e.dom.ownerDocument.documentElement,n=t.clientWidth,r=getComputedStyle(t);if(!/stable/.test(r.scrollbarGutter||``))return{left:0,right:n};let i=t.getBoundingClientRect(),a=e.win.scrollX;return{left:Math.max(0,i.left+a-parseFloat(r.marginLeft)),right:Math.min(n,i.right+a+parseFloat(r.marginRight))}}function nB(e){let{left:t,right:n}=tB(e);return{top:0,left:t,right:n,bottom:e.dom.ownerDocument.documentElement.clientHeight}}var rB=K.define({combine:e=>({position:J.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||nB})}),iB=new WeakMap,aB=AF.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(rB);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 eB(e,lB,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.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(rB);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.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 e of this.manager.tooltipViews)this.container.appendChild(e.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 e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=$z,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 t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1,r=0;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(J.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}else r=tB(this.view).left;let i=this.view.scrollDOM.getBoundingClientRect(),a=VF(this.view);return{visible:{left:i.left+a.left,top:i.top+a.top,right:i.right-a.right,bottom:i.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(rB).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n,fixedLeft:r}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=$z;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=iB.get(c)??d.bottom-d.top,g=c.offset||cB,_=this.view.textDirection==HP.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=$z;continue}iB.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,oB(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,oB(l,(v-e.fixedLeft)/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.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=$z}},{eventObservers:{scroll(){this.maybeMeasure()}}});function oB(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var sB=X.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:`14px`,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`}}}),cB={x:0,y:0},lB=K.define({enables:[aB,sB]}),uB=K.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),dB=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new eB(e,uB,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},fB=lB.compute([uB],e=>{let t=e.facet(uB);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:dB.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),pB=K.define(),Sne=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener(`mouseleave`,this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener(`mousemove`,this.mousemove=this.mousemove.bind(this))}update(e){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 e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==HP.RTL?-1:1;i=t.x<n.left?-o:o}this.activateHover(e,r,i)}activateHover(e,t,n,r){let i=this.source(e,t,n),a=t=>{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>EF(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(aB),t=e?e.manager.tooltips.findIndex(e=>e.create==dB.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!Cne(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!wne(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},mB=4;function Cne(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-mB&&t.clientX<=r+mB&&t.clientY>=i-mB&&t.clientY<=a+mB}function wne(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let c=e.posAtCoords({x:r,y:i},!1);return c>=t&&c<=n}function Tne(e,t={}){let n=q.define(),r=new WeakMap,i=bM.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,nM.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(Dne)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>uB.from(e)}),a=AF.define(a=>new Sne(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,pB.of(a),fB]}}function Ene(e,t,n,r={}){let i=e.state.facet(pB).map(t=>e.plugin(t)).filter(e=>!!e);if(r.tooltip&&r.tooltip.active){let e=i.find(e=>e.field==r.tooltip.active);e&&(i=[e])}for(let a of i)a.activateHover(e,t,n,r.until??(()=>!1))}function hB(e,t){let n=e.plugin(aB);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var Dne=q.define(),gB=K.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function _B(e,t){let n=e.plugin(vB),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var vB=AF.fromClass(class{constructor(e){this.input=e.state.facet(xB),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(gB);this.top=new yB(e,!0,t.topContainer),this.bottom=new yB(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(gB);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new yB(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new yB(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(xB);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>X.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),yB=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),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`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=bB(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=bB(e)}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 e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function bB(e){let t=e.nextSibling;return e.remove(),t}var xB=K.define({enables:vB});function One(e,t){let n,r=new Promise(e=>n=e),i=e=>Ane(e,t,n);e.state.field(SB,!1)?e.dispatch({effects:CB.of(i)}):e.dispatch({effects:q.appendConfig.of(SB.init(()=>[i]))});let a=wB.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(SB).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}function kne(e,t){let n=e.state.field(SB,!1)||[];for(let r of n){let n=_B(e,r);if(n&&n.dom.classList.contains(t))return n}return null}var SB=bM.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(CB)?e=[n.value].concat(e):n.is(wB)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>xB.computeN([e],t=>t.field(e))}),CB=q.define(),wB=q.define();function Ane(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=RN(`form`),t.input){let e=RN(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(RN(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(RN(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=RN(`div`,r,RN(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var TB=class extends rN{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};TB.prototype.elementClass=``,TB.prototype.toDOM=void 0,TB.prototype.mapMode=nM.TrackBefore,TB.prototype.startSide=TB.prototype.endSide=-1,TB.prototype.point=!0;var EB=K.define(),jne=K.define(),Mne={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>cN.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},DB=K.define();function Nne(e){return[kB(),DB.of({...Mne,...e})]}var OB=K.define({combine:e=>e.some(e=>e)});function kB(e){let t=[Pne];return e&&e.fixed===!1&&t.push(OB.of(!0)),t}var Pne=AF.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(DB).map(t=>new MB(e,t)),this.fixed=!e.state.facet(OB);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.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 e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(OB)!=!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=cN.iter(this.view.state.facet(EB),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Fne(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==iP.Text&&t){jB(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==iP.Text){jB(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(DB),n=e.state.facet(DB),r=e.docChanged||e.heightChanged||e.viewportChanged||!cN.eq(e.startState.facet(EB),e.state.facet(EB),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new MB(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.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=>X.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==HP.LTR?{left:r,right:i}:{right:r,left:i}})});function AB(e){return Array.isArray(e)?e:[e]}function jB(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Fne=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=cN.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new NB(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];jB(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;(r.length!=0||a.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(jne)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},MB=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=AB(t.markers(e)),t.initialSpacer&&(this.spacer=new NB(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=AB(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!cN.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},NB=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Ine(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Ine(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}var Lne=K.define(),Rne=K.define(),PB=K.define({combine(e){return nN(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),FB=class extends TB{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function IB(e,t){return e.state.facet(PB).formatNumber(t,e.state)}var zne=DB.compute([PB],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Lne)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new FB(IB(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Rne)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(PB)!=e.state.facet(PB),initialSpacer(e){return new FB(IB(e,LB(e.state.doc.lines)))},updateSpacer(e,t){let n=IB(t.view,LB(t.view.state.doc.lines));return n==e.number?e:new FB(n)},domEventHandlers:e.facet(PB).domEventHandlers,side:`before`}));function Bne(e={}){return[PB.of(e),kB(),zne]}function LB(e){let t=9;for(;t<e;)t=t*10+9;return t}var Vne=new class extends TB{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},Hne=EB.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(Vne.range(i)))}return cN.of(t)});function Une(){return Hne}var RB=new pA;function zB(e){return K.define({combine:e?t=>t.concat(e):void 0})}var BB=new pA,VB=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,tN.prototype.hasOwnProperty(`tree`)||Object.defineProperty(tN.prototype,"tree",{get(){return WB(this)}}),this.parser=t,this.extension=[ZB.of(this),tN.languageData.of((e,t,n)=>{let r=HB(e,t,n),i=r.type.prop(RB);if(!i)return[];let a=e.facet(i),o=r.type.prop(BB);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return HB(e,t,n).type.prop(RB)==this.data}findRegions(e){let t=e.facet(ZB);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(RB)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(pA.mounted);if(i){if(i.tree.prop(RB)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof xA&&r(i,e.positions[n]+t)}};return r(WB(e),0),n}get allowsNesting(){return!0}};VB.setState=q.define();function HB(e,t,n){let r=e.facet(ZB),i=WB(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,bA.ExcludeBuffers|bA.EnterBracketed))e.type.isTop&&(i=e);return i}var UB=class e extends VB{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=zB(t.languageData);return new e(n,t.parser.configure({props:[RB.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function WB(e){let t=e.field(VB.state,!1);return t?t.tree:xA.empty}var Wne=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},GB=null,KB=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],xA.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Wne(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=xA.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(IA.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(IA.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=GB;GB=this;try{return e()}finally{GB=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=qB(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=IA.applyChanges(r,e),i=xA.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=qB(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends LA{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=GB;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new xA(gA.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return GB}};function qB(e,t,n){return IA.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var JB=class e{constructor(e){this.context=e,this.tree=e.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 e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=KB.create(t.facet(ZB).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};VB.state=bM.define({create:JB.init,update(e,t){for(let e of t.effects)if(e.is(VB.setState))return e.value;return t.startState.facet(ZB)==t.state.facet(ZB)?e.apply(t):JB.init(t.state)}});var YB=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(YB=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var XB=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Gne=AF.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(VB.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(VB.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=YB(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(VB.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!XB?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>XB&&XB()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:VB.setState.of(new JB(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>EF(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ZB=K.define({combine(e){return e.length?e[0]:null},enables:e=>[VB.state,Gne,X.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),QB=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Kne=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},qne=K.define(),$B=K.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function eV(e){let t=e.facet($B);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function tV(e,t){let n=``,r=e.tabSize,i=e.facet($B)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function nV(e,t){e instanceof tN&&(e=new rV(e));for(let n of e.state.facet(qne)){let r=n(e,t);if(r!==void 0)return r}let n=WB(e.state);return n.length>=t?Jne(e,n,t):null}var rV=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=eV(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return SN(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},iV=new pA;function Jne(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return aV(r,e,n)}function aV(e,t,n){for(let r=e;r;r=r.next){let e=Xne(r.node);if(e)return e(Qne.create(t,n,r))}return 0}function Yne(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Xne(e){let t=e.type.prop(iV);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(pA.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>sV(e,!0,1,void 0,n&&!Yne(e)?t.from:void 0)}return e.parent==null?Zne:null}function Zne(){return 0}var Qne=class e extends rV{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if($ne(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return aV(this.context.next,this.base,this.pos)}};function $ne(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function ere(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function oV({closing:e,align:t=!0,units:n=1}){return r=>sV(r,t,n,e)}function sV(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?ere(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var tre=e=>e.baseIndent;function cV({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var nre=200;function rre(){return tN.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+nre)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=nV(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=tV(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var lV=K.define(),uV=new pA;function dV(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 ire(e,t,n){let r=WB(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(uV);if(s&&(i.to<r.length-50||r.length==e.doc.length||!are(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function are(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function fV(e,t,n){for(let r of e.facet(lV)){let i=r(e,t,n);if(i)return i}return ire(e,t,n)}function pV(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var mV=q.define({map:pV}),hV=q.define({map:pV});function gV(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var _V=bM.define({create(){return Y.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=vV(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(mV)&&!ore(e,r.value.from,r.value.to)?n.push(r.value):r.is(hV)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(SV),i=n.map(e=>(r?Y.replace({widget:new dre(r(t.state,e))}):TV).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=vV(e,t.selection.main.head)),e},provide:e=>X.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw 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 RangeError(`Invalid JSON for fold state`);t.push(TV.range(r,i))}return Y.set(t,!0)}});function vV(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function yV(e,t,n){var r;let i=null;return(r=e.field(_V,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function ore(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function bV(e,t){return e.field(_V,!1)?t:t.concat(q.appendConfig.of(CV()))}var sre=e=>{for(let t of gV(e)){let n=fV(e.state,t.from,t.to);if(n)return e.dispatch({effects:bV(e.state,[mV.of(n),xV(e,n)])}),!0}return!1},cre=e=>{if(!e.state.field(_V,!1))return!1;let t=[];for(let n of gV(e)){let r=yV(e.state,n.from,n.to);r&&t.push(hV.of(r),xV(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function xV(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return X.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var lre=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:sre},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:cre},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=fV(t,i.from,i.to);a&&n.push(mV.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:bV(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(_V,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(hV.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],ure={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},SV=K.define({combine(e){return nN(e,ure)}});function CV(e){let t=[_V,mre];return e&&t.push(SV.of(e)),t}function wV(e,t){let{state:n}=e,r=n.facet(SV),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=yV(e.state,n.from,n.to);r&&e.dispatch({effects:hV.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var TV=Y.replace({widget:new class extends rP{toDOM(e){return wV(e,null)}}}),dre=class extends rP{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return wV(e,this.value)}},fre={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},EV=class extends TB{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function pre(e={}){let t={...fre,...e},n=new EV(t,!0),r=new EV(t,!1),i=AF.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(ZB)!=e.state.facet(ZB)||e.startState.field(_V,!1)!=e.state.field(_V,!1)||WB(e.startState)!=WB(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new dN;for(let i of e.viewportLineBlocks){let a=yV(e.state,i.from,i.to)?r:fV(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,Nne({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||cN.empty},initialSpacer(){return new EV(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=yV(e.state,t.from,t.to);if(r)return e.dispatch({effects:hV.of(r)}),!0;let i=fV(e.state,t.from,t.to);return i?(e.dispatch({effects:mV.of(i)}),!0):!1}}}),CV()]}var mre=X.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`}}),DV=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=ON.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof VB?e=>e.prop(RB)==a.data:a?e=>e==a:void 0,this.style=mj(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new ON(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},OV=K.define(),kV=K.define({combine(e){return e.length?[e[0]]:null}});function AV(e){let t=e.facet(OV);return t.length?t:e.facet(kV)}function jV(e,t){let n=[gre],r;return e instanceof DV&&(e.module&&n.push(X.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(kV.of(e)):r?n.push(OV.computeN([X.darkTheme],t=>t.facet(X.darkTheme)==(r==`dark`)?[e]:[])):n.push(OV.of(e)),n}var hre=class{constructor(e){this.markCache=Object.create(null),this.tree=WB(e.state),this.decorations=this.buildDeco(e,AV(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=WB(e.state),n=AV(e.state),r=n!=AV(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let n=new dN;for(let{from:r,to:i}of e.visibleRanges)hj(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=Y.mark({class:r})))},r,i);return n.finish()}},gre=CM.high(AF.fromClass(hre,{decorations:e=>e.decorations})),_re=DV.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`}]),vre=X.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),MV=1e4,NV=`()[]{}`,PV=K.define({combine(e){return nN(e,{afterCursor:!0,brackets:NV,maxScanDistance:MV,renderMatch:xre})}}),yre=Y.mark({class:`cm-matchingBracket`}),bre=Y.mark({class:`cm-nonmatchingBracket`});function xre(e){let t=[],n=e.matched?yre:bre;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 FV(e){let t=[],n=e.facet(PV);for(let r of e.selection.ranges){if(!r.empty)continue;let i=zV(e,r.head,-1,n)||r.head>0&&zV(e,r.head-1,1,n)||n.afterCursor&&(zV(e,r.head,1,n)||r.head<e.doc.length&&zV(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return Y.set(t,!0)}var Sre=[AF.fromClass(class{constructor(e){this.paused=!1,this.decorations=FV(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=FV(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),vre];function Cre(e={}){return[PV.of(e),Sre]}var IV=new pA;function LV(e,t,n){let r=e.prop(t<0?pA.openedBy:pA.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function RV(e){let t=e.type.prop(IV);return t?t(e.node):e}function zV(e,t,n,r={}){let i=r.maxScanDistance||MV,a=r.brackets||NV,o=WB(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=LV(r.type,n,a);if(i&&r.from<r.to){let o=RV(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return wre(e,t,n,r,o,i,a)}}return Tre(e,t,n,o,s.type,i,a)}function wre(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=RV(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(LV(u.type,n,o))l++;else if(LV(u.type,-n,o)){if(l==0){let e=RV(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Tre(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var Ere=Object.create(null),BV=[gA.none],VV=[],HV=Object.create(null),Dre=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`]])Dre[e]=Ore(Ere,t);function UV(e,t){VV.indexOf(e)>-1||(VV.push(e),console.warn(t))}function Ore(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||W[n];r?typeof r==`function`?t.length?t=t.map(r):UV(n,`Modifier ${n} used at start of tag`):t.length?UV(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:UV(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=HV[i];if(a)return a.id;let o=HV[i]=gA.define({id:BV.length,name:r,props:[dj({[r]:n})]});return BV.push(o),o.id}HP.RTL,HP.LTR;var WV=UB.define({name:`json`,parser:_ne.configure({props:[iV.add({Object:cV({except:/^\s*\}/}),Array:cV({except:/^\s*\]/})}),uV.add({"Object Array":dV})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function GV(){return new QB(WV)}function KV(){return KV=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},KV.apply(null,arguments)}function kre(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Are=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=JV(e.state,n.from);return r.line?jre(e):r.block?Nre(e):!1};function qV(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}}var jre=qV(Ire,0),Mre=qV(XV,0),Nre=qV((e,t)=>XV(e,t,Fre(t)),0);function JV(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var YV=50;function Pre(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-YV,r),o=e.sliceDoc(i,i+YV),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+YV),d=e.sliceDoc(i-YV,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Fre(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 a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function XV(e,t,n=t.selection.ranges){let r=n.map(e=>JV(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Pre(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Ire(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=JV(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var ZV=RM.define(),Lre=RM.define(),Rre=K.define(),QV=K.define({combine(e){return nN(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),$V=bM.define({create(){return lH.empty},update(e,t){let n=t.state.facet(QV),r=t.annotation(ZV);if(r){let i=rH.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?iH(o,o.length,n.minDepth,i):sH(o,t.startState.selection),new lH(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Lre);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(VM.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=rH.fromTransaction(t),o=t.annotation(VM.time),s=t.annotation(VM.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new lH(e.done.map(rH.fromJSON),e.undone.map(rH.fromJSON))}});function zre(e={}){return[$V,QV.of(e),X.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?tH:e.inputType==`historyRedo`?nH:null;return n?(e.preventDefault(),n(t)):!1}})]}function eH(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field($V,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var tH=eH(0,!1),nH=eH(1,!1),Bre=eH(0,!0),Vre=eH(1,!0),rH=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&iM.fromJSON(t.changes),[],t.mapped&&rM.fromJSON(t.mapped),t.startSelection&&G.fromJSON(t.startSelection),t.selectionsAfter.map(G.fromJSON))}static fromTransaction(t,n){let r=oH;for(let e of t.startState.facet(Rre)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,oH)}static selection(t){return new e(void 0,oH,void 0,void 0,t)}};function iH(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Hre(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Ure(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function aH(e,t){return e.length?t.length?e.concat(t):e:t}var oH=[],Wre=200;function sH(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Wre));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),iH(e,e.length-1,1e9,n.setSelAfter(r)))}return[rH.selection([t])]}function Gre(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 cH(e,t){if(!e.length)return e;let n=e.length,r=oH;for(;n;){let i=Kre(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[rH.selection(r)]:oH}function Kre(e,t,n){let r=aH(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):oH,n);if(!e.changes)return rH.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new rH(i,q.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var qre=/^(input\.type|delete)($|\.)/,lH=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||qre.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Hre(s.changes,t.changes))||r==`input.type.compose`)?iH(o,o.length-1,i.minDepth,new rH(t.changes.compose(s.changes),aH(q.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,oH)):iH(o,o.length,i.minDepth,t),new e(o,oH,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:oH;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Ure(a[a.length-1],t)?this:new e(sH(this.done,t),this.undone,n,r)}addMapping(t){return new e(cH(this.done,t),cH(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:ZV.of({side:e,rest:Gre(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?oH:r.slice(0,r.length-1);return i.mapped&&(n=cH(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:ZV.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};lH.empty=new lH(oH,oH);var Jre=[{key:`Mod-z`,run:tH,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:nH,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:nH,preventDefault:!0},{key:`Mod-u`,run:Bre,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Vre,preventDefault:!0}];function uH(e,t){return G.create(e.ranges.map(t),e.mainIndex)}function dH(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function fH({state:e,dispatch:t},n){let r=uH(e.selection,n);return!r.eq(e.selection,!0)&&(t(dH(e,r)),!0)}function pH(e,t){return G.cursor(t?e.to:e.from)}function mH(e,t){return fH(e,n=>n.empty?e.moveByChar(n,t):pH(n,t))}function hH(e){return e.textDirectionAt(e.state.selection.main.head)==HP.LTR}var gH=e=>mH(e,!hH(e)),_H=e=>mH(e,hH(e));function vH(e,t){return fH(e,n=>n.empty?e.moveByGroup(n,t):pH(n,t))}var Yre=e=>vH(e,!hH(e)),Xre=e=>vH(e,hH(e));typeof Intl<`u`&&Intl.Segmenter;function Zre(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 yH(e,t,n){let r=WB(e).resolveInner(t.head),i=n?pA.closedBy:pA.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Zre(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?zV(e,r.from,1):zV(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,G.cursor(s,n?-1:1)}var Qre=e=>fH(e,t=>yH(e.state,t,!hH(e))),$re=e=>fH(e,t=>yH(e.state,t,hH(e)));function bH(e,t){return fH(e,n=>{if(!n.empty)return pH(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var xH=e=>bH(e,!1),SH=e=>bH(e,!0);function CH(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(X.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.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 wH(e,t){let n=CH(e),{state:r}=e,i=uH(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):pH(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=X.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(dH(r,i),{effects:a}),!0}var TH=e=>wH(e,!1),EH=e=>wH(e,!0);function DH(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 n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=G.cursor(r.from+n))}return i}var OH=e=>fH(e,t=>DH(e,t,!0)),kH=e=>fH(e,t=>DH(e,t,!1)),AH=e=>fH(e,t=>DH(e,t,!hH(e))),jH=e=>fH(e,t=>DH(e,t,hH(e))),MH=e=>fH(e,t=>e.moveToLineBoundary(t,!1,!1)),NH=e=>fH(e,t=>e.moveToLineBoundary(t,!0,!1));function PH(e,t,n){let r=!1,i=uH(e.selection,t=>{let i=zV(e,t.head,-1)||zV(e,t.head,1)||t.head>0&&zV(e,t.head-1,1)||t.head<e.doc.length&&zV(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?G.range(t.anchor,a):G.cursor(a)});return r?(t(dH(e,i)),!0):!1}var FH=({state:e,dispatch:t})=>PH(e,t,!1);function IH(e,t,n){let r=uH(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=G.range(e.head,e.anchor));let r=n(e);return G.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(dH(e.state,r)),!0)}function LH(e,t){return IH(e,t,n=>e.moveByChar(n,t))}var RH=e=>LH(e,!hH(e)),zH=e=>LH(e,hH(e));function BH(e,t){return IH(e,t,n=>e.moveByGroup(n,t))}var VH=e=>BH(e,!hH(e)),HH=e=>BH(e,hH(e)),UH=e=>{let t=!hH(e);return IH(e,t,n=>yH(e.state,n,t))},WH=e=>{let t=hH(e);return IH(e,t,n=>yH(e.state,n,t))};function GH(e,t){return IH(e,t,n=>e.moveVertically(n,t))}var KH=e=>GH(e,!1),qH=e=>GH(e,!0);function JH(e,t){return IH(e,t,n=>e.moveVertically(n,t,CH(e).height))}var YH=e=>JH(e,!1),XH=e=>JH(e,!0),ZH=e=>IH(e,!0,t=>DH(e,t,!0)),QH=e=>IH(e,!1,t=>DH(e,t,!1)),$H=e=>{let t=!hH(e);return IH(e,t,n=>DH(e,n,t))},eU=e=>{let t=hH(e);return IH(e,t,n=>DH(e,n,t))},tU=e=>IH(e,!1,t=>G.cursor(e.lineBlockAt(t.head).from)),nU=e=>IH(e,!0,t=>G.cursor(e.lineBlockAt(t.head).to)),rU=({state:e,dispatch:t})=>(t(dH(e,{anchor:0})),!0),iU=({state:e,dispatch:t})=>(t(dH(e,{anchor:e.doc.length})),!0),aU=({state:e,dispatch:t})=>(t(dH(e,{anchor:e.selection.main.anchor,head:0})),!0),oU=({state:e,dispatch:t})=>(t(dH(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),sU=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),cU=({state:e,dispatch:t})=>{let n=DU(e).map(({from:t,to:n})=>G.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:G.create(n),userEvent:`select`})),!0},lU=({state:e,dispatch:t})=>{let n=uH(e.selection,t=>{let n=WB(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return G.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(dH(e,n)),!0)};function uU(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(dH(n,G.create(i,i.length-1))),!0)}var dU=e=>uU(e,!1),fU=e=>uU(e,!0),pU=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=G.create([n.main]):n.main.empty||(r=G.create([G.cursor(n.main.head)])),r?(t(dH(e,r)),!0):!1};function mU(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=hU(e,o,!1)):o>i&&(n=`delete.forward`,o=hU(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=hU(e,i,!1),a=hU(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:G.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?X.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function hU(e,t,n){if(e instanceof X)for(let r of e.state.facet(X.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var gU=(e,t,n)=>mU(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=SN(s,a.tabSize)%eV(a)||eV(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=Yj(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=Yj(o.text,c-o.from,!1,!1)+o.from);return c}),_U=e=>gU(e,!1,!0),vU=e=>gU(e,!0,!1),yU=(e,t)=>mU(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=Yj(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),bU=e=>yU(e,!1),xU=e=>yU(e,!0),SU=e=>mU(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),CU=e=>mU(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),wU=e=>mU(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),TU=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:zj.of([``,``])},range:G.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},EU=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:Yj(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:Yj(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:G.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function DU(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function OU(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of DU(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(G.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(G.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:G.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var kU=({state:e,dispatch:t})=>OU(e,t,!1),AU=({state:e,dispatch:t})=>OU(e,t,!0);function jU(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of DU(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.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}var MU=({state:e,dispatch:t})=>jU(e,t,!1),NU=({state:e,dispatch:t})=>jU(e,t,!0),PU=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(DU(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=uH(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function FU(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=WB(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(pA.closedBy))&&a.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}var IU=RU(!1),LU=RU(!0);function RU(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&FU(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new rV(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=nV(s,r);for(c??=SN(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,tV(t,c)];return o&&l.push(tV(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:zj.of(l)},range:G.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function zU(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:G.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var BU=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new rV(e,{overrideIndentation:e=>n[e]??-1}),i=zU(e,(t,i,a)=>{let o=nV(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=tV(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},VU=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(zU(e,(t,n)=>{n.push({from:t.from,insert:e.facet($B)})}),{userEvent:`input.indent`})),!0),HU=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(zU(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=SN(r,e.tabSize),a=0,o=tV(e,Math.max(0,i-eV(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),UU=e=>(e.setTabFocusMode(),!0),WU=[{key:`Ctrl-b`,run:gH,shift:RH,preventDefault:!0},{key:`Ctrl-f`,run:_H,shift:zH},{key:`Ctrl-p`,run:xH,shift:KH},{key:`Ctrl-n`,run:SH,shift:qH},{key:`Ctrl-a`,run:MH,shift:tU},{key:`Ctrl-e`,run:NH,shift:nU},{key:`Ctrl-d`,run:vU},{key:`Ctrl-h`,run:_U},{key:`Ctrl-k`,run:SU},{key:`Ctrl-Alt-h`,run:bU},{key:`Ctrl-o`,run:TU},{key:`Ctrl-t`,run:EU},{key:`Ctrl-v`,run:EH}],GU=[{key:`ArrowLeft`,run:gH,shift:RH,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Yre,shift:VH,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:AH,shift:$H,preventDefault:!0},{key:`ArrowRight`,run:_H,shift:zH,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Xre,shift:HH,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:jH,shift:eU,preventDefault:!0},{key:`ArrowUp`,run:xH,shift:KH,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:rU,shift:aU},{mac:`Ctrl-ArrowUp`,run:TH,shift:YH},{key:`ArrowDown`,run:SH,shift:qH,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:iU,shift:oU},{mac:`Ctrl-ArrowDown`,run:EH,shift:XH},{key:`PageUp`,run:TH,shift:YH},{key:`PageDown`,run:EH,shift:XH},{key:`Home`,run:kH,shift:QH,preventDefault:!0},{key:`Mod-Home`,run:rU,shift:aU},{key:`End`,run:OH,shift:ZH,preventDefault:!0},{key:`Mod-End`,run:iU,shift:oU},{key:`Enter`,run:IU,shift:IU},{key:`Mod-a`,run:sU},{key:`Backspace`,run:_U,shift:_U,preventDefault:!0},{key:`Delete`,run:vU,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:bU,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:xU,preventDefault:!0},{mac:`Mod-Backspace`,run:CU,preventDefault:!0},{mac:`Mod-Delete`,run:wU,preventDefault:!0}].concat(WU.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),KU=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Qre,shift:UH},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:$re,shift:WH},{key:`Alt-ArrowUp`,run:kU},{key:`Shift-Alt-ArrowUp`,run:MU},{key:`Alt-ArrowDown`,run:AU},{key:`Shift-Alt-ArrowDown`,run:NU},{key:`Mod-Alt-ArrowUp`,run:dU},{key:`Mod-Alt-ArrowDown`,run:fU},{key:`Escape`,run:pU},{key:`Mod-Enter`,run:LU},{key:`Alt-l`,mac:`Ctrl-l`,run:cU},{key:`Mod-i`,run:lU,preventDefault:!0},{key:`Mod-[`,run:HU},{key:`Mod-]`,run:VU},{key:`Mod-Alt-\\`,run:BU},{key:`Shift-Mod-k`,run:PU},{key:`Shift-Mod-\\`,run:FH},{key:`Mod-/`,run:Are},{key:`Alt-A`,mac:`Ctrl-A`,run:Mre},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:UU}].concat(GU),qU={key:`Tab`,run:VU,shift:HU},JU=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,YU=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(JU(e)):JU,this.query=this.normalize(t)}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 Qj(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=$j(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=eM(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(YU.prototype[Symbol.iterator]=function(){return this});var XU={from:-1,to:-1,match:/.*/.exec(``),precise:!0},ZU=`gm`+(/x/.unicode==null?``:`u`),QU=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=XU,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new tW(e,t,n,r,i);this.re=new RegExp(t,ZU+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=rW(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),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 e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=rW(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},$U=new WeakMap,eW=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=$U.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return $U.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),$U.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},tW=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=XU,this.matchPos=rW(e,r),this.re=new RegExp(t,ZU+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=eW.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=rW(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=eW.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(QU.prototype[Symbol.iterator]=tW.prototype[Symbol.iterator]=function(){return this});function nW(e){try{return new RegExp(e,ZU),!0}catch{return!1}}function rW(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}var iW=e=>{let t=kne(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=One(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=G.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,X.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},aW={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},oW=K.define({combine(e){return nN(e,aW,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function sW(e){let t=[pW,fW];return e&&t.push(oW.of(e)),t}var cW=Y.mark({class:`cm-selectionMatch`}),lW=Y.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function uW(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=XM.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=XM.Word)}function dW(e,t,n,r){return e(t.sliceDoc(n,n+1))==XM.Word&&e(t.sliceDoc(r-1,r))==XM.Word}var fW=AF.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(oW),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Y.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return Y.none;let e=n.wordAt(i.head);if(!e)return Y.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return Y.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(uW(o,n,i.from,i.to)&&dW(o,n,i.from,i.to)))return Y.none}else if(a=n.sliceDoc(i.from,i.to),!a)return Y.none}let s=[];for(let r of e.visibleRanges){let e=new YU(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||uW(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(lW.range(r,a)):(r>=i.to||a<=i.from)&&s.push(cW.range(r,a)),s.length>t.maxMatches))return Y.none}}return Y.set(s)}},{decorations:e=>e.decorations}),pW=X.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),mW=({state:e,dispatch:t})=>{let{selection:n}=e,r=G.create(n.ranges.map(t=>e.wordAt(t.head)||G.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function hW(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new YU(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new YU(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var gW=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return mW({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=hW(e,r);return i?(t(e.update({selection:e.selection.addRange(G.range(i.from,i.to),!1),effects:X.scrollIntoView(i.to)})),!0):!1},_W=K.define({combine(e){return nN(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ZW(e),scrollToMatch:e=>X.scrollIntoView(e)})}}),vW=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||nW(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
70
|
-
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new kW(this):new CW(this)}getCursor(e,t=0,n){let r=e.doc?e:tN.create({doc:e});return n??=r.doc.length,this.regexp?TW(this,r,t,n):xW(this,r,t,n)}},yW=class{constructor(e){this.spec=e}};function bW(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function xW(e,t,n,r){let i;return e.wholeWord&&(i=SW(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=bW(e.test,t,i)),new YU(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function SW(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(EW(i,n-a))!=XM.Word||t(DW(i,n-a))!=XM.Word)&&(t(DW(i,r-a))!=XM.Word||t(EW(i,r-a))!=XM.Word))}var CW=class extends yW{constructor(e){super(e)}nextMatch(e,t,n){let r=xW(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=xW(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=xW(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=xW(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=xW(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function wW(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function TW(e,t,n,r){let i;return e.wholeWord&&(i=OW(t.charCategorizer(t.selection.main.head))),e.test&&(i=wW(e.test,t,i)),new QU(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function EW(e,t){return e.slice(Yj(e,t,!1),t)}function DW(e,t){return e.slice(t,Yj(e,t))}function OW(e){return(t,n,r)=>!r[0].length||(e(EW(r.input,r.index))!=XM.Word||e(DW(r.input,r.index))!=XM.Word)&&(e(DW(r.input,r.index+r[0].length))!=XM.Word||e(EW(r.input,r.index+r[0].length))!=XM.Word)}var kW=class extends yW{nextMatch(e,t,n){let r=TW(this.spec,e,n,e.doc.length).next();return r.done&&(r=TW(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=TW(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=TW(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=TW(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},AW=q.define(),jW=q.define(),MW=bM.define({create(e){return new NW(GW(e).create(),null)},update(e,t){for(let n of t.effects)n.is(AW)?e=new NW(n.value.create(),e.panel):n.is(jW)&&(e=new NW(e.query,n.value?WW:null));return e},provide:e=>xB.from(e,e=>e.panel)}),NW=class{constructor(e,t){this.query=e,this.panel=t}},PW=Y.mark({class:`cm-searchMatch`}),FW=Y.mark({class:`cm-searchMatch cm-searchMatch-selected`}),IW=AF.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(MW))}update(e){let t=e.state.field(MW);(t!=e.startState.field(MW)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Y.none;let{view:n}=this,r=new dN;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?FW:PW)})}return r.finish()}},{decorations:e=>e.decorations});function LW(e){return t=>{let n=t.state.field(MW,!1);return n&&n.query.spec.valid?e(t,n):JW(t)}}var RW=LW((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(_W);return e.dispatch({selection:i,effects:[tG(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),qW(e),!0}),zW=LW((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(_W);return e.dispatch({selection:a,effects:[tG(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),qW(e),!0}),BW=LW((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),VW=({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,a=[],o=0;for(let t=new YU(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},HW=LW((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(X.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(tG(e,o)),u.push(n.facet(_W).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),UW=LW((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:X.announce.of(r),userEvent:`input.replace.all`}),!0});function WW(e){return e.state.facet(_W).createPanel(e)}function GW(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(_W);return new vW({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function KW(e){let t=_B(e,WW);return t&&t.dom.querySelector(`[main-field]`)}function qW(e){let t=KW(e);t&&t==e.root.activeElement&&t.select()}var JW=e=>{let t=e.state.field(MW,!1);if(t&&t.panel){let n=KW(e);if(n&&n!=e.root.activeElement){let r=GW(e.state,t.query.spec);r.valid&&e.dispatch({effects:AW.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[jW.of(!0),t?AW.of(GW(e.state,t.query.spec)):q.appendConfig.of(rG)]});return!0},YW=e=>{let t=e.state.field(MW,!1);if(!t||!t.panel)return!1;let n=_B(e,WW);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:jW.of(!1)}),!0},XW=[{key:`Mod-f`,run:JW,scope:`editor search-panel`},{key:`F3`,run:RW,shift:zW,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:RW,shift:zW,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:YW,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:VW},{key:`Mod-Alt-g`,run:iW},{key:`Mod-d`,run:gW,preventDefault:!0}],ZW=class{constructor(e){this.view=e;let t=this.query=e.state.field(MW).query.spec;this.commit=this.commit.bind(this),this.searchField=RN(`input`,{value:t.search,placeholder:QW(e,`Find`),"aria-label":QW(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=RN(`input`,{value:t.replace,placeholder:QW(e,`Replace`),"aria-label":QW(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=RN(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=RN(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=RN(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return RN(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=RN(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>RW(e),[QW(e,`next`)]),n(`prev`,()=>zW(e),[QW(e,`previous`)]),n(`select`,()=>BW(e),[QW(e,`all`)]),RN(`label`,null,[this.caseField,QW(e,`match case`)]),RN(`label`,null,[this.reField,QW(e,`regexp`)]),RN(`label`,null,[this.wordField,QW(e,`by word`)]),...e.state.readOnly?[]:[RN(`br`),this.replaceField,n(`replace`,()=>HW(e),[QW(e,`replace`)]),n(`replaceAll`,()=>UW(e),[QW(e,`replace all`)])],RN(`button`,{name:`close`,onclick:()=>YW(e),"aria-label":QW(e,`close`),type:`button`},[`×`])])}commit(){let e=new vW({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:AW.of(e)}))}keydown(e){XR(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?zW:RW)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),HW(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(AW)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(_W).top}};function QW(e,t){return e.state.phrase(t)}var $W=30,eG=/[\s\.,:;?!]/;function tG(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-$W),o=Math.min(i,n+$W),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<$W;e++)if(!eG.test(s[e+1])&&eG.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-$W;e--)if(!eG.test(s[e-1])&&eG.test(s[e])){s=s.slice(0,e);break}}return X.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var nG=X.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`}}),rG=[MW,CM.low(IW),nG],iG=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=WB(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(dG(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function aG(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 oG(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=aG(t)+aG(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function sG(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:oG(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function cG(e,t){return n=>{for(let t=WB(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var lG=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function uG(e){return e.selection.main.from}function dG(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var fG=RM.define();function pG(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:G.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var mG=new WeakMap;function hG(e){if(!Array.isArray(e))return e;let t=mG.get(e);return t||mG.set(e,t=sG(e)),t}var gG=q.define(),_G=q.define(),vG=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Qj(e,t),r=eM(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(Qj(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=Qj(e,0),i=eM(r),a=i==e.length?0:-100;if(r!=t[0]){if(r==n[0])a+=-200;else return null}return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=Qj(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=eM(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=Qj(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=$j(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=eM(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?eM(Qj(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},yG=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},bG=K.define({combine(e){return nN(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:SG,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>xG(e(n),t(n)),optionClass:(e,t)=>n=>xG(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function xG(e,t){return e?t?e+` `+t:e:t}function SG(e,t,n,r,i,a){let o=e.textDirection==HP.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var CG=q.define();function wG(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function TG(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var EG=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(bG);this.optionContent=wG(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=TG(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:CG.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(bG).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:_G.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=TG(r.length,i,e.state.facet(bG).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=TG(t.options.length,t.selected,this.view.state.facet(bG).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>EF(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&OG(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(bG).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function DG(e,t){return n=>new EG(n,e,t)}function OG(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 kG(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function AG(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(bG);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new lG(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new yG(n):new vG(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new lG(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):kG(e.completion)>kG(c)&&(s[s.length-1]=e),c=e.completion}return s}var jG=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,IG(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=AG(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(bG).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,IG(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:GG,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},MG=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(LG,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(bG),i=(r.override||n.languageDataAt(`autocomplete`,uG(n)).map(hG)).map(e=>(this.active.find(t=>t.source==e)||new zG(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(HG));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!NG(i,this.active)||o?a=jG.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new zG(e.source,0):e));for(let e of t.effects)e.is(CG)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?PG:FG}};function NG(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,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var PG={"aria-autocomplete":`list`},FG={};function IG(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var LG=[];function RG(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(fG);if(n&&t.activateOnCompletion(n))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}var zG=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=RG(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(gG))i=new e(i.source,1,n.value);else if(n.is(_G))i=new e(i.source,0);else if(n.is(HG))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(uG(e.state))}},BG=class e extends zG{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=uG(t.state);if(o>a||!r||n&2&&(uG(t.startState)==this.from||o<this.limit))return new zG(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return VG(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new iG(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??uG(t.state)):new zG(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new zG(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function VG(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):dG(e,!0).test(i)}var HG=q.define({map(e,t){return e.map(e=>e.map(t))}}),UG=bM.define({create(){return MG.start()},update(e,t){return e.update(t)},provide:e=>[lB.from(e,e=>e.tooltip),X.contentAttributes.from(e,e=>e.attrs)]});function WG(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(UG).active.find(e=>e.source==t.source);return r instanceof BG&&(typeof n==`string`?e.dispatch({...pG(e.state,n,r.from,r.to),annotations:fG.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var GG=DG(UG,WG);function KG(e,t=`option`){return n=>{let r=n.state.field(UG,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(bG).interactionDelay)return!1;let i=1,a;t==`page`&&(a=hB(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:CG.of(s)}),!0}}var qG=e=>{let t=e.state.field(UG,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(bG).interactionDelay?!1:WG(e,t.open.options[t.open.selected])},JG=e=>e.state.field(UG,!1)?(e.dispatch({effects:gG.of(!0)}),!0):!1,YG=e=>{let t=e.state.field(UG,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:_G.of(null)}),!0)},XG=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},ZG=50,QG=1e3,$G=AF.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(UG).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(UG),n=e.state.facet(bG);if(!e.selectionSet&&!e.docChanged&&e.startState.field(UG)==t)return;let r=e.transactions.some(e=>{let t=RG(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>ZG&&Date.now()-n.time>QG){for(let e of n.context.abortListeners)try{e()}catch(e){EF(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(gG)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(UG);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(bG).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new iG(t,uG(t),e.explicit,this.view),r=new XG(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:_G.of(null)}),EF(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(bG).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(bG),n=this.view.state.field(UG);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=uG(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new BG(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new zG(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:HG.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(UG,!1);if(t&&t.tooltip&&this.view.state.facet(bG).closeOnBlur){let n=t.open&&hB(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:_G.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:gG.of(!1)}),20),this.composing=0}}}),eK=typeof navigator==`object`&&/Win/.test(navigator.platform),tK=CM.highest(X.domEventHandlers({keydown(e,t){let n=t.state.field(UG,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(eK&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&WG(t,r),!1}})),nK=X.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`,cursor:`pointer`},".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`}}}),rK=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},iK=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,nM.TrackDel),r=t.mapPos(this.to,1,nM.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},aK=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet($B);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new iK(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new rK(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},oK=Y.widget({widget:new class extends rP{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),sK=Y.mark({class:`cm-snippetField`}),cK=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=Y.set(e.map(e=>(e.from==e.to?oK:sK).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},lK=q.define({map(e,t){return e&&e.map(t)}}),uK=q.define(),dK=bM.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(lK))return n.value;if(n.is(uK)&&e)return new cK(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>X.decorations.from(e,e=>e?e.deco:Y.none)});function fK(e,t){return G.create(e.filter(e=>e.field==t).map(e=>G.range(e.from,e.to)))}function pK(e){let t=aK.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:zj.of(a)},scrollIntoView:!0,annotations:n?[fG.of(n),VM.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=fK(o,0)),o.some(e=>e.field>0)){let t=new cK(o,0),n=c.effects=[lK.of(t)];e.state.field(dK,!1)===void 0&&n.push(q.appendConfig.of([dK,_K,yK,nK]))}e.dispatch(e.state.update(c))}}function mK(e){return({state:t,dispatch:n})=>{let r=t.field(dK,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:fK(r.ranges,i),effects:lK.of(a?null:new cK(r.ranges,i)),scrollIntoView:!0})),!0}}var hK=[{key:`Tab`,run:mK(1),shift:mK(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(dK,!1)?(t(e.update({effects:lK.of(null)})),!0):!1}],gK=K.define({combine(e){return e.length?e[0]:hK}}),_K=CM.highest(qR.compute([gK],e=>e.facet(gK)));function vK(e,t){return{...t,apply:pK(e)}}var yK=X.domEventHandlers({mousedown(e,t){let n=t.state.field(dK,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:fK(n.ranges,i.field),effects:lK.of(n.ranges.some(e=>e.field>i.field)?new cK(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),bK={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},xK=q.define({map(e,t){return t.mapPos(e,-1,nM.TrackAfter)??void 0}}),SK=new class extends rN{};SK.startSide=1,SK.endSide=-1;var CK=bM.define({create(){return cN.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:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(xK)&&(e=e.update({add:[SK.range(n.value,n.value+1)]}));return e}});function wK(){return[kK,CK]}var TK=`()[]{}<>«»»«[]{}`;function EK(e){for(let t=0;t<16;t+=2)if(TK.charCodeAt(t)==e)return TK.charAt(t+1);return $j(e<128?e:e+1)}function DK(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||bK}var OK=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),kK=X.inputHandler.of((e,t,n,r)=>{if((OK?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&eM(Qj(r,0))==1||t!=i.from||n!=i.to)return!1;let a=jK(e.state,r);return a?(e.dispatch(a),!0):!1}),AK=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=DK(e,e.selection.main.head).brackets||bK.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=PK(e.doc,t.head);for(let i of n)if(i==r&&NK(e.doc,t.head)==EK(Qj(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:G.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function jK(e,t){let n=DK(e,e.selection.main.head),r=n.brackets||bK.brackets;for(let i of r){let a=EK(Qj(i,0));if(t==i)return a==i?LK(e,i,r.indexOf(i+i+i)>-1,n):FK(e,i,a,n.before||bK.before);if(t==a&&MK(e,e.selection.main.from))return IK(e,i,a)}return null}function MK(e,t){let n=!1;return e.field(CK).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function NK(e,t){let n=e.sliceString(t,t+2);return n.slice(0,eM(Qj(n,0)))}function PK(e,t){let n=e.sliceString(t-2,t);return eM(Qj(n,0))==n.length?n:n.slice(1)}function FK(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:xK.of(a.to+t.length),range:G.range(a.anchor+t.length,a.head+t.length)};let o=NK(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:xK.of(a.head+t.length),range:G.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function IK(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&NK(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:G.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function LK(e,t,n,r){let i=r.stringPrefixes||bK.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:xK.of(r.to+t.length),range:G.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=NK(e.doc,o),c;if(s==t){if(RK(e,o))return{changes:{insert:t+t,from:o},effects:xK.of(o+t.length),range:G.cursor(o+t.length)};if(MK(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:G.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=BK(e,o-2*t.length,i))>-1&&RK(e,c))return{changes:{insert:t+t+t+t,from:o},effects:xK.of(o+t.length),range:G.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=XM.Word&&BK(e,o,i)>-1&&!zK(e,o,t,i))return{changes:{insert:t+t,from:o},effects:xK.of(o+t.length),range:G.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function RK(e,t){let n=WB(e).resolveInner(t+1);return n.parent&&n.from==t}function zK(e,t,n,r){let i=WB(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function BK(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=XM.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=XM.Word)return n}return-1}function VK(e={}){return[tK,UG,bG.of(e),$G,UK,nK]}var HK=[{key:`Ctrl-Space`,run:JG},{mac:"Alt-`",run:JG},{mac:`Alt-i`,run:JG},{key:`Escape`,run:YG},{key:`ArrowDown`,run:KG(!0)},{key:`ArrowUp`,run:KG(!1)},{key:`PageDown`,run:KG(!0,`page`)},{key:`PageUp`,run:KG(!1,`page`)},{key:`Enter`,run:qG}],UK=CM.highest(qR.computeN([bG],e=>e.facet(bG).defaultKeymap?[HK]:[])),WK=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},GK=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(aq).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new dN,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=gq(s);if(i)o.add(n,n,Y.widget({widget:new lq(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,Y.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,KK(f))}};function KK(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new WK(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new WK(r.from,n,r.diagnostic)}}),r}function qK(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(aq).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(YK))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function JK(e,t){return e.field(QK,!1)?t:t.concat(q.appendConfig.of(vq))}var YK=q.define(),XK=q.define(),ZK=q.define(),QK=bM.define({create(){return new GK(Y.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 i=t.changes.mapPos(e.selected.from,1);r=KK(n,e.selected.diagnostic,i)||KK(n,null,i)}!n.size&&i&&t.state.facet(aq).autoPanel&&(i=null),e=new GK(n,i,r)}for(let n of t.effects)if(n.is(YK)){let r=t.state.facet(aq).autoPanel?n.value.length?dq.open:null:e.panel;e=GK.init(n.value,r,t.state)}else n.is(XK)?e=new GK(e.diagnostics,n.value?dq.open:null,e.selected):n.is(ZK)&&(e=new GK(e.diagnostics,e.panel,n.value));return e},provide:e=>[xB.from(e,e=>e.panel),X.decorations.from(e,e=>e.diagnostics)]}),$K=Y.mark({class:`cm-lintRange cm-lintRange-active`});function eq(e,t,n){let{diagnostics:r}=e.state.field(QK),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(aq).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:!0,create(){return{dom:tq(e,i)}}}:null}function tq(e,t){return RN(`ul`,{class:`cm-tooltip-lint`},t.map(t=>cq(e,t,!1)))}var nq=e=>{let t=e.state.field(QK,!1);(!t||!t.panel)&&e.dispatch({effects:JK(e.state,[XK.of(!0)])});let n=_B(e,dq.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},rq=e=>{let t=e.state.field(QK,!1);return!t||!t.panel?!1:(e.dispatch({effects:XK.of(!1)}),!0)},iq=[{key:`Mod-Shift-m`,run:nq,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(QK,!1);if(!t)return!1;let n=e.state.selection.main,r=KK(t.diagnostics,null,n.to+1);return!r&&(r=KK(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}),Ene(e,r.from,1,{tooltip:_q,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],aq=K.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...nN(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:oq,tooltipFilter:oq,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function oq(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function sq(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function cq(e,t,n){let r=n?sq(t.actions):[];return RN(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},RN(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=KK(e.state.field(QK).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),RN(`u`,s.slice(c,c+1)),s.slice(c+1)];return RN(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&RN(`div`,{class:`cm-diagnosticSource`},t.source))}var lq=class extends rP{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return RN(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},uq=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=cq(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},dq=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)rq(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=sq(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=KK(this.view.state.field(QK).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=RN(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=RN(`div`,{class:`cm-panel-lint`},this.list,RN(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>rq(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(QK).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(QK),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new uq(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new uq(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=KK(this.view.state.field(QK).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:ZK.of(t)})}static open(t){return new e(t)}};function fq(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 pq(e){return fq(`<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"`)}var mq=X.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:pq(`#f11`)},".cm-lintRange-warning":{backgroundImage:pq(`orange`)},".cm-lintRange-info":{backgroundImage:pq(`#999`)},".cm-lintRange-hint":{backgroundImage:pq(`#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 hq(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function gq(e){let t=`hint`,n=1;for(let r of e){let e=hq(r.severity);e>n&&(n=e,t=r.severity)}return t}var _q=Tne(eq,{hideOn:qK}),vq=[QK,X.decorations.compute([QK],e=>{let{selected:t,panel:n}=e.field(QK);return!t||!n||t.from==t.to?Y.none:Y.set([$K.range(t.from,t.to)])}),_q,mq],yq=function(e){e===void 0&&(e={});var t=e.crosshairCursor,n=t!==void 0&&t,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(AK)),e.defaultKeymap!==!1&&(r=r.concat(KU)),e.searchKeymap!==!1&&(r=r.concat(XW)),e.historyKeymap!==!1&&(r=r.concat(Jre)),e.foldKeymap!==!1&&(r=r.concat(lre)),e.completionKeymap!==!1&&(r=r.concat(HK)),e.lintKeymap!==!1&&(r=r.concat(iq));var i=[];return e.lineNumbers!==!1&&i.push(Bne()),e.highlightActiveLineGutter!==!1&&i.push(Une()),e.highlightSpecialChars!==!1&&i.push(Mz()),e.history!==!1&&i.push(zre()),e.foldGutter!==!1&&i.push(pre()),e.drawSelection!==!1&&i.push(fz()),e.dropCursor!==!1&&i.push(Sz()),e.allowMultipleSelections!==!1&&i.push(tN.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(rre()),e.syntaxHighlighting!==!1&&i.push(jV(_re,{fallback:!0})),e.bracketMatching!==!1&&i.push(Cre()),e.closeBrackets!==!1&&i.push(wK()),e.autocompletion!==!1&&i.push(VK()),e.rectangularSelection!==!1&&i.push(Yz()),n!==!1&&i.push(Qz()),e.highlightActiveLine!==!1&&i.push(zz()),e.highlightSelectionMatches!==!1&&i.push(sW()),e.tabSize&&typeof e.tabSize==`number`&&i.push($B.of(` `.repeat(e.tabSize))),i.concat([qR.of(r.flat())]).filter(Boolean)},bq=`#e5c07b`,xq=`#e06c75`,Sq=`#56b6c2`,Cq=`#ffffff`,wq=`#abb2bf`,Tq=`#7d8799`,Eq=`#61afef`,Dq=`#98c379`,Oq=`#d19a66`,kq=`#c678dd`,Aq=`#21252b`,jq=`#2c313a`,Mq=`#282c34`,Nq=`#353a42`,Pq=`#3E4451`,Fq=`#528bff`,Iq=[X.theme({"&":{color:wq,backgroundColor:Mq},".cm-content":{caretColor:Fq},".cm-cursor, .cm-dropCursor":{borderLeftColor:Fq},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Pq},".cm-panels":{backgroundColor:Aq,color:wq},".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:Mq,color:Tq,border:`none`},".cm-activeLineGutter":{backgroundColor:jq},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:Nq},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Nq,borderBottomColor:Nq},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:jq,color:wq}}},{dark:!0}),jV(DV.define([{tag:W.keyword,color:kq},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:xq},{tag:[W.function(W.variableName),W.labelName],color:Eq},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:Oq},{tag:[W.definition(W.name),W.separator],color:wq},{tag:[W.typeName,W.className,W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:bq},{tag:[W.operator,W.operatorKeyword,W.url,W.escape,W.regexp,W.link,W.special(W.string)],color:Sq},{tag:[W.meta,W.comment],color:Tq},{tag:W.strong,fontWeight:`bold`},{tag:W.emphasis,fontStyle:`italic`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.link,color:Tq,textDecoration:`underline`},{tag:W.heading,fontWeight:`bold`,color:xq},{tag:[W.atom,W.bool,W.special(W.variableName)],color:Oq},{tag:[W.processingInstruction,W.string,W.inserted],color:Dq},{tag:W.invalid,color:Cq}]))],Lq=X.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),Rq=function(e){e===void 0&&(e={});var t=e,n=t.indentWithTab,r=n===void 0||n,i=t.editable,a=i===void 0||i,o=t.readOnly,s=o!==void 0&&o,c=t.theme,l=c===void 0?`light`:c,u=t.placeholder,d=u===void 0?``:u,f=t.basicSetup,p=f===void 0||f,m=[];switch(r&&m.unshift(qR.of([qU])),p&&(typeof p==`boolean`?m.unshift(yq()):m.unshift(yq(p))),d&&m.unshift(Uz(d)),l){case`light`:m.push(Lq);break;case`dark`:m.push(Iq);break;case`none`:break;default:m.push(l)}return a===!1&&m.push(X.editable.of(!1)),s&&m.push(tN.readOnly.of(!0)),[...m]},zq=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(e=>!e.empty)}),Bq=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}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}},Vq=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Hq=null,Uq=()=>typeof window>`u`?new Vq:(Hq||=new Vq,Hq),Wq=X.theme({"& .cm-scroller":{height:`100% !important`}}),Gq=null,Kq=null;function qq(e,t,n,r,i,a){if(!e&&!t&&!n&&!r&&!i&&!a)return null;var o=JSON.stringify({height:e,minHeight:t,maxHeight:n,width:r,minWidth:i,maxWidth:a});return o===Gq||(Gq=o,Kq=X.theme({"&":{height:e,minHeight:t,maxHeight:n,width:r,minWidth:i,maxWidth:a}})),Kq}var Jq=RM.define(),Yq=200,Xq=[];function Zq(e){var t=e.value,n=e.selection,r=e.onChange,i=e.onStatistics,a=e.onCreateEditor,o=e.onUpdate,s=e.extensions,c=s===void 0?Xq:s,l=e.autoFocus,u=e.theme,d=u===void 0?`light`:u,f=e.height,p=f===void 0?null:f,m=e.minHeight,h=m===void 0?null:m,g=e.maxHeight,_=g===void 0?null:g,v=e.width,y=v===void 0?null:v,b=e.minWidth,x=b===void 0?null:b,S=e.maxWidth,C=S===void 0?null:S,w=e.placeholder,T=w===void 0?``:w,E=e.editable,D=E===void 0||E,O=e.readOnly,k=O!==void 0&&O,A=e.indentWithTab,j=A===void 0||A,M=e.basicSetup,N=M===void 0||M,P=e.root,F=e.initialState,ee=(0,B.useState)(),I=ee[0],te=ee[1],ne=(0,B.useState)(),re=ne[0],ie=ne[1],ae=(0,B.useState)(),oe=ae[0],se=ae[1],ce=(0,B.useState)(()=>({current:null}))[0],le=(0,B.useState)(()=>({current:null}))[0],ue=qq(p,h,_,y,x,C),de=X.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(Jq))&&(ce.current?ce.current.reset():(ce.current=new Bq(()=>{if(le.current){var e=le.current;le.current=null,e()}ce.current=null},Yq),Uq().add(ce.current)),r(e.state.doc.toString(),e)),i&&i(zq(e))}),fe=Rq({theme:d,editable:D,readOnly:k,placeholder:T,indentWithTab:j,basicSetup:N}),pe=[de,...ue?[ue]:[],Wq,...fe];return o&&typeof o==`function`&&pe.push(X.updateListener.of(o)),pe=pe.concat(c),(0,B.useLayoutEffect)(()=>{if(I&&!oe){var e={doc:t,selection:n,extensions:pe},r=F?tN.fromJSON(F.json,e,F.fields):tN.create(e);if(se(r),!re){var i=new X({state:r,parent:I,root:P});ie(i),a&&a(i,r)}}return()=>{re&&(se(void 0),ie(void 0))}},[I,oe]),(0,B.useEffect)(()=>{e.container&&te(e.container)},[e.container]),(0,B.useEffect)(()=>()=>{re&&(re.destroy(),ie(void 0)),ce.current&&=(ce.current.cancel(),null)},[re]),(0,B.useEffect)(()=>{l&&re&&re.focus()},[l,re]),(0,B.useEffect)(()=>{re&&re.dispatch({effects:q.reconfigure.of(pe)})},[d,c,p,h,_,y,x,C,T,D,k,j,N,r,o]),(0,B.useEffect)(()=>{if(t!==void 0){var e=re?re.state.doc.toString():``;if(re&&t!==e){var n=ce.current&&!ce.current.isDone,r=()=>{re&&t!==re.state.doc.toString()&&re.dispatch({changes:{from:0,to:re.state.doc.toString().length,insert:t||``},annotations:[Jq.of(!0)]})};n?le.current=r:r()}}},[t,re]),{state:oe,setState:se,view:re,setView:ie,container:I,setContainer:te}}var Qq=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],$q=(0,B.forwardRef)((e,t)=>{var n=e.className,r=e.value,i=r===void 0?``:r,a=e.selection,o=e.extensions,s=o===void 0?[]:o,c=e.onChange,l=e.onStatistics,u=e.onCreateEditor,d=e.onUpdate,f=e.autoFocus,p=e.theme,m=p===void 0?`light`:p,h=e.height,g=e.minHeight,_=e.maxHeight,v=e.width,y=e.minWidth,b=e.maxWidth,x=e.basicSetup,S=e.placeholder,C=e.indentWithTab,w=e.editable,T=e.readOnly,E=e.root,D=e.initialState,O=kre(e,Qq),k=(0,B.useRef)(null),A=Zq({root:E,value:i,autoFocus:f,theme:m,height:h,minHeight:g,maxHeight:_,width:v,minWidth:y,maxWidth:b,basicSetup:x,placeholder:S,indentWithTab:C,editable:w,readOnly:T,selection:a,onChange:c,onStatistics:l,onCreateEditor:u,onUpdate:d,extensions:s,initialState:D}),j=A.state,M=A.view,N=A.container,P=A.setContainer;(0,B.useImperativeHandle)(t,()=>({editor:k.current,state:j,view:M}),[k,N,j,M]);var F=(0,B.useCallback)(e=>{k.current=e,P(e)},[P]);if(typeof i!=`string`)throw Error(`value must be typeof string but got `+typeof i);var ee=typeof m==`string`?`cm-theme-`+m:`cm-theme`;return(0,z.jsx)(`div`,KV({ref:F,className:``+ee+(n?` `+n:``)},O))});$q.displayName=`CodeMirror`;var eJ=/^(\d{4})-(\d{2})-(\d{2})$/,tJ=/^(\d{4}-\d{2}-\d{2})([T ])(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-](\d{2}):(\d{2}))?$/,nJ=[31,28,31,30,31,30,31,31,30,31,30,31],rJ=e=>e%4==0&&e%100!=0||e%400==0;function iJ(e){if(typeof e!=`string`)return!1;let t=eJ.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return r<1||r>12||i<1?!1:i<=(r===2&&rJ(n)?29:nJ[r-1])}function aJ(e){if(typeof e!=`string`)return null;let t=tJ.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u]=t;return!iJ(n)||Number(i)>23||Number(a)>59||o!==void 0&&Number(o)>59||l!==void 0&&(Number(l)>23||Number(u)>59)?null:{date:n,sep:r,hour:i,minute:a,second:o??null,fraction:s??null,offset:c??null}}var oJ=e=>aJ(e)!==null;function sJ(e){let t=e.second===null?``:`:${e.second}${e.fraction===null?``:`.${e.fraction}`}`;return`${e.date}${e.sep}${e.hour}:${e.minute}${t}${e.offset??``}`}function cJ(e){if(iJ(e))return Date.parse(`${e}T00:00:00Z`);let t=aJ(e);if(!t)return null;let n=(t.fraction??``).padEnd(3,`0`).slice(0,3);return Date.parse(`${t.date}T${t.hour}:${t.minute}:${t.second??`00`}.${n}${t.offset??`Z`}`)}function lJ({className:e,size:t=`default`,...n}){return(0,z.jsx)(uD,{"data-slot":`switch`,"data-size":t,className:T(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80`,e),...n,children:(0,z.jsx)(fD,{"data-slot":`switch-thumb`,className:T(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground`)})})}function uJ({className:e,...t}){return(0,z.jsx)(`textarea`,{"data-slot":`textarea`,className:T(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var dJ=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/,fJ=e=>String(e).padStart(2,`0`);function pJ(e){let t=aJ(e);if(!t||t.fraction!==null&&t.fraction.length>3)return null;let n=t.second===null?``:`:${t.second}${t.fraction===null?``:`.${t.fraction}`}`,r=t.fraction===null?t.second===null?60:1:.001;return{value:`${t.date}T${t.hour}:${t.minute}${n}`,step:r}}function mJ(e,t,n){let[r,i,a]=e.split(`-`).map(Number),o=-new Date(r,i-1,a,Number(t),Number(n)).getTimezoneOffset(),s=Math.abs(o);return`${o<0?`-`:`+`}${fJ(Math.floor(s/60))}:${fJ(s%60)}`}function hJ(e,t,n=mJ){let r=dJ.exec(e);if(!r)return null;let[,i,a,o,s,c]=r,l=t===null?null:aJ(t);if(!l)return sJ({date:i,sep:`T`,hour:a,minute:o,second:null,fraction:null,offset:n(i,a,o)});let u=l.fraction?.length??0,d=(c??``).replace(/0+$/,``).length;return sJ({date:i,sep:l.sep,hour:a,minute:o,second:l.second===null?null:s??`00`,fraction:l.fraction===null?null:(c??``).padEnd(u,`0`).slice(0,Math.max(u,d)),offset:l.offset})}var gJ=e=>{let t=/^([+-])(\d{2}):(\d{2})$/.exec(e??``);return t?(t[1]===`-`?-1:1)*(Number(t[2])*60+Number(t[3])):0};function _J(e,t){if(typeof e!=`string`)return;let n=cJ(e);if(n===null)return;let r=new Date(n+gJ(t)*6e4).toISOString(),i=aJ(e),a=i?.second==null?``:i.fraction===null?r.slice(16,19):r.slice(16,23);return`${r.slice(0,16)}${a}`}function vJ(e,t){return t===`date`?iJ(e)?null:`not a date`:t===`datetime`?oJ(e)?null:`not a datetime`:t===`list`?Array.isArray(e)?null:`not a list`:t===`map`?typeof e==`object`&&e&&!Array.isArray(e)?null:`not a map`:null}function yJ(e,t){return t===`date`||t===`datetime`?vJ(e,t)===null?cJ(e):null:typeof e==`number`?e:typeof e==`bigint`?Number(e):null}var bJ=e=>typeof e==`number`?e:cJ(e);function xJ(e,t,n,r){let i=yJ(e,t);return i===null?null:n!==void 0&&i<bJ(n)?`below min ${n}`:r!==void 0&&i>bJ(r)?`above max ${r}`:null}var SJ=e=>e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`,CJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),wJ=e=>Array.isArray(e)?`[${e.length}]`:CJ(e)?`{${Object.keys(e).length}}`:``,TJ=/^(import\s|export\s+(const|let|var|function|class|default|async|\{|\*))/,EJ=/^\s*([-*_]\s*){3,}$|^\s*\|?\s*:?-{3,}/;function DJ(e){let t=[],n=[],r=()=>{n.length>0&&t.push(n.join(` `)),n=[]},i=!1;for(let t of e.split(`
|
|
71
|
-
`)){if(/^\s*(```|~~~)/.test(t)){i=!i,r();continue}if(i||
|
|
72
|
-
`,` ⏎ `)};if(Array.isArray(e))return e.every(
|
|
73
|
-
`)||e.length>80?`textarea`:`text`:MJ(e)?`chips`:jJ(e)&&NJ(e)?`map`:`json`}function FJ(e){switch(e){case`BOOLEAN`:return!1;case`INTEGER`:case`REAL`:return 0;case`JSON`:return{};case`TEXT`:return``}}function IJ(e){return JSON.stringify(e??null,(e,t)=>jJ(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function LJ(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>IJ(e[n])!==IJ(t[n]))}function RJ(e,t){let n=LJ(e,t);return{values:Object.fromEntries(n.map(e=>[e,t[e]??null])),base:Object.fromEntries(n.map(t=>[t,e[t]??null]))}}function zJ(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=[...e];return t[r]=zJ(t[r],i,n),t}let a=jJ(e)?e:{};return{...a,[r]:zJ(a[r],i,n)}}function BJ(e,t,n,r){return e==null?null:vJ(e,t)??xJ(e,t,n,r)}function VJ({label:e,value:t,onChange:n,placeholder:r=kn(),removeLabel:i=e=>Jn({item:e}),accept:a=()=>!0,unique:o=!1,invalid:s=!1}){let[c,l]=(0,B.useState)(``),u=()=>{let e=c.trim();if(e===``)return l(``);a(e)&&(o&&t.includes(e)||n([...t,e]),l(``))};return(0,z.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center gap-1 rounded-md border ${s?`border-warn`:``} bg-background px-1.5 py-1 transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,children:[t.map((e,r)=>(0,z.jsxs)(`span`,{className:cA,children:[e,(0,z.jsx)(`button`,{type:`button`,"aria-label":i(e),className:`ml-1 opacity-60 hover:opacity-100 max-md:grid max-md:size-7 max-md:place-items-center`,onClick:()=>n(t.filter((e,t)=>t!==r)),children:(0,z.jsx)(Fk,{className:`size-3`})})]},`${r}-${e}`)),(0,z.jsx)(`input`,{"aria-label":e,className:`min-w-32 flex-1 bg-transparent px-1 text-base outline-none placeholder:text-muted-foreground md:text-sm`,placeholder:r,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),u()):e.key===`Backspace`&&!e.repeat&&c===``&&t.length>0&&n(t.slice(0,-1))},onBlur:u}),c.trim()!==``&&(0,z.jsx)(`button`,{type:`button`,"aria-label":Nn({field:e}),className:`rounded-md px-2 text-[13px] text-muted-foreground md:hidden`,onMouseDown:e=>e.preventDefault(),onClick:u,children:On()})]})}function HJ(e,t,n){let r=t?.find(t=>t.name===e.table)?.key;return e.target===void 0||e.target===r?{key:n}:{filter:[{col:e.target,op:`eq`,value:n}]}}function UJ({reference:e,value:t,className:n,children:r}){let{data:i}=ry();return(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.table},search:HJ(e,i?.tables,t),"aria-label":`open ${e.table} ${t}`,className:n??`text-tomato underline-offset-2 hover:underline`,onClick:e=>e.stopPropagation(),children:r??t})}var WJ=()=>Fh({from:`__root__`,select:e=>e.app!==void 0}),GJ=(0,B.createContext)(!1),KJ=()=>(0,B.useContext)(GJ),qJ,JJ=()=>qJ;function YJ(e,t=document.baseURI){return new URL(`-/apps/${encodeURIComponent(e)}/`,t).toString()}function XJ(e,t){let n=new URL(`.`,t).pathname,r=new URL(e).pathname;if(!r.startsWith(n))return;let i=/^-\/apps\/([^/]+)\/?$/.exec(r.slice(n.length))?.[1];if(i!==void 0)try{return decodeURIComponent(i)}catch{return}}var ZJ=`modulepreload`,QJ=function(e,t){return new URL(e,t).href},$J={},eY=function(e){return e.pathname.endsWith(`.css`)},tY=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},nY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=QJ(t,n);let r=s(t),i=eY(r);return tY($J,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ZJ,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},rY=e=>e.join(`.`),iY=(0,B.lazy)(()=>nY(()=>import(`./MarkdownField-DI3OMg7I.js`),__vite__mapDeps([0,1,2]),import.meta.url));function aY({path:e,value:t,problem:n,onChange:r,onValidity:i,readOnly:a}){let[o,s]=(0,B.useState)(()=>JSON.stringify(t,null,2)),[c,l]=(0,B.useState)(null),u=h(),d=(0,B.useRef)(JSON.stringify(t)),f=(0,B.useRef)(i);f.current=i;let p=rY(e);return(0,B.useEffect)(()=>{JSON.stringify(t)!==d.current&&(d.current=JSON.stringify(t),s(JSON.stringify(t,null,2)),l(null),f.current?.(p,!0))},[t,p]),(0,B.useEffect)(()=>()=>f.current?.(p,!0),[p]),(0,z.jsxs)(`div`,{children:[(0,z.jsx)($q,{"aria-label":p,value:o,extensions:[GV(),X.lineWrapping],theme:u,editable:!a,basicSetup:{lineNumbers:!1,foldGutter:!1},className:`overflow-hidden rounded-md border text-[12px] ${uY(n)}`,onChange:e=>{s(e);try{let t=JSON.parse(e);d.current=JSON.stringify(t),r(t),l(null),i?.(p,!0)}catch(e){l(e instanceof Error?e.message:String(e)),i?.(p,!1)}}}),c&&(0,z.jsx)(`p`,{className:`mt-1 text-[11px] text-err`,children:c})]})}var oY=e=>e===!0?`1`:e===!1?`0`:e==null?``:String(e);function sY({path:e,value:t,allowed:n,onChange:r,readOnly:i}){let a=oY(t),o=a!==``&&!n.some(e=>oY(e)===a);return(0,z.jsxs)(`select`,{"aria-label":rY(e),"aria-invalid":o||void 0,disabled:i,className:`${oA} w-full ${o?`border-warn text-warn`:``}`,value:a,onChange:e=>{let t=e.target.value;if(t===``)return r(null);let i=n.find(e=>oY(e)===t);i!==void 0&&r(i)},children:[(0,z.jsx)(`option`,{value:``,children:`—`}),o&&(0,z.jsx)(`option`,{value:a,children:`${a} (not in values)`}),n.map((e,t)=>(0,z.jsx)(`option`,{value:oY(e),children:String(e)},`${t}:${oY(e)}`))]})}function cY({path:e,value:t,type:n,reference:r,onChange:i}){let a=KJ(),o=r?.table??``,s=r?.key,{data:c}=V_({queryKey:[`refKeys`,o],queryFn:()=>Uv.rows(o,{limit:500,offset:0,filters:[]}),enabled:o!==``}),l=`ref-${rY(e)}`,u=t==null?``:String(t);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(Ik,{"aria-label":rY(e),list:l,value:u,onChange:e=>{let t=e.target.value;if(t===``)return i(null);let r=Number(t);i(n===`INTEGER`&&pY.test(t)&&Number.isSafeInteger(r)?r:t)}}),r&&u!==``&&!a&&(0,z.jsx)(UJ,{reference:r,value:u,className:`shrink-0 text-muted-foreground hover:text-foreground max-md:grid max-md:size-9 max-md:place-items-center max-md:text-foreground`,children:(0,z.jsx)(rO,{className:`size-4`})})]}),(0,z.jsx)(`datalist`,{id:l,children:s!==void 0&&[...new Set(c?.rows.flatMap(e=>e[s]==null?[]:[String(e[s])]))].map(e=>(0,z.jsx)(`option`,{value:e},e))})]})}function lY(e){let{path:t,value:n,problem:r,onChange:i}=e,a=Object.entries(n??{}),[o,s]=(0,B.useState)(null);return(0,z.jsxs)(`div`,{className:`rounded-lg border bg-panel px-2.5 pt-2.5 pb-1 ${uY(r)}`,children:[a.map(([r,a])=>(0,z.jsxs)(`div`,{className:`mb-2.5 grid grid-cols-[minmax(34px,auto)_1fr_auto] items-start gap-1.5`,children:[(0,z.jsx)(`span`,{className:`pt-1.5 font-mono text-[11px] text-syn-key max-md:text-[12.5px]`,children:r}),(0,z.jsx)(_Y,{...e,path:[...t,r],value:a,type:void 0,format:void 0,min:void 0,max:void 0,reference:void 0,label:void 0,onChange:e=>i({...n,[r]:e})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Jn({item:rY([...t,r])}),className:`pt-1.5 text-muted-foreground max-md:grid max-md:size-8 max-md:place-items-center max-md:pt-0`,onClick:()=>{let{[r]:e,...t}=n;i(t)},children:(0,z.jsx)(Fk,{className:`size-3.5`})})]},r)),o===null?(0,z.jsx)(`button`,{type:`button`,className:`pb-2 text-[11.5px] text-muted-foreground max-md:py-2 max-md:text-[13px]`,onClick:()=>s(``),children:Hn()}):(0,z.jsx)(Ik,{autoFocus:!0,"aria-label":Gn({field:rY(t)}),className:`mb-2 h-7`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()!==``&&(i({...n,[o.trim()]:``}),s(null)),e.key===`Escape`&&s(null)}})]})}var uY=e=>e?`border-warn`:``;function dY({path:e,value:t,min:n,max:r,problem:i,onChange:a}){return(0,z.jsx)(Ik,{type:`date`,"aria-label":rY(e),className:`${sA} font-mono ${uY(i)}`,value:typeof t==`string`?t:``,min:typeof n==`string`?n:void 0,max:typeof r==`string`?r:void 0,onChange:e=>a(e.target.value===``?null:e.target.value)})}function fY({path:e,value:t,min:n,max:r,problem:i,onChange:a}){let o=typeof t==`string`?t:``,s=o===``?null:pJ(o),c=aJ(o)?.offset??null,l=o===``?mJ(new Date().toISOString().slice(0,10),`12`,`00`):c,u=(0,B.useRef)(o);return o!==``&&(u.current=o),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 max-md:flex-wrap`,children:[(0,z.jsx)(Ik,{type:`datetime-local`,"aria-label":rY(e),className:`w-60 font-mono max-md:w-full ${uY(i)}`,step:s?.step??60,value:s?.value??``,min:_J(n,l),max:_J(r,l),onChange:e=>{if(e.target.value===``)return a(null);let t=hJ(e.target.value,u.current===``?null:u.current);t!==null&&a(t)}}),c&&(0,z.jsx)(`span`,{className:`font-mono text-[12px] text-muted-foreground`,children:c})]})}var pY=/^-?\d+$/,mY=/^-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i;function hY(e){let{path:t,value:n,type:r,format:i,reference:a,problem:o,onChange:s}=e,c=i===`date`||i===`datetime`,[l,u]=(0,B.useState)(()=>PJ(n,r,a!==void 0,i)),[d,f]=(0,B.useState)(n==null?``:String(n)),p=n==null?``:String(n),m=(e,t)=>{l===`unset`&&(u(t??PJ(e,r,!1,i)),f(e==null?``:String(e))),s(e)},h=e=>(0,z.jsx)(`button`,{type:`button`,"aria-label":In({field:rY(t),kind:e}),className:`shrink-0 rounded border px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground hover:text-foreground max-md:grid max-md:min-h-8 max-md:min-w-8 max-md:place-items-center`,onClick:()=>u(e===`text`?`text`:PJ(n,r,!1,i)),children:e===`text`?(0,z.jsx)(jk,{className:`size-3.5`}):i===`date`?(0,z.jsx)(sO,{className:`size-3.5`}):(0,z.jsx)(yO,{className:`size-3.5`})});if(e.allowed&&r!==`JSON`)return(0,z.jsx)(sY,{...e,allowed:e.allowed});switch(l){case`switch`:return(0,z.jsx)(lJ,{"aria-label":rY(t),checked:n===!0,onCheckedChange:m});case`number`:case`bigint`:return(0,z.jsx)(Ik,{"aria-label":rY(t),inputMode:r===`REAL`?`decimal`:`numeric`,className:`${sA} font-mono ${uY(o)}`,value:d,onChange:e=>{let t=e.target.value;f(t);let n=t.trim();if(r===`INTEGER`){if(!pY.test(n))return;let e=Number(n);s(Number.isSafeInteger(e)?e:n)}else mY.test(n)&&Number.isFinite(Number(n))&&s(Number(n))}});case`date`:case`datetime`:return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[l===`date`?(0,z.jsx)(dY,{...e}):(0,z.jsx)(fY,{...e}),h(`text`)]});case`text`:{let e=(0,z.jsx)(Ik,{"aria-label":rY(t),className:uY(o),value:p,onChange:e=>m(c&&e.target.value===``?null:e.target.value)});if(!c)return e;let a=PJ(n,r,!1,i)===i;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e,a&&h(`picker`)]})}case`textarea`:return(0,z.jsx)(uJ,{"aria-label":rY(t),className:uY(o),rows:4,value:p,onChange:e=>m(e.target.value)});case`markdown`:return(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(uJ,{"aria-label":rY(t),rows:4,value:p,readOnly:!0}),children:(0,z.jsx)(iY,{...e})});case`ref`:return(0,z.jsx)(cY,{...e});case`chips`:return(0,z.jsx)(VJ,{label:rY(t),value:n??[],onChange:s,invalid:o});case`map`:return(0,z.jsx)(lY,{...e});case`json`:return(0,z.jsx)(aY,{...e});case`unset`:if(r===`JSON`){let e=[{name:`map`,text:`{ } map`,next:{},chosen:`map`},{name:`list`,text:`[ ] list`,next:[],chosen:`chips`},{name:`JSON`,text:`JSON`,next:[],chosen:`json`}],n=i===`list`?e.filter(e=>e.name!==`map`):e;return(0,z.jsx)(`div`,{className:`flex gap-1.5`,children:n.map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-label":In({field:rY(t),kind:e.name}),className:`rounded border px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground hover:text-foreground`,onClick:()=>m(e.next,e.chosen),children:e.text},e.name))})}return(0,z.jsx)(`button`,{type:`button`,"aria-label":rY(t),className:`text-[12px] text-muted-foreground hover:text-foreground`,onClick:()=>m(FJ(r??`TEXT`)),children:Yn()})}}var gY=e=>e==null||(Array.isArray(e)?e.length===0:typeof e==`object`&&Object.keys(e).length===0);function _Y(e){let{label:t,value:n,type:r,readOnly:i,onChange:a}=e,o=BJ(n,e.format,e.min,e.max),[s]=(0,B.useState)(()=>r===`JSON`&&n==null&&e.format!==`map`),[c,l]=(0,B.useState)(0);return(0,z.jsxs)(`div`,{"data-problem":o??void 0,children:[t!==void 0&&(0,z.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[t,s&&!i&&n!=null&&(0,z.jsxs)(`button`,{type:`button`,"aria-label":Vn({field:rY(e.path)}),className:`inline-flex shrink-0 items-center gap-1 rounded px-1 text-[12px] font-semibold text-muted-foreground max-md:text-[13px] font-medium hover:text-foreground`,onClick:()=>{(gY(n)||window.confirm(Rn()))&&(a(null),l(e=>e+1))},children:[(0,z.jsx)(sk,{className:`size-3`}),Ln()]})]}),(0,z.jsx)(hY,{...e,problem:o!==null},c),o&&(0,z.jsx)(`p`,{className:`mt-1 text-[11px] text-warn`,children:o})]})}function vY({table:e,open:t,onOpenChange:n,initial:r={},initialKey:i=``}){let a=Nh(),{connected:o}=ay(),s=oy(),[c,l]=(0,B.useState)(i),[u,d]=(0,B.useState)(r),[f,p]=(0,B.useState)(0),m=H_({mutationFn:()=>{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e!=null&&e!==``));return Uv.create(e.name,c,t)},onMutate:()=>s({type:`saved`,table:e.name,key:c,at:Date.now()}),onError:()=>s({type:`cancelled`,table:e.name,key:c}),onSuccess:()=>{n(!1),l(i),d(r),p(e=>e+1),a({to:`/t/$table`,params:{table:e.name},search:e=>({...e,key:c})})}}),h=lA(m.error);return(0,z.jsx)(qk,{open:t,onOpenChange:n,children:(0,z.jsxs)(Qk,{pinned:!0,className:`sm:max-w-2xl`,children:[(0,z.jsx)($k,{pinned:!0,children:(0,z.jsx)(nA,{children:Mt({table:e.name})})}),(0,z.jsxs)(eA,{children:[(0,z.jsxs)(`label`,{className:aA,children:[(e.mode===`files`?Yt:Qt)({key:e.key}),(0,z.jsx)(Ik,{"aria-label":sn(),value:c,onChange:e=>l(e.target.value),className:`mt-1 font-mono`})]}),h?.field===`key`&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:h.message}),Object.entries(e.columns).filter(([t])=>t!==e.key&&!(e.captures??[]).some(e=>e.column===t)).map(([t,n])=>(0,z.jsx)(`div`,{children:(0,z.jsx)(_Y,{path:[t],label:(0,z.jsxs)(`div`,{className:T(`flex-1`,aA,e.required.includes(t)&&u[t]==null&&`text-warn`),children:[t,e.required.includes(t)&&(0,z.jsx)(`span`,{"aria-label":Qa(),children:` *`})]}),value:u[t]??null,type:n,format:Object.hasOwn(e.formats,t)?e.formats[t]:void 0,mdx:e.files?.endsWith(`.mdx`),allowed:Object.hasOwn(e.values,t)?e.values[t]:void 0,min:Object.hasOwn(e.min,t)?e.min[t]:void 0,max:Object.hasOwn(e.max,t)?e.max[t]:void 0,reference:e.references.find(e=>e.column===t),onChange:e=>d({...u,[t]:e})})},`${f}:${t}`)),h&&h.field!==`key`&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:h.message})]}),(0,z.jsxs)(tA,{pinned:!0,children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>n(!1),children:gt()}),(0,z.jsx)(V,{disabled:c===``||m.isPending||!o,title:o?void 0:yt(),onClick:()=>m.mutate(),children:An()})]})]})})}function yY({title:e}){return(0,z.jsx)(`div`,{className:`p-6 text-muted-foreground`,children:Rl({title:e})})}var bY=63,xY=64,SY=1,CY=2,wY=3,TY=4,EY=5,DY=6,OY=7,kY=65,AY=66,jY=8,MY=9,NY=10,PY=11,FY=12,IY=13,LY=19,RY=20,zY=29,BY=33,VY=34,HY=47,UY=0,WY=1,GY=2,KY=3,qY=4,JY=class{constructor(e,t,n){this.parent=e,this.depth=t,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n}};JY.top=new JY(null,-1,UY);function YY(e,t){for(let n=0,r=t-e.pos-1;;r--,n++){let t=e.peek(r);if(ZY(t)||t==-1)return n}}function XY(e){return e==32||e==9}function ZY(e){return e==10||e==13}function QY(e){return XY(e)||ZY(e)}function $Y(e){return e<0||QY(e)}var eX=new aj({start:JY.top,reduce(e,t){return e.type==KY&&(t==RY||t==VY)?e.parent:e},shift(e,t,n,r){if(t==wY)return new JY(e,YY(r,r.pos),WY);if(t==kY||t==EY)return new JY(e,YY(r,r.pos),GY);if(t==bY)return e.parent;if(t==LY||t==BY)return new JY(e,0,KY);if(t==IY&&e.type==qY)return e.parent;if(t==HY){let t=/[1-9]/.exec(r.read(r.pos,n.pos));if(t)return new JY(e,e.depth+ +t[0],qY)}return e},hash(e){return e.hash}});function tX(e,t,n=0){return e.peek(n)==t&&e.peek(n+1)==t&&e.peek(n+2)==t&&$Y(e.peek(n+3))}var nX=new ZA((e,t)=>{if(e.next==-1&&t.canShift(xY))return e.acceptToken(xY);let n=e.peek(-1);if((ZY(n)||n<0)&&t.context.type!=KY){if(tX(e,45)){if(t.canShift(bY))e.acceptToken(bY);else return e.acceptToken(SY,3)}if(tX(e,46)){if(t.canShift(bY))e.acceptToken(bY);else return e.acceptToken(CY,3)}let n=0;for(;e.next==32;)n++,e.advance();(n<t.context.depth||n==t.context.depth&&t.context.type==WY&&(e.next!=45||!$Y(e.peek(1))))&&e.next!=-1&&!ZY(e.next)&&e.next!=35&&e.acceptToken(bY,-n)}},{contextual:!0}),rX=new ZA((e,t)=>{if(t.context.type==KY)e.next==63&&(e.advance(),$Y(e.next)&&e.acceptToken(OY));else if(e.next==45)e.advance(),$Y(e.next)&&e.acceptToken(t.context.type==WY&&t.context.depth==YY(e,e.pos-1)?TY:wY);else if(e.next==63)e.advance(),$Y(e.next)&&e.acceptToken(t.context.type==GY&&t.context.depth==YY(e,e.pos-1)?DY:EY);else{let n=e.pos;for(;;)if(XY(e.next)){if(e.pos==n)return;e.advance()}else if(e.next==33)sX(e);else if(e.next==38)cX(e);else if(e.next==42){cX(e);break}else if(e.next==39||e.next==34){if(lX(e,!0))break;return}else if(e.next==91||e.next==123){if(!uX(e))return;break}else{mX(e,!0,!1,0);break}for(;XY(e.next);)e.advance();if(e.next==58){if(e.pos==n&&t.canShift(zY))return;$Y(e.peek(1))&&e.acceptTokenTo(t.context.type==GY&&t.context.depth==YY(e,n)?AY:kY,n)}}},{contextual:!0});function iX(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 aX(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function oX(e,t){return e.next==37?(e.advance(),aX(e.next)&&e.advance(),aX(e.next)&&e.advance(),!0):iX(e.next)||t&&e.next==44?(e.advance(),!0):!1}function sX(e){if(e.advance(),e.next==60){for(e.advance();;)if(!oX(e,!0)){e.next==62&&e.advance();break}}else for(;oX(e,!1););}function cX(e){for(e.advance();!$Y(e.next)&&fX(e.next)!=`f`;)e.advance()}function lX(e,t){let n=e.next,r=!1,i=e.pos;for(e.advance();;){let a=e.next;if(a<0)break;if(e.advance(),a==n){if(a==39){if(e.next==39)e.advance();else break}else break}else if(a==92&&n==34)e.next>=0&&e.advance();else if(ZY(a)){if(t)return!1;r=!0}else if(t&&e.pos>=i+1024)return!1}return!r}function uX(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(!lX(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||ZY(e.next))return!1;else e.advance()}var dX=`iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif`;function fX(e){return e<33?`u`:e>125?`s`:dX[e-33]}function pX(e,t){let n=fX(e);return n!=`u`&&!(t&&n==`f`)}function mX(e,t,n,r){if(fX(e.next)==`s`||(e.next==63||e.next==58||e.next==45)&&pX(e.peek(1),n))e.advance();else return!1;let i=e.pos;for(;;){let a=e.next,o=0,s=r+1;for(;QY(a);){if(ZY(a)){if(t)return!1;s=0}else s++;a=e.peek(++o)}if(!(a>=0&&(a==58?pX(e.peek(o+1),n):a==35?e.peek(o-1)!=32:pX(a,n)))||!n&&s<=r||s==0&&!n&&(tX(e,45,o)||tX(e,46,o)))break;if(t&&fX(a)==`f`)return!1;for(let t=o;t>=0;t--)e.advance();if(t&&e.pos>i+1024)return!1}return!0}var hX=new ZA((e,t)=>{if(e.next==33)sX(e),e.acceptToken(FY);else if(e.next==38||e.next==42){let t=e.next==38?NY:PY;cX(e),e.acceptToken(t)}else e.next==39||e.next==34?(lX(e,!1),e.acceptToken(MY)):mX(e,!1,t.context.type==KY,t.context.depth)&&e.acceptToken(jY)}),gX=new ZA((e,t)=>{let n=t.context.type==qY?t.context.depth:-1,r=e.pos;scan:for(;;){let i=0,a=e.next;for(;a==32;)a=e.peek(++i);if(!i&&(tX(e,45,i)||tX(e,46,i))||!ZY(a)&&(n<0&&(n=Math.max(t.context.depth+1,i)),i<n))break;for(;;){if(e.next<0)break scan;let t=ZY(e.next);if(e.advance(),t)continue scan;r=e.pos}}e.acceptTokenTo(IY,r)}),_X=dj({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}),vX=oj.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:eX,nodeProps:[[`isolate`,-3,8,9,14,``],[`openedBy`,18,`[`,32,`{`],[`closedBy`,19,`]`,33,`}`]],propSources:[_X],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:[nX,rX,hX,gX,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),yX=UB.define({name:`yaml`,parser:vX.configure({props:[iV.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:oV({closing:`}`}),FlowSequence:oV({closing:`]`})}),uV.add({"FlowMapping FlowSequence":dV,"Item Pair BlockLiteral":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{commentTokens:{line:`#`},indentOnInput:/^\s*[\]\}]$/}});function bX(){return new QB(yX)}W.meta;function xX({className:e,orientation:t=`horizontal`,...n}){return(0,z.jsx)(TD,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:T(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var SX=O(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function CX({className:e,variant:t=`default`,...n}){return(0,z.jsx)(DD,{"data-slot":`tabs-list`,"data-variant":t,className:T(SX({variant:t}),e),...n})}function wX({className:e,...t}){return(0,z.jsx)(kD,{"data-slot":`tabs-trigger`,className:T(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function TX({className:e,...t}){return(0,z.jsx)(jD,{"data-slot":`tabs-content`,className:T(`flex-1 outline-none`,e),...t})}var EX=`(width < 48rem)`,DX=e=>{let t=matchMedia(EX);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},OX=()=>(0,B.useSyncExternalStore)(DX,()=>matchMedia(EX).matches);function kX(e,t){let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return Yr();let r=new Intl.RelativeTimeFormat(E(),{numeric:`always`}),i=Math.round(n/60);if(i<60)return r.format(-i,`minute`);let a=Math.round(i/60);if(a<24)return r.format(-a,`hour`);let o=Math.round(a/24);return o<30?r.format(-o,`day`):e.slice(0,10)}var AX=e=>e==null?ni():typeof e==`string`?e:JSON.stringify(e),jX=(e,t,n)=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0});function MX(e,t,n){let r={};for(let t of Object.keys(e))jX(r,t,null);for(let[e,n]of Object.entries(t))jX(r,e,n);return jX(r,n,e[n]),r}function NX(e){let t=e?.at(-1);if(!e||!t||t.state!==`ok`)return null;let n=e.reduce((e,t)=>e+(t.state===`ok`?t.entries.filter(e=>e.kind===`commit`).length:0),0);return t.next===null?String(n):`${n}+`}function PX(e,t,n){return U_({queryKey:[`history`,e,t],queryFn:({pageParam:n})=>Uv.history(e,t,n),initialPageParam:void 0,getNextPageParam:e=>e.state===`ok`?e.next??void 0:void 0,enabled:n})}var FX=e=>e.slice(0,7),IX=e=>e.sha??`wip`;function LX({title:e,children:t}){return(0,z.jsxs)(`div`,{className:`px-2 py-10 text-center text-[13px] text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`mb-1.5 text-[15px] font-semibold text-foreground`,children:e}),t]})}function RX({children:e}){return(0,z.jsx)(`span`,{className:`rounded border px-1.5 font-mono text-[11px] text-muted-foreground`,children:e})}function zX({table:e,recordKey:t,rev:n}){let{data:r,error:i}=V_({queryKey:[`history`,e,t,`diff`,n],queryFn:()=>Uv.historyDiff(e,t,n)});return i?(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:i.message}):r?(0,z.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-panel py-2 font-mono text-[12px] leading-relaxed`,children:r.text.split(`
|
|
74
|
-
`).map((e,t)=>(0,z.jsx)(`span`,{className:T(`block px-3 whitespace-pre`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-ok/15 text-ok`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-err-soft text-err`),children:e},t))}):(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:bt()})}function BX({entry:e,...t}){let[n,r]=(0,B.useState)(`fields`),i=e.record,a=i!==null&&LJ(t.current,MX(t.current,i,t.keyColumn)).length>0,o=n===`yaml`||e.changes.length===0;return(0,z.jsxs)(`div`,{className:`rounded-b-lg border border-t-0 p-3`,children:[(0,z.jsxs)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:[e.changes.length>0?(0,z.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border text-[12px]`,children:[`fields`,`yaml`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>r(e),className:T(`px-2.5 py-0.5`,n===e&&`bg-foreground text-background`),children:e===`fields`?Jr():li()},e))}):(0,z.jsx)(`span`,{className:`text-[12px] text-muted-foreground`,children:e.unreadable?si():ti()}),e.kind===`commit`&&e.sha&&i!==null&&t.canRestore&&(0,z.jsx)(V,{variant:`outline`,size:`sm`,className:`ml-auto`,disabled:!a,title:a?ii():ai(),onClick:()=>t.onRestore(i,e.sha),children:ri()})]}),o?(0,z.jsx)(zX,{table:t.table,recordKey:t.recordKey,rev:IX(e)}):e.changes.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[7rem_1fr] gap-2 border-b border-dashed py-2 last:border-b-0`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12px] break-all text-muted-foreground`,children:e.path}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1 font-mono text-[12px]`,children:[e.from!==null&&(0,z.jsx)(`span`,{className:`rounded bg-err-soft px-2 py-0.5 break-all text-err line-through`,children:AX(e.from)}),(0,z.jsx)(`span`,{className:`rounded bg-ok/15 px-2 py-0.5 break-all text-ok`,children:AX(e.to)})]})]},e.path))]})}function VX(e){let{query:t}=e,[n,r]=(0,B.useState)(null);if(t.error)return(0,z.jsx)(`p`,{className:`text-[13px] text-err`,children:t.error.message});let i=t.data?.pages[0];if(!t.data||!i)return(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:bt()});if(i.state===`nogit`)return(0,z.jsx)(LX,{title:$r(),children:ei()});if(i.state===`untracked`)return(0,z.jsx)(LX,{title:Zr(),children:Qr()});if(i.state===`error`)return(0,z.jsx)(`p`,{className:`text-[13px] text-err`,children:i.message});let a=t.data.pages.flatMap(e=>e.state===`ok`?e.entries:[]),o=Date.now();return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`ol`,{className:`relative m-0 list-none p-0 before:absolute before:top-3.5 before:bottom-3.5 before:left-[11px] before:w-0.5 before:bg-border`,children:a.map(t=>{let i=IX(t),a=n===i;return(0,z.jsxs)(`li`,{className:`relative mb-1.5 pl-8`,children:[(0,z.jsx)(`span`,{className:T(`absolute top-3.5 left-1 size-4 rounded-full border-2 border-muted-foreground bg-background`,t.kind===`wip`&&`border-dashed border-warn`,t.head&&`border-tomato`,a&&`border-primary bg-primary`)}),(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>r(a?null:i),className:T(`block w-full rounded-lg border border-transparent px-3 py-2 text-left hover:bg-panel`,a&&`rounded-b-none border-border bg-panel`),children:[(0,z.jsxs)(`span`,{className:`flex items-baseline gap-2 text-[14px] font-semibold`,children:[t.kind===`wip`?ci():t.subject,t.kind===`wip`&&(0,z.jsx)(`span`,{className:`rounded bg-warn-soft px-1.5 text-[11px] text-warn`,children:oi()}),t.head&&(0,z.jsx)(`span`,{className:`rounded bg-chip px-1.5 text-[11px] text-chip-foreground`,children:`HEAD`})]}),(0,z.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[12px] text-muted-foreground`,children:[t.sha&&(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:FX(t.sha)}),t.author&&(0,z.jsx)(`span`,{children:t.author}),(0,z.jsx)(`span`,{children:kX(t.date,o)})]}),t.renamedFrom?(0,z.jsxs)(`span`,{className:`mt-1 block font-mono text-[12px] text-muted-foreground`,children:[t.renamedFrom,` → `,t.path]}):(0,z.jsxs)(`span`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[t.event===`created`&&(0,z.jsx)(RX,{children:Kr()}),t.event===`deleted`&&(0,z.jsx)(RX,{children:qr()}),t.changes.map(e=>(0,z.jsx)(RX,{children:e.path},e.path))]})]}),a&&(0,z.jsx)(BX,{...e,entry:t})]},i)})}),t.hasNextPage&&(0,z.jsx)(`button`,{type:`button`,disabled:t.isFetchingNextPage,onClick:()=>void t.fetchNextPage(),className:`mt-2 ml-8 text-[12px] text-muted-foreground`,children:Xr()})]})}function HX({table:e,recordKey:t}){let n=vee(e,t);if(!n)return null;let r=n.state===`pending`?Xa():n.state===`applied`?Ya({file:n.file}):n.state===`failed`?Ga({reason:n.reason}):Ka(),i=n.state===`applied`?`text-ok`:n.state===`failed`?`text-err`:`text-muted-foreground`;return(0,z.jsx)(`span`,{role:`status`,className:`text-[11px] ${i}`,children:r})}var UX={min:320,max:()=>Math.max(320,Math.floor(window.innerWidth*.7))},WX={min:180,max:()=>Math.max(180,Math.min(480,Math.floor(window.innerWidth*.4)))},GX=(e,t)=>Math.min(t.max(),Math.max(t.min,Math.round(e)));function KX(e,t,n){try{let r=localStorage.getItem(e);return r!==null&&Number.isFinite(Number(r))?GX(Number(r),n):t}catch{return t}}function qX(e,t,n=UX){let[r,i]=(0,B.useState)(()=>KX(e,t,n));return[r,r=>{let a=r===null?t:GX(r,n);i(a);try{r===null?localStorage.removeItem(e):localStorage.setItem(e,String(a))}catch{}}]}var JX=e=>{let t=window.visualViewport;return t?.addEventListener(`resize`,e),t?.addEventListener(`scroll`,e),()=>{t?.removeEventListener(`resize`,e),t?.removeEventListener(`scroll`,e)}};function YX(e){let t=(0,B.useSyncExternalStore)(JX,()=>window.visualViewport?.height);return e?t:void 0}var XX=16;function ZX({width:e,label:t,onResize:n,edge:r=`left`,bounds:i=UX}){let a=r===`left`?-1:1;return(0,z.jsx)(`div`,{role:`separator`,"aria-label":t,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":i.min,"aria-valuemax":i.max(),tabIndex:0,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault();let r=t.currentTarget;r.setPointerCapture?.(t.pointerId),document.body.setAttribute(`data-resizing`,``);let i=t.clientX,o=t=>n(e+a*(t.clientX-i)),s=!1,c=()=>{if(s)return;s=!0,document.removeEventListener(`pointermove`,o),document.removeEventListener(`pointerup`,c),document.removeEventListener(`pointercancel`,c),r.removeEventListener(`lostpointercapture`,c),document.body.removeAttribute(`data-resizing`);let e=e=>e.stopPropagation();window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),0)};document.addEventListener(`pointermove`,o),document.addEventListener(`pointerup`,c),document.addEventListener(`pointercancel`,c),r.addEventListener(`lostpointercapture`,c)},onDoubleClick:()=>n(null),onKeyDown:t=>{let r=t.key===`ArrowLeft`?-a*XX:t.key===`ArrowRight`?a*XX:0;r!==0&&(t.preventDefault(),n(e+r))},className:T(`absolute inset-y-0 z-10 w-1 cursor-col-resize outline-none hover:bg-primary/40 focus-visible:bg-primary/40`,r===`left`?`-left-0.5`:`-right-0.5`)})}var QX={overlay:`absolute inset-y-0 right-0 z-20 shadow-xl`,docked:`relative`};function $X({layout:e,widthKey:t,defaultWidth:n,resizeLabel:r,className:i,children:a,...o}){let s=OX(),[c,l]=qX(t,n),u=YX(s),d=s?u?{height:u}:void 0:{width:c};return(0,z.jsxs)(`aside`,{...o,className:T(`flex min-h-0 flex-col border-l bg-background`,QX[e],`max-md:fixed max-md:inset-0 max-md:z-40 max-md:h-dvh max-md:border-l-0 max-md:shadow-none max-md:animate-[y-slide-up_160ms_ease-out]`,i),style:d,children:[!s&&(0,z.jsx)(ZX,{width:c,label:r,onResize:l}),a]})}function eZ({onClose:e,className:t,children:n}){let r=OX();return(0,z.jsxs)(`header`,{className:T(`flex items-center gap-2 border-b px-3.5 py-2.5 max-md:gap-1 max-md:px-2 max-md:pt-[calc(0.625rem+env(safe-area-inset-top))]`,t),children:[r&&(0,z.jsx)(V,{variant:`ghost`,size:`icon-lg`,"aria-label":_t(),onClick:e,children:(0,z.jsx)($D,{className:`size-5`})}),n,!r&&(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":_t(),onClick:e,children:(0,z.jsx)(Fk,{className:`size-5`})})]})}function tZ({className:e,...t}){return(0,z.jsx)(`div`,{...t,className:T(`flex items-center gap-2 border-t px-3.5 py-2.5 max-md:pb-[calc(0.625rem+env(safe-area-inset-bottom))]`,e)})}var nZ=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends nZ{};function rZ(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function iZ(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function aZ(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function oZ(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function sZ(e,t){return aZ(e,t,``)}function cZ(e,t){return oZ(e,t,``)}function lZ(e,t){return t.slice(0,uZ(e,t))}function uZ(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function dZ(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function fZ(e,t){if(t)return mZ(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function pZ(e,t){if(t)return mZ(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function mZ(e,t){if(!t)return[pZ(e),fZ(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=dZ(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var hZ=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,gZ=RegExp(`[${hZ}]+|\\s+|[^${hZ}]`,`ug`),_Z=new class extends nZ{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=dZ(e,r)}else n=e.match(gZ)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&yZ(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&yZ(n,i,r,null,t.intlSegmenter),e}};function vZ(e,t,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?xZ(e,t,n):_Z.diff(e,t,n)}function yZ(e,t,n,r,i){if(t&&n){let[a,o]=mZ(t.value,i),[s,c]=mZ(n.value,i);if(e){let r=rZ(a,s);e.value=oZ(e.value,s,r),t.value=sZ(t.value,r),n.value=sZ(n.value,r)}if(r){let e=iZ(o,c);r.value=aZ(r.value,c,e),t.value=cZ(t.value,e),n.value=cZ(n.value,e)}}else if(n){if(e){let e=pZ(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=pZ(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=pZ(r.value,i),[a,o]=mZ(t.value,i),s=rZ(n,a);t.value=sZ(t.value,s);let c=iZ(sZ(n,s),o);t.value=cZ(t.value,c),r.value=aZ(r.value,n,c),e.value=oZ(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=pZ(r.value,i),n=lZ(fZ(t.value,i),e);t.value=cZ(t.value,n)}else if(e){let n=lZ(fZ(e.value,i),pZ(t.value,i));t.value=sZ(t.value,n)}}var bZ=new class extends nZ{tokenize(e){let t=RegExp(`(\\r?\\n)|[${hZ}]+|[^\\S\\n\\r]+|[^${hZ}]`,`ug`);return e.match(t)||[]}};function xZ(e,t,n){return bZ.diff(e,t,n)}var SZ=new class extends nZ{constructor(){super(...arguments),this.tokenize=wZ}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
69
|
+
--\u2028\u2029-]`,Ez),Oz={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`},kz=null;function Az(){if(kz==null&&typeof document<`u`&&document.body){let e=document.body.style;kz=(e.tabSize??e.MozTabSize)!=null}return kz||!1}var jz=K.define({combine(e){let t=nN(e,{render:null,specialChars:Dz,addSpecialChars:null});return(t.replaceTabs=!Az())&&(t.specialChars=RegExp(` |`+t.specialChars.source,Ez)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+`|`+t.addSpecialChars.source,Ez)),t}});function Mz(e={}){return[jz.of(e),Pz()]}var Nz=null;function Pz(){return Nz||=AF.fromClass(class{constructor(e){this.view=e,this.decorations=Y.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(jz)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Tz({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=Qj(t[0],0);if(a==9){let e=i.lineAt(r),t=n.state.tabSize,a=SN(e.text,t,r-e.from);return Y.replace({widget:new Rz((t-a%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=Y.replace({widget:new Lz(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(jz);e.startState.facet(jz)==t?this.decorations=this.decorator.updateDeco(e,this.decorations):(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view))}},{decorations:e=>e.decorations})}var Fz=`•`;function Iz(e){return e>=32?Fz:e==10?``:String.fromCharCode(9216+e)}var Lz=class extends rP{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Iz(this.code),n=e.state.phrase(`Control character`)+` `+(Oz[this.code]||`0x`+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement(`span`);return i.textContent=t,i.title=n,i.setAttribute(`aria-label`,n),i.className=`cm-specialChar`,i}ignoreEvent(){return!1}},Rz=class extends rP{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement(`span`);return e.textContent=` `,e.className=`cm-tab`,e.style.width=this.width+`px`,e}ignoreEvent(){return!1}};function zz(){return Vz}var Bz=Y.line({class:`cm-activeLine`}),Vz=AF.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(Bz.range(i.from)),t=i.from)}return Y.set(n)}},{decorations:e=>e.decorations}),Hz=class extends rP{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?_P(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=CP(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function Uz(e){let t=AF.fromClass(class{constructor(t){this.view=t,this.placeholder=e?Y.set([Y.widget({widget:new Hz(e),side:1}).range(0)]):Y.none}get decorations(){return this.view.state.doc.length?Y.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,X.contentAttributes.of({"aria-placeholder":e})]:t}var Wz=2e3;function Gz(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>Wz||n.off>Wz||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(G.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=CN(n.text,o,e.tabSize,!0);if(r<0)a.push(G.cursor(n.to));else{let t=CN(n.text,s,e.tabSize);a.push(G.range(n.from+r,n.from+t))}}}return a}function Kz(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function qz(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>Wz?-1:i==r.length?Kz(e,t.clientX):SN(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Jz(e,t){let n=qz(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=qz(e,t);if(!o)return r;let s=Gz(e.state,n,o);return s.length?a?G.create(s.concat(r.ranges)):G.create(s):r}}:null}function Yz(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return X.mouseSelectionStyle.of((e,n)=>t(n)?Jz(e,n):null)}var Xz={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Zz={style:`cursor: crosshair`};function Qz(e={}){let[t,n]=Xz[e.key||`Alt`],r=AF.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,X.contentAttributes.of(e=>e.plugin(r)?.isDown?Zz:null)]}var $z=`-10000px`,eB=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function tB(e){let t=e.dom.ownerDocument.documentElement,n=t.clientWidth,r=getComputedStyle(t);if(!/stable/.test(r.scrollbarGutter||``))return{left:0,right:n};let i=t.getBoundingClientRect(),a=e.win.scrollX;return{left:Math.max(0,i.left+a-parseFloat(r.marginLeft)),right:Math.min(n,i.right+a+parseFloat(r.marginRight))}}function nB(e){let{left:t,right:n}=tB(e);return{top:0,left:t,right:n,bottom:e.dom.ownerDocument.documentElement.clientHeight}}var rB=K.define({combine:e=>({position:J.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||nB})}),iB=new WeakMap,aB=AF.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(rB);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 eB(e,lB,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.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(rB);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.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 e of this.manager.tooltipViews)this.container.appendChild(e.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 e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=$z,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 t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1,r=0;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(J.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}else r=tB(this.view).left;let i=this.view.scrollDOM.getBoundingClientRect(),a=VF(this.view);return{visible:{left:i.left+a.left,top:i.top+a.top,right:i.right-a.right,bottom:i.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(rB).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n,fixedLeft:r}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=$z;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=iB.get(c)??d.bottom-d.top,g=c.offset||cB,_=this.view.textDirection==HP.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=$z;continue}iB.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,oB(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,oB(l,(v-e.fixedLeft)/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.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=$z}},{eventObservers:{scroll(){this.maybeMeasure()}}});function oB(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var sB=X.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:`14px`,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`}}}),cB={x:0,y:0},lB=K.define({enables:[aB,sB]}),uB=K.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),dB=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new eB(e,uB,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},Sne=lB.compute([uB],e=>{let t=e.facet(uB);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:dB.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),fB=K.define(),Cne=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener(`mouseleave`,this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener(`mousemove`,this.mousemove=this.mousemove.bind(this))}update(e){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 e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==HP.RTL?-1:1;i=t.x<n.left?-o:o}this.activateHover(e,r,i)}activateHover(e,t,n,r){let i=this.source(e,t,n),a=t=>{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>EF(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(aB),t=e?e.manager.tooltips.findIndex(e=>e.create==dB.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!wne(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!Tne(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},pB=4;function wne(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-pB&&t.clientX<=r+pB&&t.clientY>=i-pB&&t.clientY<=a+pB}function Tne(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let c=e.posAtCoords({x:r,y:i},!1);return c>=t&&c<=n}function Ene(e,t={}){let n=q.define(),r=new WeakMap,i=bM.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,nM.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(One)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>uB.from(e)}),a=AF.define(a=>new Cne(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,fB.of(a),Sne]}}function Dne(e,t,n,r={}){let i=e.state.facet(fB).map(t=>e.plugin(t)).filter(e=>!!e);if(r.tooltip&&r.tooltip.active){let e=i.find(e=>e.field==r.tooltip.active);e&&(i=[e])}for(let a of i)a.activateHover(e,t,n,r.until??(()=>!1))}function mB(e,t){let n=e.plugin(aB);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var One=q.define(),hB=K.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function gB(e,t){let n=e.plugin(_B),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var _B=AF.fromClass(class{constructor(e){this.input=e.state.facet(bB),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(hB);this.top=new vB(e,!0,t.topContainer),this.bottom=new vB(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(hB);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new vB(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new vB(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(bB);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>X.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),vB=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),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`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=yB(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=yB(e)}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 e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function yB(e){let t=e.nextSibling;return e.remove(),t}var bB=K.define({enables:_B});function kne(e,t){let n,r=new Promise(e=>n=e),i=e=>jne(e,t,n);e.state.field(xB,!1)?e.dispatch({effects:SB.of(i)}):e.dispatch({effects:q.appendConfig.of(xB.init(()=>[i]))});let a=CB.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(xB).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}function Ane(e,t){let n=e.state.field(xB,!1)||[];for(let r of n){let n=gB(e,r);if(n&&n.dom.classList.contains(t))return n}return null}var xB=bM.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(SB)?e=[n.value].concat(e):n.is(CB)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>bB.computeN([e],t=>t.field(e))}),SB=q.define(),CB=q.define();function jne(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=RN(`form`),t.input){let e=RN(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(RN(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(RN(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=RN(`div`,r,RN(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var wB=class extends rN{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};wB.prototype.elementClass=``,wB.prototype.toDOM=void 0,wB.prototype.mapMode=nM.TrackBefore,wB.prototype.startSide=wB.prototype.endSide=-1,wB.prototype.point=!0;var TB=K.define(),Mne=K.define(),Nne={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>cN.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},EB=K.define();function Pne(e){return[OB(),EB.of({...Nne,...e})]}var DB=K.define({combine:e=>e.some(e=>e)});function OB(e){let t=[Fne];return e&&e.fixed===!1&&t.push(DB.of(!0)),t}var Fne=AF.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(EB).map(t=>new jB(e,t)),this.fixed=!e.state.facet(DB);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.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 e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(DB)!=!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=cN.iter(this.view.state.facet(TB),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Ine(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==iP.Text&&t){AB(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==iP.Text){AB(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(EB),n=e.state.facet(EB),r=e.docChanged||e.heightChanged||e.viewportChanged||!cN.eq(e.startState.facet(TB),e.state.facet(TB),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new jB(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.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=>X.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==HP.LTR?{left:r,right:i}:{right:r,left:i}})});function kB(e){return Array.isArray(e)?e:[e]}function AB(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Ine=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=cN.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new MB(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];AB(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;(r.length!=0||a.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(Mne)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},jB=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=kB(t.markers(e)),t.initialSpacer&&(this.spacer=new MB(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=kB(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!cN.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},MB=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Lne(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Lne(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}var Rne=K.define(),zne=K.define(),NB=K.define({combine(e){return nN(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),PB=class extends wB{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function FB(e,t){return e.state.facet(NB).formatNumber(t,e.state)}var Bne=EB.compute([NB],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Rne)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new PB(FB(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(zne)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(NB)!=e.state.facet(NB),initialSpacer(e){return new PB(FB(e,IB(e.state.doc.lines)))},updateSpacer(e,t){let n=FB(t.view,IB(t.view.state.doc.lines));return n==e.number?e:new PB(n)},domEventHandlers:e.facet(NB).domEventHandlers,side:`before`}));function Vne(e={}){return[NB.of(e),OB(),Bne]}function IB(e){let t=9;for(;t<e;)t=t*10+9;return t}var Hne=new class extends wB{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},Une=TB.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(Hne.range(i)))}return cN.of(t)});function Wne(){return Une}var LB=new pA;function RB(e){return K.define({combine:e?t=>t.concat(e):void 0})}var zB=new pA,BB=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,tN.prototype.hasOwnProperty(`tree`)||Object.defineProperty(tN.prototype,"tree",{get(){return UB(this)}}),this.parser=t,this.extension=[XB.of(this),tN.languageData.of((e,t,n)=>{let r=VB(e,t,n),i=r.type.prop(LB);if(!i)return[];let a=e.facet(i),o=r.type.prop(zB);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return VB(e,t,n).type.prop(LB)==this.data}findRegions(e){let t=e.facet(XB);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(LB)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(pA.mounted);if(i){if(i.tree.prop(LB)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof xA&&r(i,e.positions[n]+t)}};return r(UB(e),0),n}get allowsNesting(){return!0}};BB.setState=q.define();function VB(e,t,n){let r=e.facet(XB),i=UB(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,bA.ExcludeBuffers|bA.EnterBracketed))e.type.isTop&&(i=e);return i}var HB=class e extends BB{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=RB(t.languageData);return new e(n,t.parser.configure({props:[LB.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function UB(e){let t=e.field(BB.state,!1);return t?t.tree:xA.empty}var Gne=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},WB=null,GB=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],xA.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Gne(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=xA.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(IA.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(IA.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=WB;WB=this;try{return e()}finally{WB=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=KB(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=IA.applyChanges(r,e),i=xA.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=KB(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends LA{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=WB;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new xA(gA.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return WB}};function KB(e,t,n){return IA.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var qB=class e{constructor(e){this.context=e,this.tree=e.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 e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=GB.create(t.facet(XB).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};BB.state=bM.define({create:qB.init,update(e,t){for(let e of t.effects)if(e.is(BB.setState))return e.value;return t.startState.facet(XB)==t.state.facet(XB)?e.apply(t):qB.init(t.state)}});var JB=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(JB=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var YB=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Kne=AF.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(BB.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(BB.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=JB(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(BB.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!YB?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>YB&&YB()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:BB.setState.of(new qB(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>EF(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),XB=K.define({combine(e){return e.length?e[0]:null},enables:e=>[BB.state,Kne,X.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),ZB=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},qne=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},Jne=K.define(),QB=K.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function $B(e){let t=e.facet(QB);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function eV(e,t){let n=``,r=e.tabSize,i=e.facet(QB)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function tV(e,t){e instanceof tN&&(e=new nV(e));for(let n of e.state.facet(Jne)){let r=n(e,t);if(r!==void 0)return r}let n=UB(e.state);return n.length>=t?Yne(e,n,t):null}var nV=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=$B(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return SN(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},rV=new pA;function Yne(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return iV(r,e,n)}function iV(e,t,n){for(let r=e;r;r=r.next){let e=Zne(r.node);if(e)return e($ne.create(t,n,r))}return 0}function Xne(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Zne(e){let t=e.type.prop(rV);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(pA.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>oV(e,!0,1,void 0,n&&!Xne(e)?t.from:void 0)}return e.parent==null?Qne:null}function Qne(){return 0}var $ne=class e extends nV{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(ere(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return iV(this.context.next,this.base,this.pos)}};function ere(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function tre(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function aV({closing:e,align:t=!0,units:n=1}){return r=>oV(r,t,n,e)}function oV(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?tre(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var nre=e=>e.baseIndent;function sV({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var rre=200;function ire(){return tN.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+rre)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=tV(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=eV(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var cV=K.define(),lV=new pA;function uV(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 are(e,t,n){let r=UB(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(lV);if(s&&(i.to<r.length-50||r.length==e.doc.length||!ore(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function ore(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function dV(e,t,n){for(let r of e.facet(cV)){let i=r(e,t,n);if(i)return i}return are(e,t,n)}function fV(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var pV=q.define({map:fV}),mV=q.define({map:fV});function hV(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var gV=bM.define({create(){return Y.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=_V(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(pV)&&!sre(e,r.value.from,r.value.to)?n.push(r.value):r.is(mV)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(xV),i=n.map(e=>(r?Y.replace({widget:new fre(r(t.state,e))}):wV).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=_V(e,t.selection.main.head)),e},provide:e=>X.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw 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 RangeError(`Invalid JSON for fold state`);t.push(wV.range(r,i))}return Y.set(t,!0)}});function _V(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function vV(e,t,n){var r;let i=null;return(r=e.field(gV,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function sre(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function yV(e,t){return e.field(gV,!1)?t:t.concat(q.appendConfig.of(SV()))}var cre=e=>{for(let t of hV(e)){let n=dV(e.state,t.from,t.to);if(n)return e.dispatch({effects:yV(e.state,[pV.of(n),bV(e,n)])}),!0}return!1},lre=e=>{if(!e.state.field(gV,!1))return!1;let t=[];for(let n of hV(e)){let r=vV(e.state,n.from,n.to);r&&t.push(mV.of(r),bV(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function bV(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return X.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var ure=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:cre},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:lre},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=dV(t,i.from,i.to);a&&n.push(pV.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:yV(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(gV,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(mV.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],dre={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},xV=K.define({combine(e){return nN(e,dre)}});function SV(e){let t=[gV,hre];return e&&t.push(xV.of(e)),t}function CV(e,t){let{state:n}=e,r=n.facet(xV),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=vV(e.state,n.from,n.to);r&&e.dispatch({effects:mV.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var wV=Y.replace({widget:new class extends rP{toDOM(e){return CV(e,null)}}}),fre=class extends rP{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return CV(e,this.value)}},pre={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},TV=class extends wB{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function mre(e={}){let t={...pre,...e},n=new TV(t,!0),r=new TV(t,!1),i=AF.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(XB)!=e.state.facet(XB)||e.startState.field(gV,!1)!=e.state.field(gV,!1)||UB(e.startState)!=UB(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new dN;for(let i of e.viewportLineBlocks){let a=vV(e.state,i.from,i.to)?r:dV(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,Pne({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||cN.empty},initialSpacer(){return new TV(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=vV(e.state,t.from,t.to);if(r)return e.dispatch({effects:mV.of(r)}),!0;let i=dV(e.state,t.from,t.to);return i?(e.dispatch({effects:pV.of(i)}),!0):!1}}}),SV()]}var hre=X.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`}}),EV=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=ON.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof BB?e=>e.prop(LB)==a.data:a?e=>e==a:void 0,this.style=mj(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new ON(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},DV=K.define(),OV=K.define({combine(e){return e.length?[e[0]]:null}});function kV(e){let t=e.facet(DV);return t.length?t:e.facet(OV)}function AV(e,t){let n=[_re],r;return e instanceof EV&&(e.module&&n.push(X.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(OV.of(e)):r?n.push(DV.computeN([X.darkTheme],t=>t.facet(X.darkTheme)==(r==`dark`)?[e]:[])):n.push(DV.of(e)),n}var gre=class{constructor(e){this.markCache=Object.create(null),this.tree=UB(e.state),this.decorations=this.buildDeco(e,kV(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=UB(e.state),n=kV(e.state),r=n!=kV(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let n=new dN;for(let{from:r,to:i}of e.visibleRanges)hj(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=Y.mark({class:r})))},r,i);return n.finish()}},_re=CM.high(AF.fromClass(gre,{decorations:e=>e.decorations})),vre=EV.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`}]),yre=X.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),jV=1e4,MV=`()[]{}`,NV=K.define({combine(e){return nN(e,{afterCursor:!0,brackets:MV,maxScanDistance:jV,renderMatch:Sre})}}),bre=Y.mark({class:`cm-matchingBracket`}),xre=Y.mark({class:`cm-nonmatchingBracket`});function Sre(e){let t=[],n=e.matched?bre:xre;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 PV(e){let t=[],n=e.facet(NV);for(let r of e.selection.ranges){if(!r.empty)continue;let i=RV(e,r.head,-1,n)||r.head>0&&RV(e,r.head-1,1,n)||n.afterCursor&&(RV(e,r.head,1,n)||r.head<e.doc.length&&RV(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return Y.set(t,!0)}var Cre=[AF.fromClass(class{constructor(e){this.paused=!1,this.decorations=PV(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=PV(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),yre];function wre(e={}){return[NV.of(e),Cre]}var FV=new pA;function IV(e,t,n){let r=e.prop(t<0?pA.openedBy:pA.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function LV(e){let t=e.type.prop(FV);return t?t(e.node):e}function RV(e,t,n,r={}){let i=r.maxScanDistance||jV,a=r.brackets||MV,o=UB(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=IV(r.type,n,a);if(i&&r.from<r.to){let o=LV(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Tre(e,t,n,r,o,i,a)}}return Ere(e,t,n,o,s.type,i,a)}function Tre(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=LV(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(IV(u.type,n,o))l++;else if(IV(u.type,-n,o)){if(l==0){let e=LV(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Ere(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var Dre=Object.create(null),zV=[gA.none],BV=[],VV=Object.create(null),Ore=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`]])Ore[e]=kre(Dre,t);function HV(e,t){BV.indexOf(e)>-1||(BV.push(e),console.warn(t))}function kre(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||W[n];r?typeof r==`function`?t.length?t=t.map(r):HV(n,`Modifier ${n} used at start of tag`):t.length?HV(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:HV(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=VV[i];if(a)return a.id;let o=VV[i]=gA.define({id:zV.length,name:r,props:[dj({[r]:n})]});return zV.push(o),o.id}HP.RTL,HP.LTR;var UV=HB.define({name:`json`,parser:_ne.configure({props:[rV.add({Object:sV({except:/^\s*\}/}),Array:sV({except:/^\s*\]/})}),lV.add({"Object Array":uV})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function WV(){return new ZB(UV)}function GV(){return GV=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GV.apply(null,arguments)}function Are(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var jre=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=qV(e.state,n.from);return r.line?Mre(e):r.block?Pre(e):!1};function KV(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}}var Mre=KV(Lre,0),Nre=KV(YV,0),Pre=KV((e,t)=>YV(e,t,Ire(t)),0);function qV(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var JV=50;function Fre(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-JV,r),o=e.sliceDoc(i,i+JV),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+JV),d=e.sliceDoc(i-JV,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Ire(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 a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function YV(e,t,n=t.selection.ranges){let r=n.map(e=>qV(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Fre(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Lre(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=qV(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var XV=RM.define(),Rre=RM.define(),zre=K.define(),ZV=K.define({combine(e){return nN(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),QV=bM.define({create(){return cH.empty},update(e,t){let n=t.state.facet(ZV),r=t.annotation(XV);if(r){let i=nH.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?rH(o,o.length,n.minDepth,i):oH(o,t.startState.selection),new cH(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Rre);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(VM.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=nH.fromTransaction(t),o=t.annotation(VM.time),s=t.annotation(VM.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new cH(e.done.map(nH.fromJSON),e.undone.map(nH.fromJSON))}});function Bre(e={}){return[QV,ZV.of(e),X.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?eH:e.inputType==`historyRedo`?tH:null;return n?(e.preventDefault(),n(t)):!1}})]}function $V(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(QV,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var eH=$V(0,!1),tH=$V(1,!1),Vre=$V(0,!0),Hre=$V(1,!0),nH=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&iM.fromJSON(t.changes),[],t.mapped&&rM.fromJSON(t.mapped),t.startSelection&&G.fromJSON(t.startSelection),t.selectionsAfter.map(G.fromJSON))}static fromTransaction(t,n){let r=aH;for(let e of t.startState.facet(zre)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,aH)}static selection(t){return new e(void 0,aH,void 0,void 0,t)}};function rH(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Ure(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Wre(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function iH(e,t){return e.length?t.length?e.concat(t):e:t}var aH=[],Gre=200;function oH(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Gre));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),rH(e,e.length-1,1e9,n.setSelAfter(r)))}return[nH.selection([t])]}function Kre(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 sH(e,t){if(!e.length)return e;let n=e.length,r=aH;for(;n;){let i=qre(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[nH.selection(r)]:aH}function qre(e,t,n){let r=iH(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):aH,n);if(!e.changes)return nH.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new nH(i,q.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Jre=/^(input\.type|delete)($|\.)/,cH=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Jre.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Ure(s.changes,t.changes))||r==`input.type.compose`)?rH(o,o.length-1,i.minDepth,new nH(t.changes.compose(s.changes),iH(q.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,aH)):rH(o,o.length,i.minDepth,t),new e(o,aH,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:aH;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Wre(a[a.length-1],t)?this:new e(oH(this.done,t),this.undone,n,r)}addMapping(t){return new e(sH(this.done,t),sH(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:XV.of({side:e,rest:Kre(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?aH:r.slice(0,r.length-1);return i.mapped&&(n=sH(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:XV.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};cH.empty=new cH(aH,aH);var Yre=[{key:`Mod-z`,run:eH,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:tH,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:tH,preventDefault:!0},{key:`Mod-u`,run:Vre,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Hre,preventDefault:!0}];function lH(e,t){return G.create(e.ranges.map(t),e.mainIndex)}function uH(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function dH({state:e,dispatch:t},n){let r=lH(e.selection,n);return!r.eq(e.selection,!0)&&(t(uH(e,r)),!0)}function fH(e,t){return G.cursor(t?e.to:e.from)}function pH(e,t){return dH(e,n=>n.empty?e.moveByChar(n,t):fH(n,t))}function mH(e){return e.textDirectionAt(e.state.selection.main.head)==HP.LTR}var hH=e=>pH(e,!mH(e)),gH=e=>pH(e,mH(e));function _H(e,t){return dH(e,n=>n.empty?e.moveByGroup(n,t):fH(n,t))}var Xre=e=>_H(e,!mH(e)),Zre=e=>_H(e,mH(e));typeof Intl<`u`&&Intl.Segmenter;function Qre(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 vH(e,t,n){let r=UB(e).resolveInner(t.head),i=n?pA.closedBy:pA.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Qre(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?RV(e,r.from,1):RV(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,G.cursor(s,n?-1:1)}var $re=e=>dH(e,t=>vH(e.state,t,!mH(e))),eie=e=>dH(e,t=>vH(e.state,t,mH(e)));function yH(e,t){return dH(e,n=>{if(!n.empty)return fH(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var bH=e=>yH(e,!1),xH=e=>yH(e,!0);function SH(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(X.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.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 CH(e,t){let n=SH(e),{state:r}=e,i=lH(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):fH(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=X.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(uH(r,i),{effects:a}),!0}var wH=e=>CH(e,!1),TH=e=>CH(e,!0);function EH(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 n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=G.cursor(r.from+n))}return i}var DH=e=>dH(e,t=>EH(e,t,!0)),OH=e=>dH(e,t=>EH(e,t,!1)),kH=e=>dH(e,t=>EH(e,t,!mH(e))),AH=e=>dH(e,t=>EH(e,t,mH(e))),jH=e=>dH(e,t=>e.moveToLineBoundary(t,!1,!1)),MH=e=>dH(e,t=>e.moveToLineBoundary(t,!0,!1));function NH(e,t,n){let r=!1,i=lH(e.selection,t=>{let i=RV(e,t.head,-1)||RV(e,t.head,1)||t.head>0&&RV(e,t.head-1,1)||t.head<e.doc.length&&RV(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?G.range(t.anchor,a):G.cursor(a)});return r?(t(uH(e,i)),!0):!1}var PH=({state:e,dispatch:t})=>NH(e,t,!1);function FH(e,t,n){let r=lH(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=G.range(e.head,e.anchor));let r=n(e);return G.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(uH(e.state,r)),!0)}function IH(e,t){return FH(e,t,n=>e.moveByChar(n,t))}var LH=e=>IH(e,!mH(e)),RH=e=>IH(e,mH(e));function zH(e,t){return FH(e,t,n=>e.moveByGroup(n,t))}var BH=e=>zH(e,!mH(e)),VH=e=>zH(e,mH(e)),HH=e=>{let t=!mH(e);return FH(e,t,n=>vH(e.state,n,t))},UH=e=>{let t=mH(e);return FH(e,t,n=>vH(e.state,n,t))};function WH(e,t){return FH(e,t,n=>e.moveVertically(n,t))}var GH=e=>WH(e,!1),KH=e=>WH(e,!0);function qH(e,t){return FH(e,t,n=>e.moveVertically(n,t,SH(e).height))}var JH=e=>qH(e,!1),YH=e=>qH(e,!0),XH=e=>FH(e,!0,t=>EH(e,t,!0)),ZH=e=>FH(e,!1,t=>EH(e,t,!1)),QH=e=>{let t=!mH(e);return FH(e,t,n=>EH(e,n,t))},$H=e=>{let t=mH(e);return FH(e,t,n=>EH(e,n,t))},eU=e=>FH(e,!1,t=>G.cursor(e.lineBlockAt(t.head).from)),tU=e=>FH(e,!0,t=>G.cursor(e.lineBlockAt(t.head).to)),nU=({state:e,dispatch:t})=>(t(uH(e,{anchor:0})),!0),rU=({state:e,dispatch:t})=>(t(uH(e,{anchor:e.doc.length})),!0),iU=({state:e,dispatch:t})=>(t(uH(e,{anchor:e.selection.main.anchor,head:0})),!0),aU=({state:e,dispatch:t})=>(t(uH(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),oU=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),sU=({state:e,dispatch:t})=>{let n=EU(e).map(({from:t,to:n})=>G.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:G.create(n),userEvent:`select`})),!0},cU=({state:e,dispatch:t})=>{let n=lH(e.selection,t=>{let n=UB(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return G.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(uH(e,n)),!0)};function lU(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(uH(n,G.create(i,i.length-1))),!0)}var uU=e=>lU(e,!1),dU=e=>lU(e,!0),fU=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=G.create([n.main]):n.main.empty||(r=G.create([G.cursor(n.main.head)])),r?(t(uH(e,r)),!0):!1};function pU(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=mU(e,o,!1)):o>i&&(n=`delete.forward`,o=mU(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=mU(e,i,!1),a=mU(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:G.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?X.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function mU(e,t,n){if(e instanceof X)for(let r of e.state.facet(X.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var hU=(e,t,n)=>pU(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=SN(s,a.tabSize)%$B(a)||$B(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=Yj(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=Yj(o.text,c-o.from,!1,!1)+o.from);return c}),gU=e=>hU(e,!1,!0),_U=e=>hU(e,!0,!1),vU=(e,t)=>pU(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=Yj(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),yU=e=>vU(e,!1),bU=e=>vU(e,!0),xU=e=>pU(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),SU=e=>pU(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),CU=e=>pU(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),wU=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:zj.of([``,``])},range:G.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},TU=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:Yj(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:Yj(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:G.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function EU(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function DU(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of EU(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(G.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(G.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:G.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var OU=({state:e,dispatch:t})=>DU(e,t,!1),kU=({state:e,dispatch:t})=>DU(e,t,!0);function AU(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of EU(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.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}var jU=({state:e,dispatch:t})=>AU(e,t,!1),MU=({state:e,dispatch:t})=>AU(e,t,!0),NU=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(EU(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=lH(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function PU(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=UB(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(pA.closedBy))&&a.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}var FU=LU(!1),IU=LU(!0);function LU(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&PU(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new nV(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=tV(s,r);for(c??=SN(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,eV(t,c)];return o&&l.push(eV(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:zj.of(l)},range:G.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function RU(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:G.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var zU=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new nV(e,{overrideIndentation:e=>n[e]??-1}),i=RU(e,(t,i,a)=>{let o=tV(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=eV(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},BU=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(RU(e,(t,n)=>{n.push({from:t.from,insert:e.facet(QB)})}),{userEvent:`input.indent`})),!0),VU=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(RU(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=SN(r,e.tabSize),a=0,o=eV(e,Math.max(0,i-$B(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),HU=e=>(e.setTabFocusMode(),!0),UU=[{key:`Ctrl-b`,run:hH,shift:LH,preventDefault:!0},{key:`Ctrl-f`,run:gH,shift:RH},{key:`Ctrl-p`,run:bH,shift:GH},{key:`Ctrl-n`,run:xH,shift:KH},{key:`Ctrl-a`,run:jH,shift:eU},{key:`Ctrl-e`,run:MH,shift:tU},{key:`Ctrl-d`,run:_U},{key:`Ctrl-h`,run:gU},{key:`Ctrl-k`,run:xU},{key:`Ctrl-Alt-h`,run:yU},{key:`Ctrl-o`,run:wU},{key:`Ctrl-t`,run:TU},{key:`Ctrl-v`,run:TH}],WU=[{key:`ArrowLeft`,run:hH,shift:LH,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Xre,shift:BH,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:kH,shift:QH,preventDefault:!0},{key:`ArrowRight`,run:gH,shift:RH,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Zre,shift:VH,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:AH,shift:$H,preventDefault:!0},{key:`ArrowUp`,run:bH,shift:GH,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:nU,shift:iU},{mac:`Ctrl-ArrowUp`,run:wH,shift:JH},{key:`ArrowDown`,run:xH,shift:KH,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:rU,shift:aU},{mac:`Ctrl-ArrowDown`,run:TH,shift:YH},{key:`PageUp`,run:wH,shift:JH},{key:`PageDown`,run:TH,shift:YH},{key:`Home`,run:OH,shift:ZH,preventDefault:!0},{key:`Mod-Home`,run:nU,shift:iU},{key:`End`,run:DH,shift:XH,preventDefault:!0},{key:`Mod-End`,run:rU,shift:aU},{key:`Enter`,run:FU,shift:FU},{key:`Mod-a`,run:oU},{key:`Backspace`,run:gU,shift:gU,preventDefault:!0},{key:`Delete`,run:_U,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:yU,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:bU,preventDefault:!0},{mac:`Mod-Backspace`,run:SU,preventDefault:!0},{mac:`Mod-Delete`,run:CU,preventDefault:!0}].concat(UU.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),GU=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:$re,shift:HH},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:eie,shift:UH},{key:`Alt-ArrowUp`,run:OU},{key:`Shift-Alt-ArrowUp`,run:jU},{key:`Alt-ArrowDown`,run:kU},{key:`Shift-Alt-ArrowDown`,run:MU},{key:`Mod-Alt-ArrowUp`,run:uU},{key:`Mod-Alt-ArrowDown`,run:dU},{key:`Escape`,run:fU},{key:`Mod-Enter`,run:IU},{key:`Alt-l`,mac:`Ctrl-l`,run:sU},{key:`Mod-i`,run:cU,preventDefault:!0},{key:`Mod-[`,run:VU},{key:`Mod-]`,run:BU},{key:`Mod-Alt-\\`,run:zU},{key:`Shift-Mod-k`,run:NU},{key:`Shift-Mod-\\`,run:PH},{key:`Mod-/`,run:jre},{key:`Alt-A`,mac:`Ctrl-A`,run:Nre},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:HU}].concat(WU),KU={key:`Tab`,run:BU,shift:VU},qU=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,JU=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(qU(e)):qU,this.query=this.normalize(t)}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 Qj(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=$j(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=eM(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(JU.prototype[Symbol.iterator]=function(){return this});var YU={from:-1,to:-1,match:/.*/.exec(``),precise:!0},XU=`gm`+(/x/.unicode==null?``:`u`),ZU=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=YU,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new eW(e,t,n,r,i);this.re=new RegExp(t,XU+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=nW(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),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 e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=nW(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},QU=new WeakMap,$U=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=QU.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return QU.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),QU.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},eW=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=YU,this.matchPos=nW(e,r),this.re=new RegExp(t,XU+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=$U.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=nW(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=$U.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(ZU.prototype[Symbol.iterator]=eW.prototype[Symbol.iterator]=function(){return this});function tW(e){try{return new RegExp(e,XU),!0}catch{return!1}}function nW(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}var rW=e=>{let t=Ane(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=kne(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=G.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,X.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},iW={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},aW=K.define({combine(e){return nN(e,iW,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function oW(e){let t=[fW,dW];return e&&t.push(aW.of(e)),t}var sW=Y.mark({class:`cm-selectionMatch`}),cW=Y.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function lW(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=XM.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=XM.Word)}function uW(e,t,n,r){return e(t.sliceDoc(n,n+1))==XM.Word&&e(t.sliceDoc(r-1,r))==XM.Word}var dW=AF.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(aW),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Y.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return Y.none;let e=n.wordAt(i.head);if(!e)return Y.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return Y.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(lW(o,n,i.from,i.to)&&uW(o,n,i.from,i.to)))return Y.none}else if(a=n.sliceDoc(i.from,i.to),!a)return Y.none}let s=[];for(let r of e.visibleRanges){let e=new JU(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||lW(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(cW.range(r,a)):(r>=i.to||a<=i.from)&&s.push(sW.range(r,a)),s.length>t.maxMatches))return Y.none}}return Y.set(s)}},{decorations:e=>e.decorations}),fW=X.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),pW=({state:e,dispatch:t})=>{let{selection:n}=e,r=G.create(n.ranges.map(t=>e.wordAt(t.head)||G.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function mW(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new JU(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new JU(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var hW=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return pW({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=mW(e,r);return i?(t(e.update({selection:e.selection.addRange(G.range(i.from,i.to),!1),effects:X.scrollIntoView(i.to)})),!0):!1},gW=K.define({combine(e){return nN(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new XW(e),scrollToMatch:e=>X.scrollIntoView(e)})}}),_W=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||tW(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
70
|
+
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new OW(this):new SW(this)}getCursor(e,t=0,n){let r=e.doc?e:tN.create({doc:e});return n??=r.doc.length,this.regexp?wW(this,r,t,n):bW(this,r,t,n)}},vW=class{constructor(e){this.spec=e}};function yW(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function bW(e,t,n,r){let i;return e.wholeWord&&(i=xW(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=yW(e.test,t,i)),new JU(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function xW(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(TW(i,n-a))!=XM.Word||t(EW(i,n-a))!=XM.Word)&&(t(EW(i,r-a))!=XM.Word||t(TW(i,r-a))!=XM.Word))}var SW=class extends vW{constructor(e){super(e)}nextMatch(e,t,n){let r=bW(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=bW(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=bW(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=bW(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=bW(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function CW(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function wW(e,t,n,r){let i;return e.wholeWord&&(i=DW(t.charCategorizer(t.selection.main.head))),e.test&&(i=CW(e.test,t,i)),new ZU(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function TW(e,t){return e.slice(Yj(e,t,!1),t)}function EW(e,t){return e.slice(t,Yj(e,t))}function DW(e){return(t,n,r)=>!r[0].length||(e(TW(r.input,r.index))!=XM.Word||e(EW(r.input,r.index))!=XM.Word)&&(e(EW(r.input,r.index+r[0].length))!=XM.Word||e(TW(r.input,r.index+r[0].length))!=XM.Word)}var OW=class extends vW{nextMatch(e,t,n){let r=wW(this.spec,e,n,e.doc.length).next();return r.done&&(r=wW(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=wW(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=wW(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=wW(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},kW=q.define(),AW=q.define(),jW=bM.define({create(e){return new MW(WW(e).create(),null)},update(e,t){for(let n of t.effects)n.is(kW)?e=new MW(n.value.create(),e.panel):n.is(AW)&&(e=new MW(e.query,n.value?UW:null));return e},provide:e=>bB.from(e,e=>e.panel)}),MW=class{constructor(e,t){this.query=e,this.panel=t}},NW=Y.mark({class:`cm-searchMatch`}),PW=Y.mark({class:`cm-searchMatch cm-searchMatch-selected`}),FW=AF.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(jW))}update(e){let t=e.state.field(jW);(t!=e.startState.field(jW)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Y.none;let{view:n}=this,r=new dN;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?PW:NW)})}return r.finish()}},{decorations:e=>e.decorations});function IW(e){return t=>{let n=t.state.field(jW,!1);return n&&n.query.spec.valid?e(t,n):qW(t)}}var LW=IW((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(gW);return e.dispatch({selection:i,effects:[eG(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),KW(e),!0}),RW=IW((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(gW);return e.dispatch({selection:a,effects:[eG(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),KW(e),!0}),zW=IW((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),BW=({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,a=[],o=0;for(let t=new JU(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},VW=IW((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(X.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(eG(e,o)),u.push(n.facet(gW).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),HW=IW((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:X.announce.of(r),userEvent:`input.replace.all`}),!0});function UW(e){return e.state.facet(gW).createPanel(e)}function WW(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(gW);return new _W({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function GW(e){let t=gB(e,UW);return t&&t.dom.querySelector(`[main-field]`)}function KW(e){let t=GW(e);t&&t==e.root.activeElement&&t.select()}var qW=e=>{let t=e.state.field(jW,!1);if(t&&t.panel){let n=GW(e);if(n&&n!=e.root.activeElement){let r=WW(e.state,t.query.spec);r.valid&&e.dispatch({effects:kW.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[AW.of(!0),t?kW.of(WW(e.state,t.query.spec)):q.appendConfig.of(nG)]});return!0},JW=e=>{let t=e.state.field(jW,!1);if(!t||!t.panel)return!1;let n=gB(e,UW);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:AW.of(!1)}),!0},YW=[{key:`Mod-f`,run:qW,scope:`editor search-panel`},{key:`F3`,run:LW,shift:RW,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:LW,shift:RW,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:JW,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:BW},{key:`Mod-Alt-g`,run:rW},{key:`Mod-d`,run:hW,preventDefault:!0}],XW=class{constructor(e){this.view=e;let t=this.query=e.state.field(jW).query.spec;this.commit=this.commit.bind(this),this.searchField=RN(`input`,{value:t.search,placeholder:ZW(e,`Find`),"aria-label":ZW(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=RN(`input`,{value:t.replace,placeholder:ZW(e,`Replace`),"aria-label":ZW(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=RN(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=RN(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=RN(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return RN(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=RN(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>LW(e),[ZW(e,`next`)]),n(`prev`,()=>RW(e),[ZW(e,`previous`)]),n(`select`,()=>zW(e),[ZW(e,`all`)]),RN(`label`,null,[this.caseField,ZW(e,`match case`)]),RN(`label`,null,[this.reField,ZW(e,`regexp`)]),RN(`label`,null,[this.wordField,ZW(e,`by word`)]),...e.state.readOnly?[]:[RN(`br`),this.replaceField,n(`replace`,()=>VW(e),[ZW(e,`replace`)]),n(`replaceAll`,()=>HW(e),[ZW(e,`replace all`)])],RN(`button`,{name:`close`,onclick:()=>JW(e),"aria-label":ZW(e,`close`),type:`button`},[`×`])])}commit(){let e=new _W({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:kW.of(e)}))}keydown(e){XR(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?RW:LW)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),VW(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(kW)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(gW).top}};function ZW(e,t){return e.state.phrase(t)}var QW=30,$W=/[\s\.,:;?!]/;function eG(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-QW),o=Math.min(i,n+QW),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<QW;e++)if(!$W.test(s[e+1])&&$W.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-QW;e--)if(!$W.test(s[e-1])&&$W.test(s[e])){s=s.slice(0,e);break}}return X.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var tG=X.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`}}),nG=[jW,CM.low(FW),tG],rG=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=UB(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(uG(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function iG(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 aG(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=iG(t)+iG(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function oG(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:aG(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function sG(e,t){return n=>{for(let t=UB(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var cG=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function lG(e){return e.selection.main.from}function uG(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var dG=RM.define();function fG(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:G.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var pG=new WeakMap;function mG(e){if(!Array.isArray(e))return e;let t=pG.get(e);return t||pG.set(e,t=oG(e)),t}var hG=q.define(),gG=q.define(),_G=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Qj(e,t),r=eM(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(Qj(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=Qj(e,0),i=eM(r),a=i==e.length?0:-100;if(r!=t[0]){if(r==n[0])a+=-200;else return null}return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=Qj(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=eM(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=Qj(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=$j(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=eM(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?eM(Qj(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},vG=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},yG=K.define({combine(e){return nN(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:xG,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>bG(e(n),t(n)),optionClass:(e,t)=>n=>bG(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function bG(e,t){return e?t?e+` `+t:e:t}function xG(e,t,n,r,i,a){let o=e.textDirection==HP.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var SG=q.define();function CG(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function wG(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var TG=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(yG);this.optionContent=CG(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=wG(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:SG.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(yG).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:gG.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=wG(r.length,i,e.state.facet(yG).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=wG(t.options.length,t.selected,this.view.state.facet(yG).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>EF(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&DG(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(yG).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function EG(e,t){return n=>new TG(n,e,t)}function DG(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 OG(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function kG(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(yG);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new cG(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new vG(n):new _G(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new cG(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):OG(e.completion)>OG(c)&&(s[s.length-1]=e),c=e.completion}return s}var AG=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,FG(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=kG(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(yG).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,FG(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:WG,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},jG=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(IG,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(yG),i=(r.override||n.languageDataAt(`autocomplete`,lG(n)).map(mG)).map(e=>(this.active.find(t=>t.source==e)||new RG(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(VG));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!MG(i,this.active)||o?a=AG.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new RG(e.source,0):e));for(let e of t.effects)e.is(SG)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?NG:PG}};function MG(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,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var NG={"aria-autocomplete":`list`},PG={};function FG(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var IG=[];function LG(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(dG);if(n&&t.activateOnCompletion(n))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}var RG=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=LG(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(hG))i=new e(i.source,1,n.value);else if(n.is(gG))i=new e(i.source,0);else if(n.is(VG))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(lG(e.state))}},zG=class e extends RG{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=lG(t.state);if(o>a||!r||n&2&&(lG(t.startState)==this.from||o<this.limit))return new RG(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return BG(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new rG(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??lG(t.state)):new RG(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new RG(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function BG(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):uG(e,!0).test(i)}var VG=q.define({map(e,t){return e.map(e=>e.map(t))}}),HG=bM.define({create(){return jG.start()},update(e,t){return e.update(t)},provide:e=>[lB.from(e,e=>e.tooltip),X.contentAttributes.from(e,e=>e.attrs)]});function UG(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(HG).active.find(e=>e.source==t.source);return r instanceof zG&&(typeof n==`string`?e.dispatch({...fG(e.state,n,r.from,r.to),annotations:dG.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var WG=EG(HG,UG);function GG(e,t=`option`){return n=>{let r=n.state.field(HG,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(yG).interactionDelay)return!1;let i=1,a;t==`page`&&(a=mB(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:SG.of(s)}),!0}}var KG=e=>{let t=e.state.field(HG,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(yG).interactionDelay?!1:UG(e,t.open.options[t.open.selected])},qG=e=>e.state.field(HG,!1)?(e.dispatch({effects:hG.of(!0)}),!0):!1,JG=e=>{let t=e.state.field(HG,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:gG.of(null)}),!0)},YG=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},XG=50,ZG=1e3,QG=AF.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(HG).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(HG),n=e.state.facet(yG);if(!e.selectionSet&&!e.docChanged&&e.startState.field(HG)==t)return;let r=e.transactions.some(e=>{let t=LG(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>XG&&Date.now()-n.time>ZG){for(let e of n.context.abortListeners)try{e()}catch(e){EF(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(hG)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(HG);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(yG).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new rG(t,lG(t),e.explicit,this.view),r=new YG(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:gG.of(null)}),EF(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(yG).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(yG),n=this.view.state.field(HG);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=lG(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new zG(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new RG(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:VG.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(HG,!1);if(t&&t.tooltip&&this.view.state.facet(yG).closeOnBlur){let n=t.open&&mB(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:gG.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:hG.of(!1)}),20),this.composing=0}}}),$G=typeof navigator==`object`&&/Win/.test(navigator.platform),eK=CM.highest(X.domEventHandlers({keydown(e,t){let n=t.state.field(HG,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!($G&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&UG(t,r),!1}})),tK=X.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`,cursor:`pointer`},".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`}}}),nK=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},rK=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,nM.TrackDel),r=t.mapPos(this.to,1,nM.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},iK=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(QB);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new rK(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new nK(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},aK=Y.widget({widget:new class extends rP{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),oK=Y.mark({class:`cm-snippetField`}),sK=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=Y.set(e.map(e=>(e.from==e.to?aK:oK).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},cK=q.define({map(e,t){return e&&e.map(t)}}),lK=q.define(),uK=bM.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(cK))return n.value;if(n.is(lK)&&e)return new sK(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>X.decorations.from(e,e=>e?e.deco:Y.none)});function dK(e,t){return G.create(e.filter(e=>e.field==t).map(e=>G.range(e.from,e.to)))}function fK(e){let t=iK.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:zj.of(a)},scrollIntoView:!0,annotations:n?[dG.of(n),VM.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=dK(o,0)),o.some(e=>e.field>0)){let t=new sK(o,0),n=c.effects=[cK.of(t)];e.state.field(uK,!1)===void 0&&n.push(q.appendConfig.of([uK,gK,vK,tK]))}e.dispatch(e.state.update(c))}}function pK(e){return({state:t,dispatch:n})=>{let r=t.field(uK,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:dK(r.ranges,i),effects:cK.of(a?null:new sK(r.ranges,i)),scrollIntoView:!0})),!0}}var mK=[{key:`Tab`,run:pK(1),shift:pK(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(uK,!1)?(t(e.update({effects:cK.of(null)})),!0):!1}],hK=K.define({combine(e){return e.length?e[0]:mK}}),gK=CM.highest(qR.compute([hK],e=>e.facet(hK)));function _K(e,t){return{...t,apply:fK(e)}}var vK=X.domEventHandlers({mousedown(e,t){let n=t.state.field(uK,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:dK(n.ranges,i.field),effects:cK.of(n.ranges.some(e=>e.field>i.field)?new sK(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),yK={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},bK=q.define({map(e,t){return t.mapPos(e,-1,nM.TrackAfter)??void 0}}),xK=new class extends rN{};xK.startSide=1,xK.endSide=-1;var SK=bM.define({create(){return cN.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:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(bK)&&(e=e.update({add:[xK.range(n.value,n.value+1)]}));return e}});function CK(){return[OK,SK]}var wK=`()[]{}<>«»»«[]{}`;function TK(e){for(let t=0;t<16;t+=2)if(wK.charCodeAt(t)==e)return wK.charAt(t+1);return $j(e<128?e:e+1)}function EK(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||yK}var DK=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),OK=X.inputHandler.of((e,t,n,r)=>{if((DK?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&eM(Qj(r,0))==1||t!=i.from||n!=i.to)return!1;let a=AK(e.state,r);return a?(e.dispatch(a),!0):!1}),kK=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=EK(e,e.selection.main.head).brackets||yK.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=NK(e.doc,t.head);for(let i of n)if(i==r&&MK(e.doc,t.head)==TK(Qj(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:G.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function AK(e,t){let n=EK(e,e.selection.main.head),r=n.brackets||yK.brackets;for(let i of r){let a=TK(Qj(i,0));if(t==i)return a==i?IK(e,i,r.indexOf(i+i+i)>-1,n):PK(e,i,a,n.before||yK.before);if(t==a&&jK(e,e.selection.main.from))return FK(e,i,a)}return null}function jK(e,t){let n=!1;return e.field(SK).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function MK(e,t){let n=e.sliceString(t,t+2);return n.slice(0,eM(Qj(n,0)))}function NK(e,t){let n=e.sliceString(t-2,t);return eM(Qj(n,0))==n.length?n:n.slice(1)}function PK(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:bK.of(a.to+t.length),range:G.range(a.anchor+t.length,a.head+t.length)};let o=MK(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:bK.of(a.head+t.length),range:G.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function FK(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&MK(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:G.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function IK(e,t,n,r){let i=r.stringPrefixes||yK.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:bK.of(r.to+t.length),range:G.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=MK(e.doc,o),c;if(s==t){if(LK(e,o))return{changes:{insert:t+t,from:o},effects:bK.of(o+t.length),range:G.cursor(o+t.length)};if(jK(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:G.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=zK(e,o-2*t.length,i))>-1&&LK(e,c))return{changes:{insert:t+t+t+t,from:o},effects:bK.of(o+t.length),range:G.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=XM.Word&&zK(e,o,i)>-1&&!RK(e,o,t,i))return{changes:{insert:t+t,from:o},effects:bK.of(o+t.length),range:G.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function LK(e,t){let n=UB(e).resolveInner(t+1);return n.parent&&n.from==t}function RK(e,t,n,r){let i=UB(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function zK(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=XM.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=XM.Word)return n}return-1}function BK(e={}){return[eK,HG,yG.of(e),QG,HK,tK]}var VK=[{key:`Ctrl-Space`,run:qG},{mac:"Alt-`",run:qG},{mac:`Alt-i`,run:qG},{key:`Escape`,run:JG},{key:`ArrowDown`,run:GG(!0)},{key:`ArrowUp`,run:GG(!1)},{key:`PageDown`,run:GG(!0,`page`)},{key:`PageUp`,run:GG(!1,`page`)},{key:`Enter`,run:KG}],HK=CM.highest(qR.computeN([yG],e=>e.facet(yG).defaultKeymap?[VK]:[])),UK=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},WK=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(iq).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new dN,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=hq(s);if(i)o.add(n,n,Y.widget({widget:new cq(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,Y.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,GK(f))}};function GK(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new UK(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new UK(r.from,n,r.diagnostic)}}),r}function KK(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(iq).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(JK))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function qK(e,t){return e.field(ZK,!1)?t:t.concat(q.appendConfig.of(_q))}var JK=q.define(),YK=q.define(),XK=q.define(),ZK=bM.define({create(){return new WK(Y.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 i=t.changes.mapPos(e.selected.from,1);r=GK(n,e.selected.diagnostic,i)||GK(n,null,i)}!n.size&&i&&t.state.facet(iq).autoPanel&&(i=null),e=new WK(n,i,r)}for(let n of t.effects)if(n.is(JK)){let r=t.state.facet(iq).autoPanel?n.value.length?uq.open:null:e.panel;e=WK.init(n.value,r,t.state)}else n.is(YK)?e=new WK(e.diagnostics,n.value?uq.open:null,e.selected):n.is(XK)&&(e=new WK(e.diagnostics,e.panel,n.value));return e},provide:e=>[bB.from(e,e=>e.panel),X.decorations.from(e,e=>e.diagnostics)]}),QK=Y.mark({class:`cm-lintRange cm-lintRange-active`});function $K(e,t,n){let{diagnostics:r}=e.state.field(ZK),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(iq).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:!0,create(){return{dom:eq(e,i)}}}:null}function eq(e,t){return RN(`ul`,{class:`cm-tooltip-lint`},t.map(t=>sq(e,t,!1)))}var tq=e=>{let t=e.state.field(ZK,!1);(!t||!t.panel)&&e.dispatch({effects:qK(e.state,[YK.of(!0)])});let n=gB(e,uq.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},nq=e=>{let t=e.state.field(ZK,!1);return!t||!t.panel?!1:(e.dispatch({effects:YK.of(!1)}),!0)},rq=[{key:`Mod-Shift-m`,run:tq,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(ZK,!1);if(!t)return!1;let n=e.state.selection.main,r=GK(t.diagnostics,null,n.to+1);return!r&&(r=GK(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}),Dne(e,r.from,1,{tooltip:gq,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],iq=K.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...nN(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:aq,tooltipFilter:aq,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function aq(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function oq(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function sq(e,t,n){let r=n?oq(t.actions):[];return RN(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},RN(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=GK(e.state.field(ZK).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),RN(`u`,s.slice(c,c+1)),s.slice(c+1)];return RN(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&RN(`div`,{class:`cm-diagnosticSource`},t.source))}var cq=class extends rP{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return RN(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},lq=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=sq(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},uq=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)nq(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=oq(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=GK(this.view.state.field(ZK).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=RN(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=RN(`div`,{class:`cm-panel-lint`},this.list,RN(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>nq(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(ZK).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(ZK),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new lq(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new lq(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=GK(this.view.state.field(ZK).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:XK.of(t)})}static open(t){return new e(t)}};function dq(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 fq(e){return dq(`<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"`)}var pq=X.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:fq(`#f11`)},".cm-lintRange-warning":{backgroundImage:fq(`orange`)},".cm-lintRange-info":{backgroundImage:fq(`#999`)},".cm-lintRange-hint":{backgroundImage:fq(`#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 mq(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function hq(e){let t=`hint`,n=1;for(let r of e){let e=mq(r.severity);e>n&&(n=e,t=r.severity)}return t}var gq=Ene($K,{hideOn:KK}),_q=[ZK,X.decorations.compute([ZK],e=>{let{selected:t,panel:n}=e.field(ZK);return!t||!n||t.from==t.to?Y.none:Y.set([QK.range(t.from,t.to)])}),gq,pq],vq=function(e){e===void 0&&(e={});var t=e.crosshairCursor,n=t!==void 0&&t,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(kK)),e.defaultKeymap!==!1&&(r=r.concat(GU)),e.searchKeymap!==!1&&(r=r.concat(YW)),e.historyKeymap!==!1&&(r=r.concat(Yre)),e.foldKeymap!==!1&&(r=r.concat(ure)),e.completionKeymap!==!1&&(r=r.concat(VK)),e.lintKeymap!==!1&&(r=r.concat(rq));var i=[];return e.lineNumbers!==!1&&i.push(Vne()),e.highlightActiveLineGutter!==!1&&i.push(Wne()),e.highlightSpecialChars!==!1&&i.push(Mz()),e.history!==!1&&i.push(Bre()),e.foldGutter!==!1&&i.push(mre()),e.drawSelection!==!1&&i.push(fz()),e.dropCursor!==!1&&i.push(Sz()),e.allowMultipleSelections!==!1&&i.push(tN.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(ire()),e.syntaxHighlighting!==!1&&i.push(AV(vre,{fallback:!0})),e.bracketMatching!==!1&&i.push(wre()),e.closeBrackets!==!1&&i.push(CK()),e.autocompletion!==!1&&i.push(BK()),e.rectangularSelection!==!1&&i.push(Yz()),n!==!1&&i.push(Qz()),e.highlightActiveLine!==!1&&i.push(zz()),e.highlightSelectionMatches!==!1&&i.push(oW()),e.tabSize&&typeof e.tabSize==`number`&&i.push(QB.of(` `.repeat(e.tabSize))),i.concat([qR.of(r.flat())]).filter(Boolean)},yq=`#e5c07b`,bq=`#e06c75`,xq=`#56b6c2`,Sq=`#ffffff`,Cq=`#abb2bf`,wq=`#7d8799`,Tq=`#61afef`,Eq=`#98c379`,Dq=`#d19a66`,Oq=`#c678dd`,kq=`#21252b`,Aq=`#2c313a`,jq=`#282c34`,Mq=`#353a42`,Nq=`#3E4451`,Pq=`#528bff`,Fq=[X.theme({"&":{color:Cq,backgroundColor:jq},".cm-content":{caretColor:Pq},".cm-cursor, .cm-dropCursor":{borderLeftColor:Pq},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Nq},".cm-panels":{backgroundColor:kq,color:Cq},".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:jq,color:wq,border:`none`},".cm-activeLineGutter":{backgroundColor:Aq},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:Mq},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Mq,borderBottomColor:Mq},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Aq,color:Cq}}},{dark:!0}),AV(EV.define([{tag:W.keyword,color:Oq},{tag:[W.name,W.deleted,W.character,W.propertyName,W.macroName],color:bq},{tag:[W.function(W.variableName),W.labelName],color:Tq},{tag:[W.color,W.constant(W.name),W.standard(W.name)],color:Dq},{tag:[W.definition(W.name),W.separator],color:Cq},{tag:[W.typeName,W.className,W.number,W.changed,W.annotation,W.modifier,W.self,W.namespace],color:yq},{tag:[W.operator,W.operatorKeyword,W.url,W.escape,W.regexp,W.link,W.special(W.string)],color:xq},{tag:[W.meta,W.comment],color:wq},{tag:W.strong,fontWeight:`bold`},{tag:W.emphasis,fontStyle:`italic`},{tag:W.strikethrough,textDecoration:`line-through`},{tag:W.link,color:wq,textDecoration:`underline`},{tag:W.heading,fontWeight:`bold`,color:bq},{tag:[W.atom,W.bool,W.special(W.variableName)],color:Dq},{tag:[W.processingInstruction,W.string,W.inserted],color:Eq},{tag:W.invalid,color:Sq}]))],Iq=X.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),Lq=function(e){e===void 0&&(e={});var t=e,n=t.indentWithTab,r=n===void 0||n,i=t.editable,a=i===void 0||i,o=t.readOnly,s=o!==void 0&&o,c=t.theme,l=c===void 0?`light`:c,u=t.placeholder,d=u===void 0?``:u,f=t.basicSetup,p=f===void 0||f,m=[];switch(r&&m.unshift(qR.of([KU])),p&&(typeof p==`boolean`?m.unshift(vq()):m.unshift(vq(p))),d&&m.unshift(Uz(d)),l){case`light`:m.push(Iq);break;case`dark`:m.push(Fq);break;case`none`:break;default:m.push(l)}return a===!1&&m.push(X.editable.of(!1)),s&&m.push(tN.readOnly.of(!0)),[...m]},Rq=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(e=>!e.empty)}),zq=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}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}},Bq=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},Vq=null,Hq=()=>typeof window>`u`?new Bq:(Vq||=new Bq,Vq),Uq=X.theme({"& .cm-scroller":{height:`100% !important`}}),Wq=null,Gq=null;function Kq(e,t,n,r,i,a){if(!e&&!t&&!n&&!r&&!i&&!a)return null;var o=JSON.stringify({height:e,minHeight:t,maxHeight:n,width:r,minWidth:i,maxWidth:a});return o===Wq||(Wq=o,Gq=X.theme({"&":{height:e,minHeight:t,maxHeight:n,width:r,minWidth:i,maxWidth:a}})),Gq}var qq=RM.define(),Jq=200,Yq=[];function Xq(e){var t=e.value,n=e.selection,r=e.onChange,i=e.onStatistics,a=e.onCreateEditor,o=e.onUpdate,s=e.extensions,c=s===void 0?Yq:s,l=e.autoFocus,u=e.theme,d=u===void 0?`light`:u,f=e.height,p=f===void 0?null:f,m=e.minHeight,h=m===void 0?null:m,g=e.maxHeight,_=g===void 0?null:g,v=e.width,y=v===void 0?null:v,b=e.minWidth,x=b===void 0?null:b,S=e.maxWidth,C=S===void 0?null:S,w=e.placeholder,T=w===void 0?``:w,E=e.editable,D=E===void 0||E,O=e.readOnly,k=O!==void 0&&O,A=e.indentWithTab,j=A===void 0||A,M=e.basicSetup,N=M===void 0||M,P=e.root,F=e.initialState,ee=(0,B.useState)(),I=ee[0],te=ee[1],ne=(0,B.useState)(),re=ne[0],ie=ne[1],ae=(0,B.useState)(),oe=ae[0],se=ae[1],ce=(0,B.useState)(()=>({current:null}))[0],le=(0,B.useState)(()=>({current:null}))[0],ue=Kq(p,h,_,y,x,C),de=X.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(qq))&&(ce.current?ce.current.reset():(ce.current=new zq(()=>{if(le.current){var e=le.current;le.current=null,e()}ce.current=null},Jq),Hq().add(ce.current)),r(e.state.doc.toString(),e)),i&&i(Rq(e))}),fe=Lq({theme:d,editable:D,readOnly:k,placeholder:T,indentWithTab:j,basicSetup:N}),pe=[de,...ue?[ue]:[],Uq,...fe];return o&&typeof o==`function`&&pe.push(X.updateListener.of(o)),pe=pe.concat(c),(0,B.useLayoutEffect)(()=>{if(I&&!oe){var e={doc:t,selection:n,extensions:pe},r=F?tN.fromJSON(F.json,e,F.fields):tN.create(e);if(se(r),!re){var i=new X({state:r,parent:I,root:P});ie(i),a&&a(i,r)}}return()=>{re&&(se(void 0),ie(void 0))}},[I,oe]),(0,B.useEffect)(()=>{e.container&&te(e.container)},[e.container]),(0,B.useEffect)(()=>()=>{re&&(re.destroy(),ie(void 0)),ce.current&&=(ce.current.cancel(),null)},[re]),(0,B.useEffect)(()=>{l&&re&&re.focus()},[l,re]),(0,B.useEffect)(()=>{re&&re.dispatch({effects:q.reconfigure.of(pe)})},[d,c,p,h,_,y,x,C,T,D,k,j,N,r,o]),(0,B.useEffect)(()=>{if(t!==void 0){var e=re?re.state.doc.toString():``;if(re&&t!==e){var n=ce.current&&!ce.current.isDone,r=()=>{re&&t!==re.state.doc.toString()&&re.dispatch({changes:{from:0,to:re.state.doc.toString().length,insert:t||``},annotations:[qq.of(!0)]})};n?le.current=r:r()}}},[t,re]),{state:oe,setState:se,view:re,setView:ie,container:I,setContainer:te}}var Zq=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],Qq=(0,B.forwardRef)((e,t)=>{var n=e.className,r=e.value,i=r===void 0?``:r,a=e.selection,o=e.extensions,s=o===void 0?[]:o,c=e.onChange,l=e.onStatistics,u=e.onCreateEditor,d=e.onUpdate,f=e.autoFocus,p=e.theme,m=p===void 0?`light`:p,h=e.height,g=e.minHeight,_=e.maxHeight,v=e.width,y=e.minWidth,b=e.maxWidth,x=e.basicSetup,S=e.placeholder,C=e.indentWithTab,w=e.editable,T=e.readOnly,E=e.root,D=e.initialState,O=Are(e,Zq),k=(0,B.useRef)(null),A=Xq({root:E,value:i,autoFocus:f,theme:m,height:h,minHeight:g,maxHeight:_,width:v,minWidth:y,maxWidth:b,basicSetup:x,placeholder:S,indentWithTab:C,editable:w,readOnly:T,selection:a,onChange:c,onStatistics:l,onCreateEditor:u,onUpdate:d,extensions:s,initialState:D}),j=A.state,M=A.view,N=A.container,P=A.setContainer;(0,B.useImperativeHandle)(t,()=>({editor:k.current,state:j,view:M}),[k,N,j,M]);var F=(0,B.useCallback)(e=>{k.current=e,P(e)},[P]);if(typeof i!=`string`)throw Error(`value must be typeof string but got `+typeof i);var ee=typeof m==`string`?`cm-theme-`+m:`cm-theme`;return(0,z.jsx)(`div`,GV({ref:F,className:``+ee+(n?` `+n:``)},O))});Qq.displayName=`CodeMirror`;var $q=/^(\d{4})-(\d{2})-(\d{2})$/,eJ=/^(\d{4}-\d{2}-\d{2})([T ])(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-](\d{2}):(\d{2}))?$/,tJ=[31,28,31,30,31,30,31,31,30,31,30,31],nJ=e=>e%4==0&&e%100!=0||e%400==0;function rJ(e){if(typeof e!=`string`)return!1;let t=$q.exec(e);if(!t)return!1;let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])];return r<1||r>12||i<1?!1:i<=(r===2&&nJ(n)?29:tJ[r-1])}function iJ(e){if(typeof e!=`string`)return null;let t=eJ.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u]=t;return!rJ(n)||Number(i)>23||Number(a)>59||o!==void 0&&Number(o)>59||l!==void 0&&(Number(l)>23||Number(u)>59)?null:{date:n,sep:r,hour:i,minute:a,second:o??null,fraction:s??null,offset:c??null}}var aJ=e=>iJ(e)!==null;function oJ(e){let t=e.second===null?``:`:${e.second}${e.fraction===null?``:`.${e.fraction}`}`;return`${e.date}${e.sep}${e.hour}:${e.minute}${t}${e.offset??``}`}function sJ(e){if(rJ(e))return Date.parse(`${e}T00:00:00Z`);let t=iJ(e);if(!t)return null;let n=(t.fraction??``).padEnd(3,`0`).slice(0,3);return Date.parse(`${t.date}T${t.hour}:${t.minute}:${t.second??`00`}.${n}${t.offset??`Z`}`)}function cJ({className:e,size:t=`default`,...n}){return(0,z.jsx)(uD,{"data-slot":`switch`,"data-size":t,className:T(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80`,e),...n,children:(0,z.jsx)(fD,{"data-slot":`switch-thumb`,className:T(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground`)})})}function lJ({className:e,...t}){return(0,z.jsx)(`textarea`,{"data-slot":`textarea`,className:T(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var uJ=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/,dJ=e=>String(e).padStart(2,`0`);function fJ(e){let t=iJ(e);if(!t||t.fraction!==null&&t.fraction.length>3)return null;let n=t.second===null?``:`:${t.second}${t.fraction===null?``:`.${t.fraction}`}`,r=t.fraction===null?t.second===null?60:1:.001;return{value:`${t.date}T${t.hour}:${t.minute}${n}`,step:r}}function pJ(e,t,n){let[r,i,a]=e.split(`-`).map(Number),o=-new Date(r,i-1,a,Number(t),Number(n)).getTimezoneOffset(),s=Math.abs(o);return`${o<0?`-`:`+`}${dJ(Math.floor(s/60))}:${dJ(s%60)}`}function mJ(e,t,n=pJ){let r=uJ.exec(e);if(!r)return null;let[,i,a,o,s,c]=r,l=t===null?null:iJ(t);if(!l)return oJ({date:i,sep:`T`,hour:a,minute:o,second:null,fraction:null,offset:n(i,a,o)});let u=l.fraction?.length??0,d=(c??``).replace(/0+$/,``).length;return oJ({date:i,sep:l.sep,hour:a,minute:o,second:l.second===null?null:s??`00`,fraction:l.fraction===null?null:(c??``).padEnd(u,`0`).slice(0,Math.max(u,d)),offset:l.offset})}var hJ=e=>{let t=/^([+-])(\d{2}):(\d{2})$/.exec(e??``);return t?(t[1]===`-`?-1:1)*(Number(t[2])*60+Number(t[3])):0};function gJ(e,t){if(typeof e!=`string`)return;let n=sJ(e);if(n===null)return;let r=new Date(n+hJ(t)*6e4).toISOString(),i=iJ(e),a=i?.second==null?``:i.fraction===null?r.slice(16,19):r.slice(16,23);return`${r.slice(0,16)}${a}`}function _J(e,t){return t===`date`?rJ(e)?null:`not a date`:t===`datetime`?aJ(e)?null:`not a datetime`:t===`list`?Array.isArray(e)?null:`not a list`:t===`map`?typeof e==`object`&&e&&!Array.isArray(e)?null:`not a map`:null}function vJ(e,t){return t===`date`||t===`datetime`?_J(e,t)===null?sJ(e):null:typeof e==`number`?e:typeof e==`bigint`?Number(e):null}var yJ=e=>typeof e==`number`?e:sJ(e);function bJ(e,t,n,r){let i=vJ(e,t);return i===null?null:n!==void 0&&i<yJ(n)?`below min ${n}`:r!==void 0&&i>yJ(r)?`above max ${r}`:null}var xJ=e=>e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`,SJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),CJ=e=>Array.isArray(e)?`[${e.length}]`:SJ(e)?`{${Object.keys(e).length}}`:``,wJ=/^(import\s|export\s+(const|let|var|function|class|default|async|\{|\*))/,TJ=/^\s*([-*_]\s*){3,}$|^\s*\|?\s*:?-{3,}/;function EJ(e){let t=[],n=[],r=()=>{n.length>0&&t.push(n.join(` `)),n=[]},i=!1;for(let t of e.split(`
|
|
71
|
+
`)){if(/^\s*(```|~~~)/.test(t)){i=!i,r();continue}if(i||wJ.test(t)||TJ.test(t))continue;let e=/^\s*(#{1,6}\s|\|)/.test(t),a=/^\s*([-*+]|\d+[.)])\s/.test(t);(e||a)&&r();let o=t.replace(/^\s*(#{1,6}\s+|>\s?|[-*+]\s+(\[[ xX]\]\s+)?|\d+[.)]\s+)/,``).replace(/<\/?[A-Za-z][^>]*>/g,``).replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/(\*\*|__|~~)(.+?)\1/g,`$2`).replace(/\*([^*\s][^*]*)\*/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\s*\|\s*/g,` `).trim();o===``?r():n.push(o),e&&r()}return r(),t.join(` · `)}var DJ=3,OJ=2;function kJ(e,t,n){if(e==null)return{kind:`null`};if(typeof e==`boolean`)return{kind:`bool`,value:e};if(typeof e==`number`)return{kind:`number`,text:String(e)};if(typeof e==`string`)return t===`INTEGER`&&/^-?\d+$/.test(e)?{kind:`number`,text:e}:n===`markdown`?{kind:`text`,text:EJ(e)}:{kind:`text`,text:e.replaceAll(`
|
|
72
|
+
`,` ⏎ `)};if(Array.isArray(e))return e.every(xJ)?{kind:`chips`,items:e.slice(0,DJ).map(String),more:Math.max(0,e.length-DJ)}:{kind:`nested`,label:CJ(e),preview:e.map(CJ).join(`, `)};if(SJ(e)){let t=Object.entries(e);return t.length>0&&t.every(([,e])=>xJ(e))?{kind:`map`,entries:t.slice(0,OJ).map(([e,t])=>[e,String(t)]),more:Math.max(0,t.length-OJ)}:{kind:`nested`,label:CJ(e),preview:t.map(([e,t])=>xJ(t)?e:`${e}${CJ(t)}`).join(`, `)}}return{kind:`text`,text:String(e)}}var AJ=e=>typeof e==`object`&&!!e&&!Array.isArray(e),jJ=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`);function MJ(e){return xJ(e)?!0:Array.isArray(e)?jJ(e):AJ(e)&&Object.values(e).every(MJ)}function NJ(e,t,n,r){return n?`ref`:r===`date`&&(e==null||rJ(e))?`date`:r===`datetime`&&(e==null||typeof e==`string`&&fJ(e)!==null)?`datetime`:e==null?r===`map`?`map`:`unset`:typeof e==`boolean`?`switch`:typeof e==`number`?`number`:typeof e==`string`?t===`INTEGER`&&/^-?\d+$/.test(e)?`bigint`:r===`markdown`?`markdown`:e.includes(`
|
|
73
|
+
`)||e.length>80?`textarea`:`text`:jJ(e)?`chips`:AJ(e)&&MJ(e)?`map`:`json`}function PJ(e){switch(e){case`BOOLEAN`:return!1;case`INTEGER`:case`REAL`:return 0;case`JSON`:return{};case`TEXT`:return``}}function FJ(e){return JSON.stringify(e??null,(e,t)=>AJ(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function IJ(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>FJ(e[n])!==FJ(t[n]))}function LJ(e,t){let n=IJ(e,t);return{values:Object.fromEntries(n.map(e=>[e,t[e]??null])),base:Object.fromEntries(n.map(t=>[t,e[t]??null]))}}function RJ(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(Array.isArray(e)){let t=[...e];return t[r]=RJ(t[r],i,n),t}let a=AJ(e)?e:{};return{...a,[r]:RJ(a[r],i,n)}}function zJ(e,t,n,r){return e==null?null:_J(e,t)??bJ(e,t,n,r)}function BJ({label:e,value:t,onChange:n,placeholder:r=kn(),removeLabel:i=e=>Jn({item:e}),accept:a=()=>!0,unique:o=!1,invalid:s=!1}){let[c,l]=(0,B.useState)(``),u=()=>{let e=c.trim();if(e===``)return l(``);a(e)&&(o&&t.includes(e)||n([...t,e]),l(``))};return(0,z.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center gap-1 rounded-md border ${s?`border-warn`:``} bg-background px-1.5 py-1 transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,children:[t.map((e,r)=>(0,z.jsxs)(`span`,{className:cA,children:[e,(0,z.jsx)(`button`,{type:`button`,"aria-label":i(e),className:`ml-1 opacity-60 hover:opacity-100 max-md:grid max-md:size-7 max-md:place-items-center`,onClick:()=>n(t.filter((e,t)=>t!==r)),children:(0,z.jsx)(Fk,{className:`size-3`})})]},`${r}-${e}`)),(0,z.jsx)(`input`,{"aria-label":e,className:`min-w-32 flex-1 bg-transparent px-1 text-base outline-none placeholder:text-muted-foreground md:text-sm`,placeholder:r,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),u()):e.key===`Backspace`&&!e.repeat&&c===``&&t.length>0&&n(t.slice(0,-1))},onBlur:u}),c.trim()!==``&&(0,z.jsx)(`button`,{type:`button`,"aria-label":Nn({field:e}),className:`rounded-md px-2 text-[13px] text-muted-foreground md:hidden`,onMouseDown:e=>e.preventDefault(),onClick:u,children:On()})]})}function VJ(e,t,n){let r=t?.find(t=>t.name===e.table)?.key;return e.target===void 0||e.target===r?{key:n}:{filter:[{col:e.target,op:`eq`,value:n}]}}function HJ({reference:e,value:t,className:n,children:r}){let{data:i}=ry();return(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.table},search:VJ(e,i?.tables,t),"aria-label":`open ${e.table} ${t}`,className:n??`text-tomato underline-offset-2 hover:underline`,onClick:e=>e.stopPropagation(),children:r??t})}var UJ=()=>Fh({from:`__root__`,select:e=>e.app!==void 0}),WJ=(0,B.createContext)(!1),GJ=()=>(0,B.useContext)(WJ),KJ=()=>()=>{};function qJ(e){return(0,B.useSyncExternalStore)(KJ,()=>null)}var JJ,YJ=()=>JJ;function XJ(e,t=document.baseURI){return new URL(`-/apps/${encodeURIComponent(e)}/`,t).toString()}function ZJ(e,t){let n=new URL(`.`,t).pathname,r=new URL(e).pathname;if(!r.startsWith(n))return;let i=/^-\/apps\/([^/]+)\/?$/.exec(r.slice(n.length))?.[1];if(i!==void 0)try{return decodeURIComponent(i)}catch{return}}var QJ=`modulepreload`,$J=function(e,t){return new URL(e,t).href},eY={},tY=function(e){return e.pathname.endsWith(`.css`)},nY=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},rY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=$J(t,n);let r=s(t),i=tY(r);return nY(eY,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:QJ,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},iY=e=>e.join(`.`),aY=(0,B.lazy)(()=>rY(()=>import(`./MarkdownField-DbmIyR2F.js`),__vite__mapDeps([0,1,2]),import.meta.url));function oY({path:e,value:t,problem:n,onChange:r,onValidity:i,readOnly:a}){let[o,s]=(0,B.useState)(()=>JSON.stringify(t,null,2)),[c,l]=(0,B.useState)(null),u=h(),d=(0,B.useRef)(JSON.stringify(t)),f=(0,B.useRef)(i);f.current=i;let p=iY(e);return(0,B.useEffect)(()=>{JSON.stringify(t)!==d.current&&(d.current=JSON.stringify(t),s(JSON.stringify(t,null,2)),l(null),f.current?.(p,!0))},[t,p]),(0,B.useEffect)(()=>()=>f.current?.(p,!0),[p]),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(Qq,{"aria-label":p,value:o,extensions:[WV(),X.lineWrapping],theme:u,editable:!a,basicSetup:{lineNumbers:!1,foldGutter:!1},className:`overflow-hidden rounded-md border text-[12px] ${dY(n)}`,onChange:e=>{s(e);try{let t=JSON.parse(e);d.current=JSON.stringify(t),r(t),l(null),i?.(p,!0)}catch(e){l(e instanceof Error?e.message:String(e)),i?.(p,!1)}}}),c&&(0,z.jsx)(`p`,{className:`mt-1 text-[11px] text-err`,children:c})]})}var sY=e=>e===!0?`1`:e===!1?`0`:e==null?``:String(e);function cY({path:e,value:t,allowed:n,onChange:r,readOnly:i}){let a=sY(t),o=a!==``&&!n.some(e=>sY(e)===a);return(0,z.jsxs)(`select`,{"aria-label":iY(e),"aria-invalid":o||void 0,disabled:i,className:`${oA} w-full ${o?`border-warn text-warn`:``}`,value:a,onChange:e=>{let t=e.target.value;if(t===``)return r(null);let i=n.find(e=>sY(e)===t);i!==void 0&&r(i)},children:[(0,z.jsx)(`option`,{value:``,children:`—`}),o&&(0,z.jsx)(`option`,{value:a,children:`${a} (not in values)`}),n.map((e,t)=>(0,z.jsx)(`option`,{value:sY(e),children:String(e)},`${t}:${sY(e)}`))]})}function lY({path:e,value:t,type:n,reference:r,onChange:i}){let a=GJ(),o=r?.table??``,s=r?.key,{data:c}=V_({queryKey:[`refKeys`,o],queryFn:()=>Uv.rows(o,{limit:500,offset:0,filters:[]}),enabled:o!==``}),l=`ref-${iY(e)}`,u=t==null?``:String(t);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(Ik,{"aria-label":iY(e),list:l,value:u,onChange:e=>{let t=e.target.value;if(t===``)return i(null);let r=Number(t);i(n===`INTEGER`&&mY.test(t)&&Number.isSafeInteger(r)?r:t)}}),r&&u!==``&&!a&&(0,z.jsx)(HJ,{reference:r,value:u,className:`shrink-0 text-muted-foreground hover:text-foreground max-md:grid max-md:size-9 max-md:place-items-center max-md:text-foreground`,children:(0,z.jsx)(rO,{className:`size-4`})})]}),(0,z.jsx)(`datalist`,{id:l,children:s!==void 0&&[...new Set(c?.rows.flatMap(e=>e[s]==null?[]:[String(e[s])]))].map(e=>(0,z.jsx)(`option`,{value:e},e))})]})}function uY(e){let{path:t,value:n,problem:r,onChange:i}=e,a=Object.entries(n??{}),[o,s]=(0,B.useState)(null);return(0,z.jsxs)(`div`,{className:`rounded-lg border bg-panel px-2.5 pt-2.5 pb-1 ${dY(r)}`,children:[a.map(([r,a])=>(0,z.jsxs)(`div`,{className:`mb-2.5 grid grid-cols-[minmax(34px,auto)_1fr_auto] items-start gap-1.5`,children:[(0,z.jsx)(`span`,{className:`pt-1.5 font-mono text-[11px] text-syn-key max-md:text-[12.5px]`,children:r}),(0,z.jsx)(vY,{...e,path:[...t,r],value:a,type:void 0,format:void 0,min:void 0,max:void 0,reference:void 0,label:void 0,onChange:e=>i({...n,[r]:e})}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Jn({item:iY([...t,r])}),className:`pt-1.5 text-muted-foreground max-md:grid max-md:size-8 max-md:place-items-center max-md:pt-0`,onClick:()=>{let{[r]:e,...t}=n;i(t)},children:(0,z.jsx)(Fk,{className:`size-3.5`})})]},r)),o===null?(0,z.jsx)(`button`,{type:`button`,className:`pb-2 text-[11.5px] text-muted-foreground max-md:py-2 max-md:text-[13px]`,onClick:()=>s(``),children:Hn()}):(0,z.jsx)(Ik,{autoFocus:!0,"aria-label":Gn({field:iY(t)}),className:`mb-2 h-7`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()!==``&&(i({...n,[o.trim()]:``}),s(null)),e.key===`Escape`&&s(null)}})]})}var dY=e=>e?`border-warn`:``;function fY({path:e,value:t,min:n,max:r,problem:i,onChange:a}){return(0,z.jsx)(Ik,{type:`date`,"aria-label":iY(e),className:`${sA} font-mono ${dY(i)}`,value:typeof t==`string`?t:``,min:typeof n==`string`?n:void 0,max:typeof r==`string`?r:void 0,onChange:e=>a(e.target.value===``?null:e.target.value)})}function pY({path:e,value:t,min:n,max:r,problem:i,onChange:a}){let o=typeof t==`string`?t:``,s=o===``?null:fJ(o),c=iJ(o)?.offset??null,l=o===``?pJ(new Date().toISOString().slice(0,10),`12`,`00`):c,u=(0,B.useRef)(o);return o!==``&&(u.current=o),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 max-md:flex-wrap`,children:[(0,z.jsx)(Ik,{type:`datetime-local`,"aria-label":iY(e),className:`w-60 font-mono max-md:w-full ${dY(i)}`,step:s?.step??60,value:s?.value??``,min:gJ(n,l),max:gJ(r,l),onChange:e=>{if(e.target.value===``)return a(null);let t=mJ(e.target.value,u.current===``?null:u.current);t!==null&&a(t)}}),c&&(0,z.jsx)(`span`,{className:`font-mono text-[12px] text-muted-foreground`,children:c})]})}var mY=/^-?\d+$/,hY=/^-?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i;function gY(e){let{path:t,value:n,type:r,format:i,reference:a,problem:o,onChange:s}=e,c=i===`date`||i===`datetime`,[l,u]=(0,B.useState)(()=>NJ(n,r,a!==void 0,i)),[d,f]=(0,B.useState)(n==null?``:String(n)),p=n==null?``:String(n),m=(e,t)=>{l===`unset`&&(u(t??NJ(e,r,!1,i)),f(e==null?``:String(e))),s(e)},h=e=>(0,z.jsx)(`button`,{type:`button`,"aria-label":In({field:iY(t),kind:e}),className:`shrink-0 rounded border px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground hover:text-foreground max-md:grid max-md:min-h-8 max-md:min-w-8 max-md:place-items-center`,onClick:()=>u(e===`text`?`text`:NJ(n,r,!1,i)),children:e===`text`?(0,z.jsx)(jk,{className:`size-3.5`}):i===`date`?(0,z.jsx)(sO,{className:`size-3.5`}):(0,z.jsx)(yO,{className:`size-3.5`})});if(e.allowed&&r!==`JSON`)return(0,z.jsx)(cY,{...e,allowed:e.allowed});switch(l){case`switch`:return(0,z.jsx)(cJ,{"aria-label":iY(t),checked:n===!0,onCheckedChange:m});case`number`:case`bigint`:return(0,z.jsx)(Ik,{"aria-label":iY(t),inputMode:r===`REAL`?`decimal`:`numeric`,className:`${sA} font-mono ${dY(o)}`,value:d,onChange:e=>{let t=e.target.value;f(t);let n=t.trim();if(r===`INTEGER`){if(!mY.test(n))return;let e=Number(n);s(Number.isSafeInteger(e)?e:n)}else hY.test(n)&&Number.isFinite(Number(n))&&s(Number(n))}});case`date`:case`datetime`:return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[l===`date`?(0,z.jsx)(fY,{...e}):(0,z.jsx)(pY,{...e}),h(`text`)]});case`text`:{let e=(0,z.jsx)(Ik,{"aria-label":iY(t),className:dY(o),value:p,onChange:e=>m(c&&e.target.value===``?null:e.target.value)});if(!c)return e;let a=NJ(n,r,!1,i)===i;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e,a&&h(`picker`)]})}case`textarea`:return(0,z.jsx)(lJ,{"aria-label":iY(t),className:dY(o),rows:4,value:p,onChange:e=>m(e.target.value)});case`markdown`:return(0,z.jsx)(B.Suspense,{fallback:(0,z.jsx)(lJ,{"aria-label":iY(t),rows:4,value:p,readOnly:!0}),children:(0,z.jsx)(aY,{...e})});case`ref`:return(0,z.jsx)(lY,{...e});case`chips`:return(0,z.jsx)(BJ,{label:iY(t),value:n??[],onChange:s,invalid:o});case`map`:return(0,z.jsx)(uY,{...e});case`json`:return(0,z.jsx)(oY,{...e});case`unset`:if(r===`JSON`){let e=[{name:`map`,text:`{ } map`,next:{},chosen:`map`},{name:`list`,text:`[ ] list`,next:[],chosen:`chips`},{name:`JSON`,text:`JSON`,next:[],chosen:`json`}],n=i===`list`?e.filter(e=>e.name!==`map`):e;return(0,z.jsx)(`div`,{className:`flex gap-1.5`,children:n.map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-label":In({field:iY(t),kind:e.name}),className:`rounded border px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground hover:text-foreground`,onClick:()=>m(e.next,e.chosen),children:e.text},e.name))})}return(0,z.jsx)(`button`,{type:`button`,"aria-label":iY(t),className:`text-[12px] text-muted-foreground hover:text-foreground`,onClick:()=>m(PJ(r??`TEXT`)),children:Yn()})}}var _Y=e=>e==null||(Array.isArray(e)?e.length===0:typeof e==`object`&&Object.keys(e).length===0);function vY(e){let{label:t,value:n,type:r,readOnly:i,onChange:a}=e,o=zJ(n,e.format,e.min,e.max),[s]=(0,B.useState)(()=>r===`JSON`&&n==null&&e.format!==`map`),[c,l]=(0,B.useState)(0);return(0,z.jsxs)(`div`,{"data-problem":o??void 0,children:[t!==void 0&&(0,z.jsxs)(`div`,{className:`mb-1 flex items-center gap-2`,children:[t,s&&!i&&n!=null&&(0,z.jsxs)(`button`,{type:`button`,"aria-label":Vn({field:iY(e.path)}),className:`inline-flex shrink-0 items-center gap-1 rounded px-1 text-[12px] font-semibold text-muted-foreground max-md:text-[13px] font-medium hover:text-foreground`,onClick:()=>{(_Y(n)||window.confirm(Rn()))&&(a(null),l(e=>e+1))},children:[(0,z.jsx)(sk,{className:`size-3`}),Ln()]})]}),(0,z.jsx)(gY,{...e,problem:o!==null},c),o&&(0,z.jsx)(`p`,{className:`mt-1 text-[11px] text-warn`,children:o})]})}function yY({table:e,open:t,onOpenChange:n,initial:r={},initialKey:i=``}){let a=Nh(),{connected:o}=ay(),s=oy(),[c,l]=(0,B.useState)(i),[u,d]=(0,B.useState)(r),[f,p]=(0,B.useState)(0),m=H_({mutationFn:()=>{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e!=null&&e!==``));return Uv.create(e.name,c,t)},onMutate:()=>s({type:`saved`,table:e.name,key:c,at:Date.now()}),onError:()=>s({type:`cancelled`,table:e.name,key:c}),onSuccess:()=>{n(!1),l(i),d(r),p(e=>e+1),a({to:`/t/$table`,params:{table:e.name},search:e=>({...e,key:c})})}}),h=lA(m.error);return(0,z.jsx)(qk,{open:t,onOpenChange:n,children:(0,z.jsxs)(Qk,{pinned:!0,className:`sm:max-w-2xl`,children:[(0,z.jsx)($k,{pinned:!0,children:(0,z.jsx)(nA,{children:Mt({table:e.name})})}),(0,z.jsxs)(eA,{children:[(0,z.jsxs)(`label`,{className:aA,children:[(e.mode===`files`?Yt:Qt)({key:e.key}),(0,z.jsx)(Ik,{"aria-label":sn(),value:c,onChange:e=>l(e.target.value),className:`mt-1 font-mono`})]}),h?.field===`key`&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:h.message}),Object.entries(e.columns).filter(([t])=>t!==e.key&&!(e.captures??[]).some(e=>e.column===t)).map(([t,n])=>(0,z.jsx)(`div`,{children:(0,z.jsx)(vY,{path:[t],label:(0,z.jsxs)(`div`,{className:T(`flex-1`,aA,e.required.includes(t)&&u[t]==null&&`text-warn`),children:[t,e.required.includes(t)&&(0,z.jsx)(`span`,{"aria-label":Qa(),children:` *`})]}),value:u[t]??null,type:n,format:Object.hasOwn(e.formats,t)?e.formats[t]:void 0,mdx:e.files?.endsWith(`.mdx`),allowed:Object.hasOwn(e.values,t)?e.values[t]:void 0,min:Object.hasOwn(e.min,t)?e.min[t]:void 0,max:Object.hasOwn(e.max,t)?e.max[t]:void 0,reference:e.references.find(e=>e.column===t),onChange:e=>d({...u,[t]:e})})},`${f}:${t}`)),h&&h.field!==`key`&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:h.message})]}),(0,z.jsxs)(tA,{pinned:!0,children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>n(!1),children:gt()}),(0,z.jsx)(V,{disabled:c===``||m.isPending||!o,title:o?void 0:yt(),onClick:()=>m.mutate(),children:An()})]})]})})}function bY({title:e}){return(0,z.jsx)(`div`,{className:`p-6 text-muted-foreground`,children:Rl({title:e})})}var xY=63,SY=64,CY=1,wY=2,TY=3,EY=4,DY=5,OY=6,kY=7,AY=65,jY=66,MY=8,NY=9,PY=10,FY=11,IY=12,LY=13,RY=19,zY=20,BY=29,VY=33,HY=34,UY=47,WY=0,GY=1,KY=2,qY=3,JY=4,YY=class{constructor(e,t,n){this.parent=e,this.depth=t,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n}};YY.top=new YY(null,-1,WY);function XY(e,t){for(let n=0,r=t-e.pos-1;;r--,n++){let t=e.peek(r);if(QY(t)||t==-1)return n}}function ZY(e){return e==32||e==9}function QY(e){return e==10||e==13}function $Y(e){return ZY(e)||QY(e)}function eX(e){return e<0||$Y(e)}var tX=new aj({start:YY.top,reduce(e,t){return e.type==qY&&(t==zY||t==HY)?e.parent:e},shift(e,t,n,r){if(t==TY)return new YY(e,XY(r,r.pos),GY);if(t==AY||t==DY)return new YY(e,XY(r,r.pos),KY);if(t==xY)return e.parent;if(t==RY||t==VY)return new YY(e,0,qY);if(t==LY&&e.type==JY)return e.parent;if(t==UY){let t=/[1-9]/.exec(r.read(r.pos,n.pos));if(t)return new YY(e,e.depth+ +t[0],JY)}return e},hash(e){return e.hash}});function nX(e,t,n=0){return e.peek(n)==t&&e.peek(n+1)==t&&e.peek(n+2)==t&&eX(e.peek(n+3))}var rX=new ZA((e,t)=>{if(e.next==-1&&t.canShift(SY))return e.acceptToken(SY);let n=e.peek(-1);if((QY(n)||n<0)&&t.context.type!=qY){if(nX(e,45)){if(t.canShift(xY))e.acceptToken(xY);else return e.acceptToken(CY,3)}if(nX(e,46)){if(t.canShift(xY))e.acceptToken(xY);else return e.acceptToken(wY,3)}let n=0;for(;e.next==32;)n++,e.advance();(n<t.context.depth||n==t.context.depth&&t.context.type==GY&&(e.next!=45||!eX(e.peek(1))))&&e.next!=-1&&!QY(e.next)&&e.next!=35&&e.acceptToken(xY,-n)}},{contextual:!0}),iX=new ZA((e,t)=>{if(t.context.type==qY)e.next==63&&(e.advance(),eX(e.next)&&e.acceptToken(kY));else if(e.next==45)e.advance(),eX(e.next)&&e.acceptToken(t.context.type==GY&&t.context.depth==XY(e,e.pos-1)?EY:TY);else if(e.next==63)e.advance(),eX(e.next)&&e.acceptToken(t.context.type==KY&&t.context.depth==XY(e,e.pos-1)?OY:DY);else{let n=e.pos;for(;;)if(ZY(e.next)){if(e.pos==n)return;e.advance()}else if(e.next==33)cX(e);else if(e.next==38)lX(e);else if(e.next==42){lX(e);break}else if(e.next==39||e.next==34){if(uX(e,!0))break;return}else if(e.next==91||e.next==123){if(!dX(e))return;break}else{hX(e,!0,!1,0);break}for(;ZY(e.next);)e.advance();if(e.next==58){if(e.pos==n&&t.canShift(BY))return;eX(e.peek(1))&&e.acceptTokenTo(t.context.type==KY&&t.context.depth==XY(e,n)?jY:AY,n)}}},{contextual:!0});function aX(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 oX(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function sX(e,t){return e.next==37?(e.advance(),oX(e.next)&&e.advance(),oX(e.next)&&e.advance(),!0):aX(e.next)||t&&e.next==44?(e.advance(),!0):!1}function cX(e){if(e.advance(),e.next==60){for(e.advance();;)if(!sX(e,!0)){e.next==62&&e.advance();break}}else for(;sX(e,!1););}function lX(e){for(e.advance();!eX(e.next)&&pX(e.next)!=`f`;)e.advance()}function uX(e,t){let n=e.next,r=!1,i=e.pos;for(e.advance();;){let a=e.next;if(a<0)break;if(e.advance(),a==n){if(a==39){if(e.next==39)e.advance();else break}else break}else if(a==92&&n==34)e.next>=0&&e.advance();else if(QY(a)){if(t)return!1;r=!0}else if(t&&e.pos>=i+1024)return!1}return!r}function dX(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(!uX(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||QY(e.next))return!1;else e.advance()}var fX=`iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif`;function pX(e){return e<33?`u`:e>125?`s`:fX[e-33]}function mX(e,t){let n=pX(e);return n!=`u`&&!(t&&n==`f`)}function hX(e,t,n,r){if(pX(e.next)==`s`||(e.next==63||e.next==58||e.next==45)&&mX(e.peek(1),n))e.advance();else return!1;let i=e.pos;for(;;){let a=e.next,o=0,s=r+1;for(;$Y(a);){if(QY(a)){if(t)return!1;s=0}else s++;a=e.peek(++o)}if(!(a>=0&&(a==58?mX(e.peek(o+1),n):a==35?e.peek(o-1)!=32:mX(a,n)))||!n&&s<=r||s==0&&!n&&(nX(e,45,o)||nX(e,46,o)))break;if(t&&pX(a)==`f`)return!1;for(let t=o;t>=0;t--)e.advance();if(t&&e.pos>i+1024)return!1}return!0}var gX=new ZA((e,t)=>{if(e.next==33)cX(e),e.acceptToken(IY);else if(e.next==38||e.next==42){let t=e.next==38?PY:FY;lX(e),e.acceptToken(t)}else e.next==39||e.next==34?(uX(e,!1),e.acceptToken(NY)):hX(e,!1,t.context.type==qY,t.context.depth)&&e.acceptToken(MY)}),_X=new ZA((e,t)=>{let n=t.context.type==JY?t.context.depth:-1,r=e.pos;scan:for(;;){let i=0,a=e.next;for(;a==32;)a=e.peek(++i);if(!i&&(nX(e,45,i)||nX(e,46,i))||!QY(a)&&(n<0&&(n=Math.max(t.context.depth+1,i)),i<n))break;for(;;){if(e.next<0)break scan;let t=QY(e.next);if(e.advance(),t)continue scan;r=e.pos}}e.acceptTokenTo(LY,r)}),vX=dj({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}),yX=oj.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:tX,nodeProps:[[`isolate`,-3,8,9,14,``],[`openedBy`,18,`[`,32,`{`],[`closedBy`,19,`]`,33,`}`]],propSources:[vX],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:[rX,iX,gX,_X,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),bX=HB.define({name:`yaml`,parser:yX.configure({props:[rV.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:aV({closing:`}`}),FlowSequence:aV({closing:`]`})}),lV.add({"FlowMapping FlowSequence":uV,"Item Pair BlockLiteral":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{commentTokens:{line:`#`},indentOnInput:/^\s*[\]\}]$/}});function xX(){return new ZB(bX)}W.meta;function SX({className:e,orientation:t=`horizontal`,...n}){return(0,z.jsx)(TD,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:T(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var CX=O(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function wX({className:e,variant:t=`default`,...n}){return(0,z.jsx)(DD,{"data-slot":`tabs-list`,"data-variant":t,className:T(CX({variant:t}),e),...n})}function TX({className:e,...t}){return(0,z.jsx)(kD,{"data-slot":`tabs-trigger`,className:T(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function EX({className:e,...t}){return(0,z.jsx)(jD,{"data-slot":`tabs-content`,className:T(`flex-1 outline-none`,e),...t})}var DX=`(width < 48rem)`,OX=e=>{let t=matchMedia(DX);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},kX=()=>(0,B.useSyncExternalStore)(OX,()=>matchMedia(DX).matches);function AX(e,t){let n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return Yr();let r=new Intl.RelativeTimeFormat(E(),{numeric:`always`}),i=Math.round(n/60);if(i<60)return r.format(-i,`minute`);let a=Math.round(i/60);if(a<24)return r.format(-a,`hour`);let o=Math.round(a/24);return o<30?r.format(-o,`day`):e.slice(0,10)}var jX=e=>e==null?ni():typeof e==`string`?e:JSON.stringify(e),MX=(e,t,n)=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0});function NX(e,t,n){let r={};for(let t of Object.keys(e))MX(r,t,null);for(let[e,n]of Object.entries(t))MX(r,e,n);return MX(r,n,e[n]),r}function PX(e){let t=e?.at(-1);if(!e||!t||t.state!==`ok`)return null;let n=e.reduce((e,t)=>e+(t.state===`ok`?t.entries.filter(e=>e.kind===`commit`).length:0),0);return t.next===null?String(n):`${n}+`}function FX(e,t,n){return U_({queryKey:[`history`,e,t],queryFn:({pageParam:n})=>Uv.history(e,t,n),initialPageParam:void 0,getNextPageParam:e=>e.state===`ok`?e.next??void 0:void 0,enabled:n})}var IX=e=>e.slice(0,7),LX=e=>e.sha??`wip`;function RX({title:e,children:t}){return(0,z.jsxs)(`div`,{className:`px-2 py-10 text-center text-[13px] text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`mb-1.5 text-[15px] font-semibold text-foreground`,children:e}),t]})}function zX({children:e}){return(0,z.jsx)(`span`,{className:`rounded border px-1.5 font-mono text-[11px] text-muted-foreground`,children:e})}function BX({table:e,recordKey:t,rev:n}){let{data:r,error:i}=V_({queryKey:[`history`,e,t,`diff`,n],queryFn:()=>Uv.historyDiff(e,t,n)});return i?(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:i.message}):r?(0,z.jsx)(`pre`,{className:`overflow-x-auto rounded-md bg-panel py-2 font-mono text-[12px] leading-relaxed`,children:r.text.split(`
|
|
74
|
+
`).map((e,t)=>(0,z.jsx)(`span`,{className:T(`block px-3 whitespace-pre`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-ok/15 text-ok`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-err-soft text-err`),children:e},t))}):(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:bt()})}function VX({entry:e,...t}){let[n,r]=(0,B.useState)(`fields`),i=e.record,a=i!==null&&IJ(t.current,NX(t.current,i,t.keyColumn)).length>0,o=n===`yaml`||e.changes.length===0;return(0,z.jsxs)(`div`,{className:`rounded-b-lg border border-t-0 p-3`,children:[(0,z.jsxs)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:[e.changes.length>0?(0,z.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border text-[12px]`,children:[`fields`,`yaml`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>r(e),className:T(`px-2.5 py-0.5`,n===e&&`bg-foreground text-background`),children:e===`fields`?Jr():li()},e))}):(0,z.jsx)(`span`,{className:`text-[12px] text-muted-foreground`,children:e.unreadable?si():ti()}),e.kind===`commit`&&e.sha&&i!==null&&t.canRestore&&(0,z.jsx)(V,{variant:`outline`,size:`sm`,className:`ml-auto`,disabled:!a,title:a?ii():ai(),onClick:()=>t.onRestore(i,e.sha),children:ri()})]}),o?(0,z.jsx)(BX,{table:t.table,recordKey:t.recordKey,rev:LX(e)}):e.changes.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[7rem_1fr] gap-2 border-b border-dashed py-2 last:border-b-0`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12px] break-all text-muted-foreground`,children:e.path}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1 font-mono text-[12px]`,children:[e.from!==null&&(0,z.jsx)(`span`,{className:`rounded bg-err-soft px-2 py-0.5 break-all text-err line-through`,children:jX(e.from)}),(0,z.jsx)(`span`,{className:`rounded bg-ok/15 px-2 py-0.5 break-all text-ok`,children:jX(e.to)})]})]},e.path))]})}function HX(e){let{query:t}=e,[n,r]=(0,B.useState)(null);if(t.error)return(0,z.jsx)(`p`,{className:`text-[13px] text-err`,children:t.error.message});let i=t.data?.pages[0];if(!t.data||!i)return(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:bt()});if(i.state===`nogit`)return(0,z.jsx)(RX,{title:$r(),children:ei()});if(i.state===`untracked`)return(0,z.jsx)(RX,{title:Zr(),children:Qr()});if(i.state===`error`)return(0,z.jsx)(`p`,{className:`text-[13px] text-err`,children:i.message});let a=t.data.pages.flatMap(e=>e.state===`ok`?e.entries:[]),o=Date.now();return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`ol`,{className:`relative m-0 list-none p-0 before:absolute before:top-3.5 before:bottom-3.5 before:left-[11px] before:w-0.5 before:bg-border`,children:a.map(t=>{let i=LX(t),a=n===i;return(0,z.jsxs)(`li`,{className:`relative mb-1.5 pl-8`,children:[(0,z.jsx)(`span`,{className:T(`absolute top-3.5 left-1 size-4 rounded-full border-2 border-muted-foreground bg-background`,t.kind===`wip`&&`border-dashed border-warn`,t.head&&`border-tomato`,a&&`border-primary bg-primary`)}),(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>r(a?null:i),className:T(`block w-full rounded-lg border border-transparent px-3 py-2 text-left hover:bg-panel`,a&&`rounded-b-none border-border bg-panel`),children:[(0,z.jsxs)(`span`,{className:`flex items-baseline gap-2 text-[14px] font-semibold`,children:[t.kind===`wip`?ci():t.subject,t.kind===`wip`&&(0,z.jsx)(`span`,{className:`rounded bg-warn-soft px-1.5 text-[11px] text-warn`,children:oi()}),t.head&&(0,z.jsx)(`span`,{className:`rounded bg-chip px-1.5 text-[11px] text-chip-foreground`,children:`HEAD`})]}),(0,z.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[12px] text-muted-foreground`,children:[t.sha&&(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:IX(t.sha)}),t.author&&(0,z.jsx)(`span`,{children:t.author}),(0,z.jsx)(`span`,{children:AX(t.date,o)})]}),t.renamedFrom?(0,z.jsxs)(`span`,{className:`mt-1 block font-mono text-[12px] text-muted-foreground`,children:[t.renamedFrom,` → `,t.path]}):(0,z.jsxs)(`span`,{className:`mt-1.5 flex flex-wrap gap-1`,children:[t.event===`created`&&(0,z.jsx)(zX,{children:Kr()}),t.event===`deleted`&&(0,z.jsx)(zX,{children:qr()}),t.changes.map(e=>(0,z.jsx)(zX,{children:e.path},e.path))]})]}),a&&(0,z.jsx)(VX,{...e,entry:t})]},i)})}),t.hasNextPage&&(0,z.jsx)(`button`,{type:`button`,disabled:t.isFetchingNextPage,onClick:()=>void t.fetchNextPage(),className:`mt-2 ml-8 text-[12px] text-muted-foreground`,children:Xr()})]})}function UX({table:e,recordKey:t}){let n=vee(e,t);if(!n)return null;let r=n.state===`pending`?Xa():n.state===`applied`?Ya({file:n.file}):n.state===`failed`?Ga({reason:n.reason}):Ka(),i=n.state===`applied`?`text-ok`:n.state===`failed`?`text-err`:`text-muted-foreground`;return(0,z.jsx)(`span`,{role:`status`,className:`text-[11px] ${i}`,children:r})}var WX={min:320,max:()=>Math.max(320,Math.floor(window.innerWidth*.7))},GX={min:180,max:()=>Math.max(180,Math.min(480,Math.floor(window.innerWidth*.4)))},KX=(e,t)=>Math.min(t.max(),Math.max(t.min,Math.round(e)));function qX(e,t,n){try{let r=localStorage.getItem(e);return r!==null&&Number.isFinite(Number(r))?KX(Number(r),n):t}catch{return t}}function JX(e,t,n=WX){let[r,i]=(0,B.useState)(()=>qX(e,t,n));return[r,r=>{let a=r===null?t:KX(r,n);i(a);try{r===null?localStorage.removeItem(e):localStorage.setItem(e,String(a))}catch{}}]}var YX=e=>{let t=window.visualViewport;return t?.addEventListener(`resize`,e),t?.addEventListener(`scroll`,e),()=>{t?.removeEventListener(`resize`,e),t?.removeEventListener(`scroll`,e)}};function XX(e){let t=(0,B.useSyncExternalStore)(YX,()=>window.visualViewport?.height);return e?t:void 0}var ZX=16;function QX({width:e,label:t,onResize:n,edge:r=`left`,bounds:i=WX}){let a=r===`left`?-1:1;return(0,z.jsx)(`div`,{role:`separator`,"aria-label":t,"aria-orientation":`vertical`,"aria-valuenow":e,"aria-valuemin":i.min,"aria-valuemax":i.max(),tabIndex:0,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault();let r=t.currentTarget;r.setPointerCapture?.(t.pointerId),document.body.setAttribute(`data-resizing`,``);let i=t.clientX,o=t=>n(e+a*(t.clientX-i)),s=!1,c=()=>{if(s)return;s=!0,document.removeEventListener(`pointermove`,o),document.removeEventListener(`pointerup`,c),document.removeEventListener(`pointercancel`,c),r.removeEventListener(`lostpointercapture`,c),document.body.removeAttribute(`data-resizing`);let e=e=>e.stopPropagation();window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),0)};document.addEventListener(`pointermove`,o),document.addEventListener(`pointerup`,c),document.addEventListener(`pointercancel`,c),r.addEventListener(`lostpointercapture`,c)},onDoubleClick:()=>n(null),onKeyDown:t=>{let r=t.key===`ArrowLeft`?-a*ZX:t.key===`ArrowRight`?a*ZX:0;r!==0&&(t.preventDefault(),n(e+r))},className:T(`absolute inset-y-0 z-10 w-1 cursor-col-resize outline-none hover:bg-primary/40 focus-visible:bg-primary/40`,r===`left`?`-left-0.5`:`-right-0.5`)})}var $X={overlay:`absolute inset-y-0 right-0 z-20 shadow-xl`,docked:`relative`};function eZ({layout:e,widthKey:t,defaultWidth:n,resizeLabel:r,className:i,children:a,...o}){let s=kX(),[c,l]=JX(t,n),u=XX(s),d=s?u?{height:u}:void 0:{width:c};return(0,z.jsxs)(`aside`,{...o,className:T(`flex min-h-0 flex-col border-l bg-background`,$X[e],`max-md:fixed max-md:inset-0 max-md:z-40 max-md:h-dvh max-md:border-l-0 max-md:shadow-none max-md:animate-[y-slide-up_160ms_ease-out]`,i),style:d,children:[!s&&(0,z.jsx)(QX,{width:c,label:r,onResize:l}),a]})}function tZ({onClose:e,className:t,children:n}){let r=kX();return(0,z.jsxs)(`header`,{className:T(`flex items-center gap-2 border-b px-3.5 py-2.5 max-md:gap-1 max-md:px-2 max-md:pt-[calc(0.625rem+env(safe-area-inset-top))]`,t),children:[r&&(0,z.jsx)(V,{variant:`ghost`,size:`icon-lg`,"aria-label":_t(),onClick:e,children:(0,z.jsx)($D,{className:`size-5`})}),n,!r&&(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":_t(),onClick:e,children:(0,z.jsx)(Fk,{className:`size-5`})})]})}function nZ({className:e,...t}){return(0,z.jsx)(`div`,{...t,className:T(`flex items-center gap-2 border-t px-3.5 py-2.5 max-md:pb-[calc(0.625rem+env(safe-area-inset-bottom))]`,e)})}var rZ=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r)setTimeout(function(){r(e)},0);else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h)d[r]=void 0;else{if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends rZ{};function iZ(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function aZ(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function oZ(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function sZ(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function cZ(e,t){return oZ(e,t,``)}function lZ(e,t){return sZ(e,t,``)}function uZ(e,t){return t.slice(0,dZ(e,t))}function dZ(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function fZ(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function pZ(e,t){if(t)return hZ(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function mZ(e,t){if(t)return hZ(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function hZ(e,t){if(!t)return[mZ(e),pZ(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=fZ(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var gZ=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,_Z=RegExp(`[${gZ}]+|\\s+|[^${gZ}]`,`ug`),vZ=new class extends rZ{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=fZ(e,r)}else n=e.match(_Z)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&bZ(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&bZ(n,i,r,null,t.intlSegmenter),e}};function yZ(e,t,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?SZ(e,t,n):vZ.diff(e,t,n)}function bZ(e,t,n,r,i){if(t&&n){let[a,o]=hZ(t.value,i),[s,c]=hZ(n.value,i);if(e){let r=iZ(a,s);e.value=sZ(e.value,s,r),t.value=cZ(t.value,r),n.value=cZ(n.value,r)}if(r){let e=aZ(o,c);r.value=oZ(r.value,c,e),t.value=lZ(t.value,e),n.value=lZ(n.value,e)}}else if(n){if(e){let e=mZ(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=mZ(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=mZ(r.value,i),[a,o]=hZ(t.value,i),s=iZ(n,a);t.value=cZ(t.value,s);let c=aZ(cZ(n,s),o);t.value=lZ(t.value,c),r.value=oZ(r.value,n,c),e.value=sZ(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=mZ(r.value,i),n=uZ(pZ(t.value,i),e);t.value=lZ(t.value,n)}else if(e){let n=uZ(pZ(e.value,i),mZ(t.value,i));t.value=cZ(t.value,n)}}var xZ=new class extends rZ{tokenize(e){let t=RegExp(`(\\r?\\n)|[${gZ}]+|[^\\S\\n\\r]+|[^${gZ}]`,`ug`);return e.match(t)||[]}};function SZ(e,t,n){return xZ.diff(e,t,n)}var CZ=new class extends rZ{constructor(){super(...arguments),this.tokenize=TZ}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
75
75
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
76
76
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
77
77
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
78
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function
|
|
79
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
80
|
-
`)||e.length>120),
|
|
81
|
-
`),jZ=(e,t)=>({kind:e,segments:[{text:t,mark:!1}]});function MZ(e,t){let n=vZ(e,t,{intlSegmenter:OZ});return[{kind:`del`,segments:n.filter(e=>!e.added).map(e=>({text:e.value,mark:e.removed}))},{kind:`add`,segments:n.filter(e=>!e.removed).map(e=>({text:e.value,mark:e.added}))}]}function NZ(e,t){let n=CZ(e,t),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=AZ(t.value),a=n[e+1];if(t.removed&&a?.added){let t=AZ(a.value),n=Math.min(i.length,t.length),o=Array.from({length:n},(e,n)=>MZ(i[n],t[n]));r.push(...o.map(([e])=>e),...i.slice(n).map(e=>jZ(`del`,e))),r.push(...o.map(([,e])=>e),...t.slice(n).map(e=>jZ(`add`,e))),e++}else r.push(...i.map(e=>jZ(t.added?`add`:t.removed?`del`:`same`,e)))}return r}function PZ(e){let t=e.map(()=>!1);e.forEach((n,r)=>{if(n.kind!==`same`)for(let n=Math.max(0,r-DZ);n<=Math.min(e.length-1,r+DZ);n++)t[n]=!0});let n=[];return e.forEach((e,r)=>{let i=t[r]?`lines`:`skip`,a=n.at(-1);a?.kind===i?a.lines.push(e):n.push({kind:i,lines:[e]})}),n}var FZ={same:` `,add:`+`,del:`-`};function IZ({line:e}){return e.segments.map((t,n)=>t.mark?(0,z.jsx)(`mark`,{className:T(`rounded-sm text-inherit`,e.kind===`add`?`bg-ok/30`:`bg-err/25`),children:t.text},n):t.text)}function LZ({line:e}){return(0,z.jsxs)(`div`,{className:T(`flex gap-2 px-2.5`,e.kind===`add`&&`bg-ok/15`,e.kind===`del`&&`bg-err-soft`,e.kind===`same`&&`text-muted-foreground`),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:T(`shrink-0 select-none`,e.kind===`add`?`text-ok`:e.kind===`del`&&`text-err`),children:FZ[e.kind]}),(0,z.jsxs)(`span`,{className:`min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,z.jsx)(IZ,{line:e}),e.segments.every(e=>e.text===``)&&`\xA0`]})]})}function RZ({hunk:e}){let[t,n]=(0,B.useState)(!1);return t?e.lines.map((e,t)=>(0,z.jsx)(LZ,{line:e},t)):(0,z.jsx)(`button`,{type:`button`,onClick:()=>n(!0),className:`block w-full bg-panel px-2.5 py-0.5 text-left font-sans text-[13px] text-muted-foreground hover:text-foreground`,children:wa({count:e.lines.length})})}function zZ({field:e,before:t,after:n,legend:r}){let i=(0,B.useMemo)(()=>PZ(NZ(t,n)),[t,n]);return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e,className:`flex min-w-0 flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`font-mono text-syn-key`,children:e}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono text-err`,children:FZ.del}),` `,(0,z.jsx)(`span`,{className:`[&>*]:text-inherit`,children:r[0]})]}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono text-ok`,children:FZ.add}),` `,(0,z.jsx)(`span`,{className:`[&>*]:text-inherit`,children:r[1]})]})]}),(0,z.jsx)(`div`,{className:`overflow-hidden rounded-md border font-mono text-[13px] leading-relaxed`,children:i.map((e,t)=>e.kind===`skip`?(0,z.jsx)(RZ,{hunk:e},t):e.lines.map((e,n)=>(0,z.jsx)(LZ,{line:e},`${t}:${n}`)))})]})}var BZ=e=>typeof e==`string`?e:e==null?``:JSON.stringify(e),VZ=e=>!e.dim&&e.a!==e.b&&(kZ(e.a)||kZ(e.b));function HZ(e,t){let n=t(e.a),r=t(e.b);if(e.dim||typeof e.a!=`string`||typeof e.b!=`string`||e.a===e.b)return{a:n,b:r};let[i,a]=MZ(n,r);return{a:(0,z.jsx)(IZ,{line:i}),b:(0,z.jsx)(IZ,{line:a})}}function UZ({labels:e,rows:t,note:n,className:r}){return OX()?(0,z.jsxs)(`div`,{"data-testid":`field-diff`,className:T(`flex flex-col gap-2 font-mono text-[13px]`,r),children:[n&&(0,z.jsx)(`p`,{className:`font-sans text-muted-foreground`,children:n}),t.map(t=>(0,z.jsxs)(`div`,{role:`group`,"aria-label":t.field,className:T(`overflow-hidden rounded-md border`,t.dim&&`opacity-50`),children:[(0,z.jsx)(`div`,{className:`bg-panel px-2.5 py-1.5 font-semibold text-syn-key`,children:t.field}),[[e[0],t.a],[e[1],t.b]].map(([e,n],r)=>(0,z.jsxs)(`div`,{className:`flex gap-2 border-t px-2.5 py-1.5 break-all`,children:[(0,z.jsx)(`span`,{className:`w-24 shrink-0 font-sans text-[12px] text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:T(t.dim&&`line-clamp-2`),children:n})]},r))]},t.field))]}):(0,z.jsxs)(`div`,{"data-testid":`field-diff`,className:T(`grid grid-cols-[auto_1fr_1fr] gap-x-3 gap-y-1 font-mono text-[12px]`,r),children:[(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:e[0]}),(0,z.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:e[1]}),n&&(0,z.jsx)(`span`,{className:`col-span-3 text-muted-foreground`,children:n}),t.map(e=>(0,z.jsxs)(`div`,{className:T(`contents`,e.dim&&`opacity-50`),children:[(0,z.jsx)(`span`,{className:`text-syn-key`,children:e.field}),(0,z.jsx)(`span`,{className:T(`[overflow-wrap:anywhere]`,e.dim&&`line-clamp-2`),children:e.a}),(0,z.jsx)(`span`,{className:T(`[overflow-wrap:anywhere]`,e.dim&&`line-clamp-2`),children:e.b})]},e.field))]})}function WZ({labels:e,rows:t,format:n,note:r,className:i}){let a=t.filter(e=>!VZ(e)),o=t.filter(VZ);return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(a.length>0||r)&&(0,z.jsx)(UZ,{labels:e,note:r,className:i,rows:a.map(e=>({field:e.field,...HZ(e,n),dim:e.dim}))}),o.map(t=>(0,z.jsx)(zZ,{field:t.field,legend:e,before:BZ(t.a),after:BZ(t.b)},t.field))]})}function GZ({stale:e,current:t,draft:n,onReload:r,onOverwrite:i,onClose:a}){let o=(0,B.useRef)(null);return(0,z.jsx)(qk,{open:!0,onOpenChange:e=>!e&&a(),children:(0,z.jsxs)(Qk,{onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{children:so()}),(0,z.jsx)(rA,{children:io()})]}),(0,z.jsx)(WZ,{labels:[oo(),ao()],format:e=>JSON.stringify(e??null),rows:e.map(e=>({field:e,a:t[e],b:n[e]}))}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{ref:o,variant:`outline`,onClick:r,children:Za()}),(0,z.jsx)(V,{onClick:i,children:Ha()})]})]})})}var KZ=(e,t)=>Object.hasOwn(e.columns,t)?e.columns[t]:void 0,qZ=(e,t)=>Object.hasOwn(e.formats,t)?e.formats[t]:void 0,JZ=e=>e.files?.endsWith(`.mdx`)??!1,YZ=(e,t)=>Object.hasOwn(e.values,t)?e.values[t]:void 0,XZ=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,ZZ={layout:`overlay`,widthKey:`yamlite-drawer-width`,defaultWidth:360,"data-record-drawer":``},QZ=`flex-1 text-[14px]`;function $Z(e,t=!0){let n=(0,B.useRef)(void 0);(0,B.useEffect)(()=>{t&&(n.current=window.event)},[t]),(0,B.useEffect)(()=>{if(!t)return;let r=t=>{if(t===n.current)return;let r=t.composedPath();r.length!==0&&r[0]instanceof Element&&(r.some(e=>e instanceof Element&&e.matches(`aside[data-record-drawer], [role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], [data-sonner-toaster], [role="row"][data-key]`))||e())},i=t=>{t.key===`Escape`&&!document.querySelector(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper]`)&&e()};return document.addEventListener(`click`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`click`,r),document.removeEventListener(`keydown`,i)}})}function eQ({table:e,recordKey:t,headerActions:n,onClose:r}){let i=h(),a=Sg(),o=Nh(),s=oy(),{connected:c}=ay(),l=c&&!Yv(),{data:u,error:d}=V_({queryKey:[`record`,e.name,t],queryFn:()=>Uv.record(e.name,t)}),[f,p]=(0,B.useState)(null),[m,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(new Set),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(null),[E,D]=(0,B.useState)(`form`),[O,k]=(0,B.useState)(null),A=PX(e.name,t,E===`history`&&!Yv()),[j,M]=(0,B.useState)(0),N=f!==null&&m!==null&&LJ(f,m).length>0,P=OX();(0,B.useEffect)(()=>{u&&!N&&(m&&LJ(m,u.row).length===0?p(u.row):F(u.row))},[u,N]);function F(e){p(e),g(e),v(new Set),w(null),M(e=>e+1),k(null)}function ee(t,n){f&&(g(MX(f,t,e.key)),v(new Set),M(e=>e+1),k(n.slice(0,7)),D(`form`))}let I=H_({mutationFn:({values:n,base:r})=>Uv.update(e.name,t,n,r),onMutate:()=>s({type:`saved`,table:e.name,key:t,at:Date.now()}),onSuccess:(n,r)=>{let i={...f,...r.values};p(i),g(i),k(null),a.setQueryData([`record`,e.name,t],e=>e&&{...e,row:i}),a.invalidateQueries({queryKey:[`record`,e.name,t]})},onError:n=>{s({type:`cancelled`,table:e.name,key:t}),n instanceof Sv&&n.status===409&&Array.isArray(n.body.stale)&&b({fields:n.body.stale,current:n.body.current})}}),te=H_({mutationFn:()=>Uv.remove(e.name,t),onMutate:()=>s({type:`saved`,table:e.name,key:t,at:Date.now()}),onError:()=>s({type:`cancelled`,table:e.name,key:t}),onSuccess:()=>{r?r():o({to:`/t/$table`,params:{table:e.name},search:{}})}}),ne=()=>{!f||!m||!N||_.size>0||!c||I.isPending||I.mutate(RJ(f,m))},re=()=>r?r():void o({to:`/t/$table`,params:{table:e.name},search:e=>({...e,key:void 0})});if($Z(re,!N),(0,B.useEffect)(()=>{let e=e=>{e.key===`s`&&(e.metaKey||e.ctrlKey)&&!Yv()&&(e.preventDefault(),ne())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),d)return(0,z.jsx)($X,{...ZZ,resizeLabel:$a(),"aria-label":Ba(),className:`p-4 text-err`,children:d.message});if(!m||!f||!u)return(0,z.jsx)($X,{...ZZ,resizeLabel:$a(),"aria-label":Ba()});let ie=Object.keys(e.columns).filter(t=>t!==e.key),ae=Object.keys(m).filter(t=>t!==e.key&&!ie.includes(t)),oe=new Set(LJ(f,m)),se=oe.size,ce=NX(A.data?.pages);return(0,z.jsxs)($X,{...ZZ,resizeLabel:$a(),"aria-label":Ba(),children:[(0,z.jsxs)(xX,{value:E,onValueChange:e=>{D(e),v(e=>new Set([...e].filter(e=>e!==`$json`))),w(null)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(eZ,{onClose:re,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono font-bold`,title:t,children:t}),n]}),(0,z.jsx)(`div`,{className:`border-b px-3.5 py-2`,children:(0,z.jsxs)(CX,{className:`h-9 w-full`,children:[(0,z.jsx)(wX,{value:`form`,className:QZ,children:lo()}),(0,z.jsx)(wX,{value:`json`,className:QZ,children:`JSON`}),(0,z.jsx)(wX,{value:`yaml`,className:QZ,children:co()}),!Yv()&&(0,z.jsxs)(wX,{value:`history`,className:QZ,children:[uo(),ce!==null&&(0,z.jsx)(`span`,{className:`ml-1 font-mono text-[12px] text-muted-foreground`,children:ce})]})]})}),(0,z.jsx)(`div`,{className:`truncate px-4 pt-3 font-mono text-[13px] text-muted-foreground`,children:u.file}),(0,z.jsxs)(TX,{value:`form`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,onFocus:e=>P&&e.target.matches(`input, textarea, [contenteditable]`)&&e.target.scrollIntoView?.({block:`center`}),children:[!c&&(0,z.jsx)(`p`,{className:`mb-2 text-[13px] text-err`,children:Ia()}),(0,z.jsx)(`fieldset`,{disabled:!l,className:`m-0 min-w-0 border-0 p-0`,children:[...ie,...ae].map(t=>{let n=e.references.find(e=>e.column===t),r=(e.captures??[]).some(e=>e.column===t),i=(0,z.jsx)(_Y,{readOnly:!l||r,path:[t],label:(0,z.jsxs)(`div`,{className:`flex flex-1 justify-between ${aA}`,children:[(0,z.jsxs)(`span`,{className:e.required.includes(t)&&m[t]==null?`text-warn`:void 0,children:[t,e.required.includes(t)&&(0,z.jsx)(`span`,{"aria-label":Qa(),children:` *`})]}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] font-medium max-md:text-[11.5px]`,children:n?`→ ${n.table}`:qZ(e,t)??KZ(e,t)??Va()})]}),value:m[t],type:KZ(e,t),format:qZ(e,t),mdx:JZ(e),allowed:YZ(e,t),min:XZ(e.min,t),max:XZ(e.max,t),reference:n,onChange:e=>g({...m,[t]:e}),onValidity:(e,t)=>v(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})},`${t}:${j}`);return(0,z.jsx)(`div`,{className:T(`mb-3.5`,O&&oe.has(t)&&`-mx-2 rounded-md bg-warn-soft px-2 py-1`),children:r?(0,z.jsx)(`fieldset`,{disabled:!0,className:`m-0 min-w-0 border-0 p-0`,children:i}):i},t)})})]}),(0,z.jsxs)(TX,{value:`json`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:[(0,z.jsx)($q,{"aria-label":Ra(),value:JSON.stringify(m,null,2),extensions:[GV(),X.lineWrapping],theme:i,editable:l,onChange:t=>{try{let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(za());g({...n,[e.key]:m[e.key]}),v(e=>new Set([...e].filter(e=>e!==`$json`))),w(null)}catch(e){v(e=>new Set([...e,`$json`])),w(e instanceof Error?e.message:String(e))}}}),C&&(0,z.jsx)(`p`,{className:`mt-1 text-[13px] text-err`,children:C})]}),(0,z.jsxs)(TX,{value:`yaml`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:[u.yamlError&&(0,z.jsx)(`p`,{className:`mb-2 text-[13px] text-err`,children:u.yamlError}),(0,z.jsx)($q,{"aria-label":La(),value:u.yaml??`# not written to a file yet`,extensions:[bX(),X.lineWrapping],editable:!1,theme:i})]}),!Yv()&&(0,z.jsx)(TX,{value:`history`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,z.jsx)(VX,{table:e.name,recordKey:t,query:A,current:f,keyColumn:e.key,canRestore:l,onRestore:ee})})]}),!Yv()&&(0,z.jsxs)(tZ,{className:`max-md:flex-wrap`,children:[(0,z.jsxs)(`span`,{className:`mr-auto flex min-w-0 flex-col text-[13px] text-muted-foreground max-md:basis-full`,children:[se>0?O?no({from:O,count:se}):Da({count:se}):(0,z.jsx)(HX,{table:e.name,recordKey:t}),I.isError&&!(I.error instanceof Sv&&I.error.status===409)&&(0,z.jsx)(`span`,{className:`text-err`,children:I.error.message})]}),(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":Oa(),disabled:!c,onClick:()=>S(!0),children:(0,z.jsx)(Dk,{className:`size-4`})}),(0,z.jsx)(V,{variant:`outline`,size:P?`lg`:`sm`,disabled:!N,onClick:()=>F(f),children:Fa()}),(0,z.jsx)(V,{size:P?`lg`:`sm`,className:`max-md:flex-1`,disabled:!N||_.size>0||I.isPending||!c,title:c?void 0:yt(),onClick:ne,children:P?St():ro()})]}),y&&(0,z.jsx)(GZ,{stale:y.fields,current:y.current,draft:m,onClose:()=>b(null),onReload:()=>{F(y.current),b(null)},onOverwrite:()=>{let e=RJ(f,m);for(let t of y.fields)e.base[t]=y.current[t]??null;b(null),I.mutate(e)}}),x&&(0,z.jsx)(qk,{open:!0,onOpenChange:e=>{e||(S(!1),te.reset())},children:(0,z.jsxs)(Qk,{children:[(0,z.jsx)($k,{children:(0,z.jsx)(nA,{children:Pa({key:t})})}),(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:ja({file:u.file})}),te.error&&(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:te.error.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>{S(!1),te.reset()},children:gt()}),(0,z.jsx)(V,{variant:`destructive`,disabled:te.isPending,onClick:()=>te.mutate(),children:vt()})]})]})})]})}function tQ({table:e,recordKey:t,open:n,onOpenChange:r}){let i=Nh(),a=oy(),[o,s]=(0,B.useState)(t),c=H_({mutationFn:()=>Uv.rename(e.name,t,o),onMutate:()=>a({type:`saved`,table:e.name,key:o,at:Date.now()}),onError:()=>a({type:`cancelled`,table:e.name,key:o}),onSuccess:()=>{r(!1),i({to:`/t/$table`,params:{table:e.name},search:e=>({...e,key:o})})}}),l=lA(c.error);return(0,z.jsx)(qk,{open:n,onOpenChange:r,children:(0,z.jsxs)(Qk,{children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{children:hn()}),(0,z.jsx)(rA,{children:e.mode===`files`?pn():mn()})]}),(0,z.jsx)(Ik,{"aria-label":sn(),value:o,onChange:e=>s(e.target.value),className:`font-mono`}),l&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:l.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>r(!1),children:gt()}),(0,z.jsx)(V,{disabled:o===``||o===t||c.isPending,onClick:()=>c.mutate(),children:fn()})]})]})})}var nQ=1,rQ=.9,iQ=.8,aQ=.17,oQ=.1,sQ=.999,cQ=.9999,lQ=.99,uQ=/[\\\/_+.#"@\[\(\{&]/,dQ=/[\\\/_+.#"@\[\(\{&]/g,fQ=/[\s-]/,pQ=/[\s-]/g;function mQ(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?nQ:lQ;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=mQ(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=nQ:uQ.test(e.charAt(l-1))?(d*=iQ,p=e.slice(i,l-1).match(dQ),p&&i>0&&(d*=sQ**+p.length)):fQ.test(e.charAt(l-1))?(d*=rQ,m=e.slice(i,l-1).match(pQ),m&&i>0&&(d*=sQ**+m.length)):(d*=aQ,i>0&&(d*=sQ**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=cQ)),(d<oQ&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=mQ(e,t,n,r,l+1,a+2,o),f*oQ>d&&(d=f*oQ)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function hQ(e){return e.toLowerCase().replace(pQ,` `)}function gQ(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,mQ(e,t,hQ(e),hQ(t),0,0,{})}var _Q=`[cmdk-group=""]`,vQ=`[cmdk-group-items=""]`,yQ=`[cmdk-group-heading=""]`,bQ=`[cmdk-item=""]`,xQ=`${bQ}:not([aria-disabled="true"])`,SQ=`cmdk-item-select`,CQ=`data-value`,wQ=(e,t,n)=>gQ(e,t,n),TQ=B.createContext(void 0),EQ=()=>B.useContext(TQ),DQ=B.createContext(void 0),OQ=()=>B.useContext(DQ),kQ=B.createContext(void 0),AQ=B.forwardRef((e,t)=>{let n=WQ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=WQ(()=>new Set),i=WQ(()=>new Map),a=WQ(()=>new Map),o=WQ(()=>new Set),s=HQ(e),{label:c,children:l,value:u,onValueChange:d,filter:p,shouldFilter:m,loop:h,disablePointerSelection:g=!1,vimBindings:_=!0,...v}=e,b=y(),x=y(),S=y(),C=B.useRef(null),w=qQ();UQ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,T.emit()}},[u]),UQ(()=>{w(6,j)},[]);let T=B.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)A(),O(),w(1,k);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(S);e?e.focus():(i=document.getElementById(b))==null||i.focus()}if(w(7,()=>{n.current.selectedItemId=M()?.id,T.emit()}),r||w(5,j),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}T.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),E=B.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,D(t,r)),w(2,()=>{O(),T.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),w(3,()=>{A(),O(),n.current.value||k(),T.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=M();w(4,()=>{A(),t?.getAttribute(`id`)===e&&k(),T.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:b,inputId:S,labelId:x,listInnerRef:C}),[]);function D(e,t){let r=s.current?.filter??wQ;return e?r(e,n.current.search,t):0}function O(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=C.current;N().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(vQ);t?t.appendChild(e.parentElement===t?e:e.closest(`${vQ} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${vQ} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=C.current?.querySelector(`${_Q}[${CQ}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function k(){let e=N().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(CQ);T.setState(`value`,e||void 0)}function A(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=D(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function j(){var e;let t=M();t&&(t.parentElement?.firstChild===t&&((e=t.closest(_Q)?.querySelector(yQ))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function M(){return C.current?.querySelector(`${bQ}[aria-selected="true"]`)}function N(){return Array.from(C.current?.querySelectorAll(xQ)||[])}function P(e){let t=N()[e];t&&T.setState(`value`,t.getAttribute(CQ))}function F(e){var t;let n=M(),r=N(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&T.setState(`value`,a.getAttribute(CQ))}function ee(e){let t=M()?.closest(_Q),n;for(;t&&!n;)t=e>0?BQ(t,_Q):VQ(t,_Q),n=t?.querySelector(xQ);n?T.setState(`value`,n.getAttribute(CQ)):F(e)}let I=()=>P(N().length-1),te=e=>{e.preventDefault(),e.metaKey?I():e.altKey?ee(1):F(1)},ne=e=>{e.preventDefault(),e.metaKey?P(0):e.altKey?ee(-1):F(-1)};return B.createElement(f.div,{ref:t,tabIndex:-1,...v,"cmdk-root":``,onKeyDown:e=>{var t;(t=v.onKeyDown)==null||t.call(v,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:_&&e.ctrlKey&&te(e);break;case`ArrowDown`:te(e);break;case`p`:case`k`:_&&e.ctrlKey&&ne(e);break;case`ArrowUp`:ne(e);break;case`Home`:e.preventDefault(),P(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=M();if(t){let e=new Event(SQ);t.dispatchEvent(e)}}}}},B.createElement(`label`,{"cmdk-label":``,htmlFor:E.inputId,id:E.labelId,style:XQ},c),YQ(e,e=>B.createElement(DQ.Provider,{value:T},B.createElement(TQ.Provider,{value:E},e))))}),jQ=B.forwardRef((e,t)=>{let n=y(),r=B.useRef(null),i=B.useContext(kQ),a=EQ(),o=HQ(e),s=o.current?.forceMount??i?.forceMount;UQ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=KQ(n,r,[e.value,e.children,r],e.keywords),l=OQ(),u=GQ(e=>e.value&&e.value===c.current),d=GQ(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);B.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(SQ,m),()=>t.removeEventListener(SQ,m)},[d,e.onSelect,e.disabled]);function m(){var e,t;h(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function h(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:g,value:_,onSelect:v,forceMount:b,keywords:x,...S}=e;return B.createElement(f.div,{ref:p(r,t),...S,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!g,"aria-selected":!!u,"data-disabled":!!g,"data-selected":!!u,onPointerMove:g||a.getDisablePointerSelection()?void 0:h,onClick:g?void 0:m},e.children)}),MQ=B.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=y(),s=B.useRef(null),c=B.useRef(null),l=y(),u=EQ(),d=GQ(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));UQ(()=>u.group(o),[]),KQ(o,s,[e.value,e.heading,c]);let m=B.useMemo(()=>({id:o,forceMount:i}),[i]);return B.createElement(f.div,{ref:p(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&B.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),YQ(e,e=>B.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},B.createElement(kQ.Provider,{value:m},e))))}),NQ=B.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=B.useRef(null),a=GQ(e=>!e.search);return!n&&!a?null:B.createElement(f.div,{ref:p(i,t),...r,"cmdk-separator":``,role:`separator`})}),PQ=B.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=OQ(),o=GQ(e=>e.search),s=GQ(e=>e.selectedItemId),c=EQ();return B.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),B.createElement(f.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),FQ=B.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=B.useRef(null),o=B.useRef(null),s=GQ(e=>e.selectedItemId),c=EQ();return B.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),B.createElement(f.div,{ref:p(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},YQ(e,e=>B.createElement(`div`,{ref:p(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),IQ=B.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return B.createElement(_x,{open:n,onOpenChange:r},B.createElement(xx,{container:o},B.createElement(Cx,{"cmdk-overlay":``,className:i}),B.createElement(Dx,{"aria-label":e.label,"cmdk-dialog":``,className:a},B.createElement(AQ,{ref:t,...s}))))}),LQ=B.forwardRef((e,t)=>GQ(e=>e.filtered.count===0)?B.createElement(f.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),RQ=B.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return B.createElement(f.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},YQ(e,e=>B.createElement(`div`,{"aria-hidden":!0},e)))}),zQ=Object.assign(AQ,{List:FQ,Item:jQ,Input:PQ,Group:MQ,Separator:NQ,Dialog:IQ,Empty:LQ,Loading:RQ});function BQ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function VQ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function HQ(e){let t=B.useRef(e);return UQ(()=>{t.current=e}),t}var UQ=typeof window>`u`?B.useEffect:B.useLayoutEffect;function WQ(e){let t=B.useRef();return t.current===void 0&&(t.current=e()),t}function GQ(e){let t=OQ(),n=()=>e(t.snapshot());return B.useSyncExternalStore(t.subscribe,n,n)}function KQ(e,t,n,r=[]){let i=B.useRef(),a=EQ();return UQ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(CQ,s),i.current=s}),i}var qQ=()=>{let[e,t]=B.useState(),n=WQ(()=>new Map);return UQ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function JQ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function YQ({asChild:e,children:t},n){return e&&B.isValidElement(t)?B.cloneElement(JQ(t),{ref:t.ref},n(t.props.children)):n(t)}var XQ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},ZQ=e=>`"${e.replaceAll(`"`,`""`)}"`,QQ=class extends Error{status;extra;constructor(e,t,n={}){super(t),this.status=e,this.extra=n}},$Q=[` `,` `,`
|
|
82
|
-
`,`\r`,`-`,`_`,`.`,`/`],
|
|
78
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function wZ(e,t,n){return CZ.diff(e,t,n)}function TZ(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
79
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function EZ(e){return e==`.`||e==`!`||e==`?`}new class extends rZ{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(EZ(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends rZ{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends rZ{constructor(){super(...arguments),this.tokenize=TZ}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(DZ(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function DZ(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=DZ(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=DZ(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends rZ{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var OZ=2,kZ=new Intl.Segmenter(void 0,{granularity:`word`}),AZ=e=>typeof e==`string`&&(e.includes(`
|
|
80
|
+
`)||e.length>120),jZ=e=>e.replace(/\n$/,``).split(`
|
|
81
|
+
`),MZ=(e,t)=>({kind:e,segments:[{text:t,mark:!1}]});function NZ(e,t){let n=yZ(e,t,{intlSegmenter:kZ});return[{kind:`del`,segments:n.filter(e=>!e.added).map(e=>({text:e.value,mark:e.removed}))},{kind:`add`,segments:n.filter(e=>!e.removed).map(e=>({text:e.value,mark:e.added}))}]}function PZ(e,t){let n=wZ(e,t),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=jZ(t.value),a=n[e+1];if(t.removed&&a?.added){let t=jZ(a.value),n=Math.min(i.length,t.length),o=Array.from({length:n},(e,n)=>NZ(i[n],t[n]));r.push(...o.map(([e])=>e),...i.slice(n).map(e=>MZ(`del`,e))),r.push(...o.map(([,e])=>e),...t.slice(n).map(e=>MZ(`add`,e))),e++}else r.push(...i.map(e=>MZ(t.added?`add`:t.removed?`del`:`same`,e)))}return r}function FZ(e){let t=e.map(()=>!1);e.forEach((n,r)=>{if(n.kind!==`same`)for(let n=Math.max(0,r-OZ);n<=Math.min(e.length-1,r+OZ);n++)t[n]=!0});let n=[];return e.forEach((e,r)=>{let i=t[r]?`lines`:`skip`,a=n.at(-1);a?.kind===i?a.lines.push(e):n.push({kind:i,lines:[e]})}),n}var IZ={same:` `,add:`+`,del:`-`};function LZ({line:e}){return e.segments.map((t,n)=>t.mark?(0,z.jsx)(`mark`,{className:T(`rounded-sm text-inherit`,e.kind===`add`?`bg-ok/30`:`bg-err/25`),children:t.text},n):t.text)}function RZ({line:e}){return(0,z.jsxs)(`div`,{className:T(`flex gap-2 px-2.5`,e.kind===`add`&&`bg-ok/15`,e.kind===`del`&&`bg-err-soft`,e.kind===`same`&&`text-muted-foreground`),children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:T(`shrink-0 select-none`,e.kind===`add`?`text-ok`:e.kind===`del`&&`text-err`),children:IZ[e.kind]}),(0,z.jsxs)(`span`,{className:`min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,z.jsx)(LZ,{line:e}),e.segments.every(e=>e.text===``)&&`\xA0`]})]})}function zZ({hunk:e}){let[t,n]=(0,B.useState)(!1);return t?e.lines.map((e,t)=>(0,z.jsx)(RZ,{line:e},t)):(0,z.jsx)(`button`,{type:`button`,onClick:()=>n(!0),className:`block w-full bg-panel px-2.5 py-0.5 text-left font-sans text-[13px] text-muted-foreground hover:text-foreground`,children:wa({count:e.lines.length})})}function BZ({field:e,before:t,after:n,legend:r}){let i=(0,B.useMemo)(()=>FZ(PZ(t,n)),[t,n]);return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e,className:`flex min-w-0 flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`font-mono text-syn-key`,children:e}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono text-err`,children:IZ.del}),` `,(0,z.jsx)(`span`,{className:`[&>*]:text-inherit`,children:r[0]})]}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono text-ok`,children:IZ.add}),` `,(0,z.jsx)(`span`,{className:`[&>*]:text-inherit`,children:r[1]})]})]}),(0,z.jsx)(`div`,{className:`overflow-hidden rounded-md border font-mono text-[13px] leading-relaxed`,children:i.map((e,t)=>e.kind===`skip`?(0,z.jsx)(zZ,{hunk:e},t):e.lines.map((e,n)=>(0,z.jsx)(RZ,{line:e},`${t}:${n}`)))})]})}var VZ=e=>typeof e==`string`?e:e==null?``:JSON.stringify(e),HZ=e=>!e.dim&&e.a!==e.b&&(AZ(e.a)||AZ(e.b));function UZ(e,t){let n=t(e.a),r=t(e.b);if(e.dim||typeof e.a!=`string`||typeof e.b!=`string`||e.a===e.b)return{a:n,b:r};let[i,a]=NZ(n,r);return{a:(0,z.jsx)(LZ,{line:i}),b:(0,z.jsx)(LZ,{line:a})}}function WZ({labels:e,rows:t,note:n,className:r}){return kX()?(0,z.jsxs)(`div`,{"data-testid":`field-diff`,className:T(`flex flex-col gap-2 font-mono text-[13px]`,r),children:[n&&(0,z.jsx)(`p`,{className:`font-sans text-muted-foreground`,children:n}),t.map(t=>(0,z.jsxs)(`div`,{role:`group`,"aria-label":t.field,className:T(`overflow-hidden rounded-md border`,t.dim&&`opacity-50`),children:[(0,z.jsx)(`div`,{className:`bg-panel px-2.5 py-1.5 font-semibold text-syn-key`,children:t.field}),[[e[0],t.a],[e[1],t.b]].map(([e,n],r)=>(0,z.jsxs)(`div`,{className:`flex gap-2 border-t px-2.5 py-1.5 break-all`,children:[(0,z.jsx)(`span`,{className:`w-24 shrink-0 font-sans text-[12px] text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:T(t.dim&&`line-clamp-2`),children:n})]},r))]},t.field))]}):(0,z.jsxs)(`div`,{"data-testid":`field-diff`,className:T(`grid grid-cols-[auto_1fr_1fr] gap-x-3 gap-y-1 font-mono text-[12px]`,r),children:[(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:e[0]}),(0,z.jsx)(`span`,{className:`font-sans text-muted-foreground`,children:e[1]}),n&&(0,z.jsx)(`span`,{className:`col-span-3 text-muted-foreground`,children:n}),t.map(e=>(0,z.jsxs)(`div`,{className:T(`contents`,e.dim&&`opacity-50`),children:[(0,z.jsx)(`span`,{className:`text-syn-key`,children:e.field}),(0,z.jsx)(`span`,{className:T(`[overflow-wrap:anywhere]`,e.dim&&`line-clamp-2`),children:e.a}),(0,z.jsx)(`span`,{className:T(`[overflow-wrap:anywhere]`,e.dim&&`line-clamp-2`),children:e.b})]},e.field))]})}function GZ({labels:e,rows:t,format:n,note:r,className:i}){let a=t.filter(e=>!HZ(e)),o=t.filter(HZ);return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(a.length>0||r)&&(0,z.jsx)(WZ,{labels:e,note:r,className:i,rows:a.map(e=>({field:e.field,...UZ(e,n),dim:e.dim}))}),o.map(t=>(0,z.jsx)(BZ,{field:t.field,legend:e,before:VZ(t.a),after:VZ(t.b)},t.field))]})}function KZ({stale:e,current:t,draft:n,onReload:r,onOverwrite:i,onClose:a}){let o=(0,B.useRef)(null);return(0,z.jsx)(qk,{open:!0,onOpenChange:e=>!e&&a(),children:(0,z.jsxs)(Qk,{onOpenAutoFocus:e=>{e.preventDefault(),o.current?.focus()},children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{children:so()}),(0,z.jsx)(rA,{children:io()})]}),(0,z.jsx)(GZ,{labels:[oo(),ao()],format:e=>JSON.stringify(e??null),rows:e.map(e=>({field:e,a:t[e],b:n[e]}))}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{ref:o,variant:`outline`,onClick:r,children:Za()}),(0,z.jsx)(V,{onClick:i,children:Ha()})]})]})})}var qZ=(e,t)=>Object.hasOwn(e.columns,t)?e.columns[t]:void 0,JZ=(e,t)=>Object.hasOwn(e.formats,t)?e.formats[t]:void 0,YZ=e=>e.files?.endsWith(`.mdx`)??!1,XZ=(e,t)=>Object.hasOwn(e.values,t)?e.values[t]:void 0,ZZ=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,QZ={layout:`overlay`,widthKey:`yamlite-drawer-width`,defaultWidth:360,"data-record-drawer":``},$Z=`flex-1 text-[14px]`;function eQ(e,t=!0){let n=(0,B.useRef)(void 0);(0,B.useEffect)(()=>{t&&(n.current=window.event)},[t]),(0,B.useEffect)(()=>{if(!t)return;let r=t=>{if(t===n.current)return;let r=t.composedPath();r.length!==0&&r[0]instanceof Element&&(r.some(e=>e instanceof Element&&e.matches(`aside[data-record-drawer], [role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], [data-sonner-toaster], [role="row"][data-key]`))||e())},i=t=>{t.key===`Escape`&&!document.querySelector(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper]`)&&e()};return document.addEventListener(`click`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`click`,r),document.removeEventListener(`keydown`,i)}})}function tQ({table:e,recordKey:t,headerActions:n,onClose:r}){let i=h(),a=Sg(),o=Nh(),s=oy(),{connected:c}=ay(),l=c&&!Yv(),{data:u,error:d}=V_({queryKey:[`record`,e.name,t],queryFn:()=>Uv.record(e.name,t)}),[f,p]=(0,B.useState)(null),[m,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(new Set),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(null),[E,D]=(0,B.useState)(`form`),[O,k]=(0,B.useState)(null),A=FX(e.name,t,E===`history`&&!Yv()),[j,M]=(0,B.useState)(0),N=f!==null&&m!==null&&IJ(f,m).length>0,P=kX();(0,B.useEffect)(()=>{u&&!N&&(m&&IJ(m,u.row).length===0?p(u.row):F(u.row))},[u,N]);function F(e){p(e),g(e),v(new Set),w(null),M(e=>e+1),k(null)}function ee(t,n){f&&(g(NX(f,t,e.key)),v(new Set),M(e=>e+1),k(n.slice(0,7)),D(`form`))}let I=H_({mutationFn:({values:n,base:r})=>Uv.update(e.name,t,n,r),onMutate:()=>s({type:`saved`,table:e.name,key:t,at:Date.now()}),onSuccess:(n,r)=>{let i={...f,...r.values};p(i),g(i),k(null),a.setQueryData([`record`,e.name,t],e=>e&&{...e,row:i}),a.invalidateQueries({queryKey:[`record`,e.name,t]})},onError:n=>{s({type:`cancelled`,table:e.name,key:t}),n instanceof Sv&&n.status===409&&Array.isArray(n.body.stale)&&b({fields:n.body.stale,current:n.body.current})}}),te=H_({mutationFn:()=>Uv.remove(e.name,t),onMutate:()=>s({type:`saved`,table:e.name,key:t,at:Date.now()}),onError:()=>s({type:`cancelled`,table:e.name,key:t}),onSuccess:()=>{r?r():o({to:`/t/$table`,params:{table:e.name},search:{}})}}),ne=()=>{!f||!m||!N||_.size>0||!c||I.isPending||I.mutate(LJ(f,m))},re=()=>r?r():void o({to:`/t/$table`,params:{table:e.name},search:e=>({...e,key:void 0})});if(eQ(re,!N),(0,B.useEffect)(()=>{let e=e=>{e.key===`s`&&(e.metaKey||e.ctrlKey)&&!Yv()&&(e.preventDefault(),ne())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),d)return(0,z.jsx)(eZ,{...QZ,resizeLabel:$a(),"aria-label":Ba(),className:`p-4 text-err`,children:d.message});if(!m||!f||!u)return(0,z.jsx)(eZ,{...QZ,resizeLabel:$a(),"aria-label":Ba()});let ie=Object.keys(e.columns).filter(t=>t!==e.key),ae=Object.keys(m).filter(t=>t!==e.key&&!ie.includes(t)),oe=new Set(IJ(f,m)),se=oe.size,ce=PX(A.data?.pages);return(0,z.jsxs)(eZ,{...QZ,resizeLabel:$a(),"aria-label":Ba(),children:[(0,z.jsxs)(SX,{value:E,onValueChange:e=>{D(e),v(e=>new Set([...e].filter(e=>e!==`$json`))),w(null)},className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsxs)(tZ,{onClose:re,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono font-bold`,title:t,children:t}),n]}),(0,z.jsx)(`div`,{className:`border-b px-3.5 py-2`,children:(0,z.jsxs)(wX,{className:`h-9 w-full`,children:[(0,z.jsx)(TX,{value:`form`,className:$Z,children:lo()}),(0,z.jsx)(TX,{value:`json`,className:$Z,children:`JSON`}),(0,z.jsx)(TX,{value:`yaml`,className:$Z,children:co()}),!Yv()&&(0,z.jsxs)(TX,{value:`history`,className:$Z,children:[uo(),ce!==null&&(0,z.jsx)(`span`,{className:`ml-1 font-mono text-[12px] text-muted-foreground`,children:ce})]})]})}),(0,z.jsx)(`div`,{className:`truncate px-4 pt-3 font-mono text-[13px] text-muted-foreground`,children:u.file}),(0,z.jsxs)(EX,{value:`form`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,onFocus:e=>P&&e.target.matches(`input, textarea, [contenteditable]`)&&e.target.scrollIntoView?.({block:`center`}),children:[!c&&(0,z.jsx)(`p`,{className:`mb-2 text-[13px] text-err`,children:Ia()}),(0,z.jsx)(`fieldset`,{disabled:!l,className:`m-0 min-w-0 border-0 p-0`,children:[...ie,...ae].map(t=>{let n=e.references.find(e=>e.column===t),r=(e.captures??[]).some(e=>e.column===t),i=(0,z.jsx)(vY,{readOnly:!l||r,path:[t],label:(0,z.jsxs)(`div`,{className:`flex flex-1 justify-between ${aA}`,children:[(0,z.jsxs)(`span`,{className:e.required.includes(t)&&m[t]==null?`text-warn`:void 0,children:[t,e.required.includes(t)&&(0,z.jsx)(`span`,{"aria-label":Qa(),children:` *`})]}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] font-medium max-md:text-[11.5px]`,children:n?`→ ${n.table}`:JZ(e,t)??qZ(e,t)??Va()})]}),value:m[t],type:qZ(e,t),format:JZ(e,t),mdx:YZ(e),allowed:XZ(e,t),min:ZZ(e.min,t),max:ZZ(e.max,t),reference:n,onChange:e=>g({...m,[t]:e}),onValidity:(e,t)=>v(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})},`${t}:${j}`);return(0,z.jsx)(`div`,{className:T(`mb-3.5`,O&&oe.has(t)&&`-mx-2 rounded-md bg-warn-soft px-2 py-1`),children:r?(0,z.jsx)(`fieldset`,{disabled:!0,className:`m-0 min-w-0 border-0 p-0`,children:i}):i},t)})})]}),(0,z.jsxs)(EX,{value:`json`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:[(0,z.jsx)(Qq,{"aria-label":Ra(),value:JSON.stringify(m,null,2),extensions:[WV(),X.lineWrapping],theme:i,editable:l,onChange:t=>{try{let n=JSON.parse(t);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(za());g({...n,[e.key]:m[e.key]}),v(e=>new Set([...e].filter(e=>e!==`$json`))),w(null)}catch(e){v(e=>new Set([...e,`$json`])),w(e instanceof Error?e.message:String(e))}}}),C&&(0,z.jsx)(`p`,{className:`mt-1 text-[13px] text-err`,children:C})]}),(0,z.jsxs)(EX,{value:`yaml`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:[u.yamlError&&(0,z.jsx)(`p`,{className:`mb-2 text-[13px] text-err`,children:u.yamlError}),(0,z.jsx)(Qq,{"aria-label":La(),value:u.yaml??`# not written to a file yet`,extensions:[xX(),X.lineWrapping],editable:!1,theme:i})]}),!Yv()&&(0,z.jsx)(EX,{value:`history`,className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,z.jsx)(HX,{table:e.name,recordKey:t,query:A,current:f,keyColumn:e.key,canRestore:l,onRestore:ee})})]}),!Yv()&&(0,z.jsxs)(nZ,{className:`max-md:flex-wrap`,children:[(0,z.jsxs)(`span`,{className:`mr-auto flex min-w-0 flex-col text-[13px] text-muted-foreground max-md:basis-full`,children:[se>0?O?no({from:O,count:se}):Da({count:se}):(0,z.jsx)(UX,{table:e.name,recordKey:t}),I.isError&&!(I.error instanceof Sv&&I.error.status===409)&&(0,z.jsx)(`span`,{className:`text-err`,children:I.error.message})]}),(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":Oa(),disabled:!c,onClick:()=>S(!0),children:(0,z.jsx)(Dk,{className:`size-4`})}),(0,z.jsx)(V,{variant:`outline`,size:P?`lg`:`sm`,disabled:!N,onClick:()=>F(f),children:Fa()}),(0,z.jsx)(V,{size:P?`lg`:`sm`,className:`max-md:flex-1`,disabled:!N||_.size>0||I.isPending||!c,title:c?void 0:yt(),onClick:ne,children:P?St():ro()})]}),y&&(0,z.jsx)(KZ,{stale:y.fields,current:y.current,draft:m,onClose:()=>b(null),onReload:()=>{F(y.current),b(null)},onOverwrite:()=>{let e=LJ(f,m);for(let t of y.fields)e.base[t]=y.current[t]??null;b(null),I.mutate(e)}}),x&&(0,z.jsx)(qk,{open:!0,onOpenChange:e=>{e||(S(!1),te.reset())},children:(0,z.jsxs)(Qk,{children:[(0,z.jsx)($k,{children:(0,z.jsx)(nA,{children:Pa({key:t})})}),(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:ja({file:u.file})}),te.error&&(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:te.error.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>{S(!1),te.reset()},children:gt()}),(0,z.jsx)(V,{variant:`destructive`,disabled:te.isPending,onClick:()=>te.mutate(),children:vt()})]})]})})]})}function nQ({table:e,recordKey:t,open:n,onOpenChange:r}){let i=Nh(),a=oy(),[o,s]=(0,B.useState)(t),c=H_({mutationFn:()=>Uv.rename(e.name,t,o),onMutate:()=>a({type:`saved`,table:e.name,key:o,at:Date.now()}),onError:()=>a({type:`cancelled`,table:e.name,key:o}),onSuccess:()=>{r(!1),i({to:`/t/$table`,params:{table:e.name},search:e=>({...e,key:o})})}}),l=lA(c.error);return(0,z.jsx)(qk,{open:n,onOpenChange:r,children:(0,z.jsxs)(Qk,{children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{children:hn()}),(0,z.jsx)(rA,{children:e.mode===`files`?pn():mn()})]}),(0,z.jsx)(Ik,{"aria-label":sn(),value:o,onChange:e=>s(e.target.value),className:`font-mono`}),l&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:l.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>r(!1),children:gt()}),(0,z.jsx)(V,{disabled:o===``||o===t||c.isPending,onClick:()=>c.mutate(),children:fn()})]})]})})}var rQ=1,iQ=.9,aQ=.8,oQ=.17,sQ=.1,cQ=.999,lQ=.9999,uQ=.99,dQ=/[\\\/_+.#"@\[\(\{&]/,fQ=/[\\\/_+.#"@\[\(\{&]/g,pQ=/[\s-]/,mQ=/[\s-]/g;function hQ(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?rQ:uQ;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=hQ(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=rQ:dQ.test(e.charAt(l-1))?(d*=aQ,p=e.slice(i,l-1).match(fQ),p&&i>0&&(d*=cQ**+p.length)):pQ.test(e.charAt(l-1))?(d*=iQ,m=e.slice(i,l-1).match(mQ),m&&i>0&&(d*=cQ**+m.length)):(d*=oQ,i>0&&(d*=cQ**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=lQ)),(d<sQ&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=hQ(e,t,n,r,l+1,a+2,o),f*sQ>d&&(d=f*sQ)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function gQ(e){return e.toLowerCase().replace(mQ,` `)}function _Q(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,hQ(e,t,gQ(e),gQ(t),0,0,{})}var vQ=`[cmdk-group=""]`,yQ=`[cmdk-group-items=""]`,bQ=`[cmdk-group-heading=""]`,xQ=`[cmdk-item=""]`,SQ=`${xQ}:not([aria-disabled="true"])`,CQ=`cmdk-item-select`,wQ=`data-value`,TQ=(e,t,n)=>_Q(e,t,n),EQ=B.createContext(void 0),DQ=()=>B.useContext(EQ),OQ=B.createContext(void 0),kQ=()=>B.useContext(OQ),AQ=B.createContext(void 0),jQ=B.forwardRef((e,t)=>{let n=GQ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=GQ(()=>new Set),i=GQ(()=>new Map),a=GQ(()=>new Map),o=GQ(()=>new Set),s=UQ(e),{label:c,children:l,value:u,onValueChange:d,filter:p,shouldFilter:m,loop:h,disablePointerSelection:g=!1,vimBindings:_=!0,...v}=e,b=y(),x=y(),S=y(),C=B.useRef(null),w=JQ();WQ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,T.emit()}},[u]),WQ(()=>{w(6,j)},[]);let T=B.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)A(),O(),w(1,k);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(S);e?e.focus():(i=document.getElementById(b))==null||i.focus()}if(w(7,()=>{n.current.selectedItemId=M()?.id,T.emit()}),r||w(5,j),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}T.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),E=B.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,D(t,r)),w(2,()=>{O(),T.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),w(3,()=>{A(),O(),n.current.value||k(),T.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=M();w(4,()=>{A(),t?.getAttribute(`id`)===e&&k(),T.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:b,inputId:S,labelId:x,listInnerRef:C}),[]);function D(e,t){let r=s.current?.filter??TQ;return e?r(e,n.current.search,t):0}function O(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=C.current;N().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(yQ);t?t.appendChild(e.parentElement===t?e:e.closest(`${yQ} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${yQ} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=C.current?.querySelector(`${vQ}[${wQ}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function k(){let e=N().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(wQ);T.setState(`value`,e||void 0)}function A(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=D(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function j(){var e;let t=M();t&&(t.parentElement?.firstChild===t&&((e=t.closest(vQ)?.querySelector(bQ))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function M(){return C.current?.querySelector(`${xQ}[aria-selected="true"]`)}function N(){return Array.from(C.current?.querySelectorAll(SQ)||[])}function P(e){let t=N()[e];t&&T.setState(`value`,t.getAttribute(wQ))}function F(e){var t;let n=M(),r=N(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&T.setState(`value`,a.getAttribute(wQ))}function ee(e){let t=M()?.closest(vQ),n;for(;t&&!n;)t=e>0?VQ(t,vQ):HQ(t,vQ),n=t?.querySelector(SQ);n?T.setState(`value`,n.getAttribute(wQ)):F(e)}let I=()=>P(N().length-1),te=e=>{e.preventDefault(),e.metaKey?I():e.altKey?ee(1):F(1)},ne=e=>{e.preventDefault(),e.metaKey?P(0):e.altKey?ee(-1):F(-1)};return B.createElement(f.div,{ref:t,tabIndex:-1,...v,"cmdk-root":``,onKeyDown:e=>{var t;(t=v.onKeyDown)==null||t.call(v,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:_&&e.ctrlKey&&te(e);break;case`ArrowDown`:te(e);break;case`p`:case`k`:_&&e.ctrlKey&&ne(e);break;case`ArrowUp`:ne(e);break;case`Home`:e.preventDefault(),P(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=M();if(t){let e=new Event(CQ);t.dispatchEvent(e)}}}}},B.createElement(`label`,{"cmdk-label":``,htmlFor:E.inputId,id:E.labelId,style:ZQ},c),XQ(e,e=>B.createElement(OQ.Provider,{value:T},B.createElement(EQ.Provider,{value:E},e))))}),MQ=B.forwardRef((e,t)=>{let n=y(),r=B.useRef(null),i=B.useContext(AQ),a=DQ(),o=UQ(e),s=o.current?.forceMount??i?.forceMount;WQ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=qQ(n,r,[e.value,e.children,r],e.keywords),l=kQ(),u=KQ(e=>e.value&&e.value===c.current),d=KQ(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);B.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(CQ,m),()=>t.removeEventListener(CQ,m)},[d,e.onSelect,e.disabled]);function m(){var e,t;h(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function h(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:g,value:_,onSelect:v,forceMount:b,keywords:x,...S}=e;return B.createElement(f.div,{ref:p(r,t),...S,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!g,"aria-selected":!!u,"data-disabled":!!g,"data-selected":!!u,onPointerMove:g||a.getDisablePointerSelection()?void 0:h,onClick:g?void 0:m},e.children)}),NQ=B.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=y(),s=B.useRef(null),c=B.useRef(null),l=y(),u=DQ(),d=KQ(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));WQ(()=>u.group(o),[]),qQ(o,s,[e.value,e.heading,c]);let m=B.useMemo(()=>({id:o,forceMount:i}),[i]);return B.createElement(f.div,{ref:p(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&B.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),XQ(e,e=>B.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},B.createElement(AQ.Provider,{value:m},e))))}),PQ=B.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=B.useRef(null),a=KQ(e=>!e.search);return!n&&!a?null:B.createElement(f.div,{ref:p(i,t),...r,"cmdk-separator":``,role:`separator`})}),FQ=B.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=kQ(),o=KQ(e=>e.search),s=KQ(e=>e.selectedItemId),c=DQ();return B.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),B.createElement(f.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),IQ=B.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=B.useRef(null),o=B.useRef(null),s=KQ(e=>e.selectedItemId),c=DQ();return B.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),B.createElement(f.div,{ref:p(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},XQ(e,e=>B.createElement(`div`,{ref:p(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),LQ=B.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return B.createElement(_x,{open:n,onOpenChange:r},B.createElement(xx,{container:o},B.createElement(Cx,{"cmdk-overlay":``,className:i}),B.createElement(Dx,{"aria-label":e.label,"cmdk-dialog":``,className:a},B.createElement(jQ,{ref:t,...s}))))}),RQ=B.forwardRef((e,t)=>KQ(e=>e.filtered.count===0)?B.createElement(f.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),zQ=B.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return B.createElement(f.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},XQ(e,e=>B.createElement(`div`,{"aria-hidden":!0},e)))}),BQ=Object.assign(jQ,{List:IQ,Item:MQ,Input:FQ,Group:NQ,Separator:PQ,Dialog:LQ,Empty:RQ,Loading:zQ});function VQ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function HQ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function UQ(e){let t=B.useRef(e);return WQ(()=>{t.current=e}),t}var WQ=typeof window>`u`?B.useEffect:B.useLayoutEffect;function GQ(e){let t=B.useRef();return t.current===void 0&&(t.current=e()),t}function KQ(e){let t=kQ(),n=()=>e(t.snapshot());return B.useSyncExternalStore(t.subscribe,n,n)}function qQ(e,t,n,r=[]){let i=B.useRef(),a=DQ();return WQ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(wQ,s),i.current=s}),i}var JQ=()=>{let[e,t]=B.useState(),n=GQ(()=>new Map);return WQ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function YQ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function XQ({asChild:e,children:t},n){return e&&B.isValidElement(t)?B.cloneElement(YQ(t),{ref:t.ref},n(t.props.children)):n(t)}var ZQ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},QQ=e=>`"${e.replaceAll(`"`,`""`)}"`,$Q=class extends Error{status;extra;constructor(e,t,n={}){super(t),this.status=e,this.extra=n}},e$=[` `,` `,`
|
|
82
|
+
`,`\r`,`-`,`_`,`.`,`/`],t$=e=>e$.includes(e),n$=e=>[...e].filter(e=>!t$(e)).join(``),r$=20,i$=200;function a$(e){let t=e.get(`q`)?.trim()??``;if([...n$(t)].length<2)throw new $Q(400,`q needs at least 2 characters`);let n=e.get(`per`);if(n===null)return{needle:t,per:r$};let r=Number(n);if(!Number.isInteger(r))throw new $Q(400,`not an integer: ${n}`);return{needle:t,per:Math.min(i$,Math.max(1,r))}}var o$=[`title`,`name`,`label`];function s$(e){let t=t=>[...e.columns].find(([n,r])=>n!==e.key&&r===`TEXT`&&n.toLowerCase()===t)?.[0];for(let e of o$){let n=t(e);if(n)return n}return null}var c$=e=>`'${e.replaceAll(`'`,`''`)}'`,l$=e=>`CAST(${QQ(e)} AS TEXT)`,u$=e=>e<` `?`char(${e.charCodeAt(0)})`:c$(e),d$=e=>e$.reduce((e,t)=>`replace(${e}, ${u$(t)}, '')`,`lower(${e})`),f$=e=>`instr(${d$(l$(e))}, needle.v) > 0`;function p$(e){let t=[e.key,...[...e.columns.keys()].filter(t=>t!==e.key)].filter(t=>e.columns.get(t)!==`BOOLEAN`);if(t.length===0)return null;let n=e=>`CASE ${t.map(t=>`WHEN ${f$(t)} THEN ${e(t)}`).join(` `)} END`,r=s$(e);return`SELECT ${c$(e.name)} AS tbl, ${l$(e.key)} AS k, ${d$(l$(e.key))} AS sk, ${r?l$(r):`NULL`} AS lbl, ${n(c$)} AS col, ${n(l$)} AS val FROM main.${QQ(e.name)}, needle WHERE ${t.map(f$).join(` OR `)}`}function m$(e,t,n){let r=e.map(p$).filter(e=>e!==null);return r.length===0?null:{sql:`WITH needle(v) AS (SELECT ${d$(`?`)}),
|
|
83
83
|
hits AS (${r.join(` UNION ALL `)}),
|
|
84
84
|
ranked AS (
|
|
85
85
|
SELECT hits.*,
|
|
@@ -92,35 +92,35 @@ ranked AS (
|
|
|
92
92
|
)
|
|
93
93
|
SELECT tbl, k, lbl, col, val, grade, total FROM (
|
|
94
94
|
SELECT ranked.*, row_number() OVER (PARTITION BY tbl ORDER BY grade, k) AS n FROM ranked
|
|
95
|
-
) WHERE n <= ? ORDER BY grade, tbl, k`,params:[t,n]}}function m$(e){return{table:String(e.tbl),key:String(e.k),label:e.lbl===null||e.lbl===void 0?null:String(e.lbl),column:String(e.col),value:String(e.val??``),rank:Number(e.grade),total:Number(e.total)}}var h$=30,g$=e=>[...t$(e.trim())].length>=2,_$=e=>e.replace(/^[ \t]*(?:#{1,6}|[-*+]|>)[ \t]+/gm,``).replace(/\s+/g,` `);function v$(e,t){let n=t$(t.toLowerCase());if(n===``)return null;let r=``,i=[];for(let t=0;t<e.length;t++){if(e$(e[t]))continue;let n=e[t].toLowerCase();r+=n;for(let e=0;e<n.length;e++)i.push(t)}let a=r.indexOf(n);return a<0?null:[i[a],i[a+n.length-1]+1]}function y$(e,t,n=h$){let r=v$(e,t);if(!r){let t=e.slice(0,n*2);return{before:``,match:``,after:_$(t)+(e.length>t.length?`…`:``)}}let[i,a]=r,o=Math.max(0,i-n),s=Math.min(e.length,a+n);return{before:(o>0?`…`:``)+_$(e.slice(o,i)),match:_$(e.slice(i,a)),after:_$(e.slice(a,s))+(s<e.length?`…`:``)}}var b$=200;function x$(e,t){let n=new Map(e.map(e=>[e,wQ(e.value.slice(0,b$),t)]));return[...e].sort((e,t)=>e.rank-t.rank||(n.get(t)??0)-(n.get(e)??0)||e.table.localeCompare(t.table)||e.key.localeCompare(t.key))}function S$(e,t){let n=new Map;for(let r of x$(e,t)){let e=n.get(r.table)??{table:r.table,total:r.total,hits:[]};e.hits.push(r),n.set(r.table,e)}return[...n.values()]}function C$(e,t){let n=e.trim();return V_({queryKey:[`search`,n,t],queryFn:()=>Uv.search(n,t),enabled:g$(n),placeholderData:Hg})}var w$=`rounded-[3px] bg-tomato-soft text-inherit`;function T$({value:e,needle:t,around:n}){let r=y$(e,t,n);return(0,z.jsxs)(`span`,{children:[r.before,r.match&&(0,z.jsx)(`mark`,{className:w$,children:r.match}),r.after]})}function E$({text:e,needle:t}){return(0,z.jsx)(T$,{value:e,needle:t,around:1/0})}function D$(e,t){let[n,r]=(0,B.useState)(e);return(0,B.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var O$=$h()({beforeLoad:({context:e,matches:t})=>{if(e.app===void 0)return;let n=t.at(-1);if(n?.routeId!==`/app/$page`||n.params.page!==e.app)throw Hf({to:`/app/$page`,params:{page:e.app},replace:!0})}}),k$=Qh({getParentRoute:()=>O$,path:`/t/$table`,validateSearch:e=>({key:typeof e.key==`string`?e.key:void 0,sort:typeof e.sort==`string`?e.sort:void 0,q:typeof e.q==`string`?e.q:void 0,filter:Array.isArray(e.filter)?e.filter:void 0})}),A$=Qh({getParentRoute:()=>O$,path:`/sql`}),j$=Qh({getParentRoute:()=>O$,path:`/sync`}),M$=Qh({getParentRoute:()=>O$,path:`/erd`}),N$=Qh({getParentRoute:()=>O$,path:`/p/$page`}),P$=Qh({getParentRoute:()=>O$,path:`/app/$page`,beforeLoad:({context:e,params:t})=>{if(e.app===void 0)throw Hf({to:`/p/$page`,params:{page:t.page},replace:!0})}}),F$=Qh({getParentRoute:()=>O$,path:`/search`,validateSearch:e=>({q:typeof e.q==`string`?e.q:void 0})}),I$=20;function L$(){let{q:e}=F$.useSearch(),t=Nh(),[n,r]=(0,B.useState)(e??``);(0,B.useEffect)(()=>r(t=>t.trim()===(e??``)?t:e??``),[e]);let i=D$(n.trim(),200);(0,B.useEffect)(()=>{i!==(e??``)&&t({to:`/search`,search:{q:i||void 0},replace:!0})},[i,e,t]);let a=(e??``).trim(),o=g$(a),{data:s,isPending:c,error:l}=C$(a,I$),u=o&&s?S$(s.hits,a):[],d;if(!o)d=(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:yl()});else if(l)d=(0,z.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:l.message});else if(c)d=(0,z.jsx)(`div`,{"aria-busy":`true`,className:`h-24 animate-pulse rounded-md bg-panel-2`});else if(u.length===0)d=(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:vl()});else{let e=u.reduce((e,t)=>e+t.total,0);d=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`text-[15px] text-muted-foreground`,children:`${Sl({count:e})} · ${kl({count:u.length})}`}),u.map(e=>(0,z.jsxs)(`section`,{"aria-label":e.table,className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2.5 px-1`,children:[(0,z.jsx)(xk,{className:`size-[18px] text-muted-foreground`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-[19px] font-semibold`,children:e.table}),(0,z.jsx)(`span`,{className:`rounded-full border px-2.5 text-[13px] text-muted-foreground`,children:Sl({count:e.total})}),e.total>e.hits.length&&(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.table},search:{q:a},className:`ml-auto text-[15px] font-medium text-tomato hover:underline`,children:El({count:e.total})})]}),(0,z.jsx)(`ul`,{className:`divide-y overflow-hidden rounded-xl border`,children:e.hits.map(t=>(0,z.jsx)(`li`,{children:(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.table},search:{key:t.key},className:`group grid grid-cols-[1fr_auto] items-center gap-x-4 gap-y-0.5 px-4 py-3 outline-none hover:bg-panel focus-visible:bg-panel`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2.5`,children:[(0,z.jsx)(`span`,{className:`truncate text-[17px] font-semibold`,children:(0,z.jsx)(E$,{text:t.label??t.key,needle:a})}),t.label!==null&&(0,z.jsx)(`span`,{className:`shrink-0 font-mono text-[13px] text-muted-foreground`,children:(0,z.jsx)(E$,{text:t.key,needle:a})})]}),(0,z.jsx)(hO,{className:`row-span-2 size-[18px] text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t.value!==t.key&&t.value!==t.label&&(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`shrink-0 rounded-md bg-chip px-1.5 font-mono text-xs text-chip-foreground`,children:t.column}),(0,z.jsx)(`span`,{className:`truncate text-[15px] text-muted-foreground`,children:(0,z.jsx)(T$,{value:t.value,needle:a})})]})]})},t.key))})]},e.table))]})}return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-5 overflow-auto px-4 py-6 md:px-8`,children:[(0,z.jsx)(`h1`,{className:`sr-only`,children:Al()}),(0,z.jsxs)(`label`,{className:`flex items-center gap-3 rounded-xl border bg-panel px-4 focus-within:ring-2 focus-within:ring-ring`,children:[(0,z.jsx)(dk,{className:`size-[22px] shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,z.jsx)(`input`,{type:`search`,"aria-label":Al(),placeholder:Cl(),value:n,onChange:e=>r(e.target.value),autoFocus:!0,className:`h-14 w-full bg-transparent text-[19px] outline-none placeholder:text-muted-foreground`})]}),d]})}var R$=e=>{let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},z$=()=>document.documentElement.dataset.theme,B$=({...e})=>{let t=(0,B.useSyncExternalStore)(R$,z$);return(0,z.jsx)(yv,{theme:t,className:`toaster group`,icons:{success:(0,z.jsx)(_O,{className:`size-4`}),info:(0,z.jsx)(kO,{className:`size-4`}),warning:(0,z.jsx)(kk,{className:`size-4`}),error:(0,z.jsx)(YO,{className:`size-4`}),loading:(0,z.jsx)(zO,{className:`size-4 animate-spin`})},style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`,pointerEvents:`auto`},...e})},V$=`yamlite-ai`,H$={};function U$(){try{return JSON.parse(localStorage.getItem(V$)??`{}`)}catch{return{}}}function W$(e){try{localStorage.setItem(V$,JSON.stringify(e))}catch{}}function G$(){let e=ry();return Yv()?null:e.data?.ai?.providers??null}function K$(){let e=ry(),t=Yv()?null:e.data?.ai;return t?{viewerKeys:t.viewerKeys,settingsUrl:t.settingsUrl,unavailable:t.unavailable??!1}:null}function q$(e){return H$[e]??U$().keys?.[e]??``}function J$(e){return!!U$().keys?.[e]}function Y$(e,{viewerKeys:t}={viewerKeys:!0}){let n=U$(),r=e.find(e=>e.id===n.provider)??e.find(e=>e.hasKey)??e[0];if(!r)return null;let i=r.id===n.provider&&n.model?n.model:void 0,a=i&&(!r.fixedModels||r.models.includes(i))?i:r.models[0],o=t?q$(r.id):``;return o||r.hasKey?{provider:r.id,model:a,apiKey:o}:null}function X$(e,t){let n={...U$().keys};delete n[e.provider],delete H$[e.provider],e.apiKey&&(t?n[e.provider]=e.apiKey:H$[e.provider]=e.apiKey),W$({provider:e.provider,model:e.model,keys:n})}var Z$={get:()=>Ov(`GET`,`/api/ai/instructions`),save:e=>Ov(`PUT`,`/api/ai/instructions`,e)},Q$={items:[],busy:!1,closed:!1};function $$(e,t){let n=e.items;switch(t.type){case`user`:return{...e,items:[...n,{kind:`user`,text:t.text}]};case`text`:{let r=n.at(-1);return r?.kind===`agent`?{...e,items:[...n.slice(0,-1),{...r,text:r.text+t.text}]}:{...e,items:[...n,{kind:`agent`,text:t.text}]}}case`source`:{let r=n.at(-1),i={url:t.url,...t.title?{title:t.title}:{}};return r?.kind!==`agent`&&r?.kind!==`tool`?{...e,items:[...n,{kind:`agent`,text:``,sources:[i]}]}:r.sources?.some(e=>e.url===t.url)?e:{...e,items:[...n.slice(0,-1),{...r,sources:[...r.sources??[],i]}]}}case`tool`:{let r=n.findIndex(e=>e.kind===`tool`&&e.id===t.id);if(r<0){let r={kind:`tool`,id:t.id,title:t.title??t.id,status:t.status??null,...t.input===void 0?{}:{input:t.input}};return{...e,items:[...n,r]}}let i={...n[r],...t.title?{title:t.title}:{},...t.status===void 0?{}:{status:t.status??null},...t.input===void 0?{}:{input:t.input}};return{...e,items:n.map((e,t)=>t===r?i:e)}}case`proposal`:{let r=n.findIndex(e=>e.kind===`proposal`&&e.proposal.id===t.proposal.id),i={kind:`proposal`,proposal:t.proposal};return{...e,items:r<0?[...n,i]:n.map((e,t)=>t===r?i:e)}}case`busy`:return{...e,busy:t.busy};case`error`:return{...e,items:[...n,{kind:`error`,message:t.code===`auth`?ce():t.message,...t.code?{code:t.code}:{}}]};case`closed`:return{...e,busy:!1,closed:!0}}}var e1=encodeURIComponent,t1=e=>`/api/agent/conversations/${e1(e)}`,n1={conversations:()=>Ov(`GET`,`/api/agent/conversations`),start:e=>Ov(`POST`,`/api/agent/conversations`,{provider:e.provider,model:e.model,...e.apiKey?{apiKey:e.apiKey}:{}}),prompt:(e,t)=>Ov(`POST`,`${t1(e)}/prompt`,{text:t}),cancel:e=>Ov(`POST`,`${t1(e)}/cancel`),proposals:()=>Ov(`GET`,`/api/agent/proposals`),apply:e=>Ov(`POST`,`/api/agent/proposals/${e1(e)}/apply`),discard:e=>Ov(`POST`,`/api/agent/proposals/${e1(e)}/discard`)};function r1(e,t){let n=new Map;for(let r of e)if(r.status===`pending`)for(let e of r.rows)e.table===t&&n.set(e.key,{op:e.op,before:e.before,after:e.after,changed:e.changed});return n}var i1=2,a1=[`agent-proposals`],o1=[`agent-conversations`],s1=new class{make;state=Q$;id=null;source=null;listeners=new Set;constructor(e=e=>xv().eventSource(e)){this.make=e}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async start(e){let{id:t}=await n1.start(e);this.open(t)}open(e){ny.invalidateQueries({queryKey:o1}),this.source?.close(),this.id=e,this.set(Q$);let t=this.make(`${t1(e)}/events`);this.source=t;let n=!1;t.addEventListener(`open`,()=>{this.source===t&&(n&&this.set(Q$),n=!0)}),t.addEventListener(`agent`,e=>{if(this.source!==t||!(e instanceof MessageEvent)||typeof e.data!=`string`)return;let n;try{n=JSON.parse(e.data)}catch{return}n.type===`proposal`&&ny.invalidateQueries({queryKey:a1}),this.set($$(this.state,n)),n.type===`closed`&&this.disconnect(t)}),t.addEventListener(`error`,()=>{if(this.source===t&&t.readyState===i1&&(this.disconnect(t),!this.state.closed)){let e=$$(this.state,{type:`error`,message:de()});this.set($$(e,{type:`closed`}))}})}async send(e){this.id&&await n1.prompt(this.id,e)}async stop(){this.id&&await n1.cancel(this.id)}async reset(){ny.invalidateQueries({queryKey:o1}),this.source?.close(),this.source=null,this.id=null,this.set(Q$)}disconnect(e){e.close(),this.source===e&&(this.source=null)}set(e){this.state=e;for(let e of this.listeners)e()}},c1=()=>(0,B.useSyncExternalStore)(e=>s1.subscribe(e),()=>s1.state);function l1(){let e=G$()!==null;return V_({queryKey:a1,queryFn:n1.proposals,enabled:e}).data?.proposals??[]}function u1(e){let t=V_({queryKey:o1,queryFn:n1.conversations,enabled:e,staleTime:0});return{conversations:t.data?.conversations??[],loading:t.isPending}}var d1=()=>ny.invalidateQueries({queryKey:a1}),f1=!1,p1=new Set,m1=e=>{f1=e;for(let e of p1)e()},h1={open:()=>m1(!0),close:()=>m1(!1),toggle:()=>m1(!f1)},g1=()=>(0,B.useSyncExternalStore)(e=>(p1.add(e),()=>p1.delete(e)),()=>f1);function _1(){}function v1(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var y1=/[$_\p{ID_Start}]/u,b1=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,x1=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,S1=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,C1=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w1={};function T1(e){return e?y1.test(String.fromCodePoint(e)):!1}function E1(e,t){let n=(t||w1).jsx?x1:b1;return e?n.test(String.fromCodePoint(e)):!1}function D1(e,t){return((t||w1).jsx?C1:S1).test(e)}var O1=/[ \t\n\f\r]/g;function k1(e){return typeof e==`object`?e.type===`text`&&A1(e.value):A1(e)}function A1(e){return e.replace(O1,``)===``}var j1=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};j1.prototype.normal={},j1.prototype.property={},j1.prototype.space=void 0;function M1(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new j1(n,r,t)}function N1(e){return e.toLowerCase()}var P1=class{constructor(e,t){this.attribute=t,this.property=e}};P1.prototype.attribute=``,P1.prototype.booleanish=!1,P1.prototype.boolean=!1,P1.prototype.commaOrSpaceSeparated=!1,P1.prototype.commaSeparated=!1,P1.prototype.defined=!1,P1.prototype.mustUseProperty=!1,P1.prototype.number=!1,P1.prototype.overloadedBoolean=!1,P1.prototype.property=``,P1.prototype.spaceSeparated=!1,P1.prototype.space=void 0;var F1=e({boolean:()=>Z,booleanish:()=>L1,commaOrSpaceSeparated:()=>V1,commaSeparated:()=>B1,number:()=>Q,overloadedBoolean:()=>R1,spaceSeparated:()=>z1}),I1=0,Z=H1(),L1=H1(),R1=H1(),Q=H1(),z1=H1(),B1=H1(),V1=H1();function H1(){return 2**++I1}var U1=Object.keys(F1),W1=class extends P1{constructor(e,t,n,r){let i=-1;if(super(e,t),G1(this,`space`,r),typeof n==`number`)for(;++i<U1.length;){let e=U1[i];G1(this,U1[i],(n&F1[e])===F1[e])}}};W1.prototype.defined=!0;function G1(e,t,n){n&&(e[t]=n)}function K1(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new W1(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[N1(r)]=r,n[N1(a.attribute)]=r}return new j1(t,n,e.space)}var q1=K1({properties:{ariaActiveDescendant:null,ariaAtomic:L1,ariaAutoComplete:null,ariaBusy:L1,ariaChecked:L1,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:z1,ariaCurrent:null,ariaDescribedBy:z1,ariaDetails:null,ariaDisabled:L1,ariaDropEffect:z1,ariaErrorMessage:null,ariaExpanded:L1,ariaFlowTo:z1,ariaGrabbed:L1,ariaHasPopup:null,ariaHidden:L1,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:z1,ariaLevel:Q,ariaLive:null,ariaModal:L1,ariaMultiLine:L1,ariaMultiSelectable:L1,ariaOrientation:null,ariaOwns:z1,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:L1,ariaReadOnly:L1,ariaRelevant:null,ariaRequired:L1,ariaRoleDescription:z1,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:L1,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function J1(e,t){return t in e?e[t]:t}function Y1(e,t){return J1(e,t.toLowerCase())}var X1=K1({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:B1,acceptCharset:z1,accessKey:z1,action:null,allow:null,allowFullScreen:Z,allowPaymentRequest:Z,allowUserMedia:Z,alpha:Z,alt:null,as:null,async:Z,autoCapitalize:null,autoComplete:z1,autoFocus:Z,autoPlay:Z,blocking:z1,capture:null,charSet:null,checked:Z,cite:null,className:z1,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:L1,controls:Z,controlsList:z1,coords:Q|B1,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Z,defer:Z,dir:null,dirName:null,disabled:Z,download:R1,draggable:L1,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Z,formTarget:null,headers:z1,height:Q,hidden:R1,high:Q,href:null,hrefLang:null,htmlFor:z1,httpEquiv:z1,id:null,imageSizes:null,imageSrcSet:null,inert:Z,inputMode:null,integrity:null,is:null,isMap:Z,itemId:null,itemProp:z1,itemRef:z1,itemScope:Z,itemType:z1,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Z,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Z,muted:Z,name:null,nonce:null,noModule:Z,noValidate:Z,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Z,optimum:Q,pattern:null,ping:z1,placeholder:null,playsInline:Z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Z,referrerPolicy:null,rel:z1,required:Z,reversed:Z,rows:Q,rowSpan:Q,sandbox:z1,scope:null,scoped:Z,seamless:Z,selected:Z,shadowRootClonable:Z,shadowRootCustomElementRegistry:Z,shadowRootDelegatesFocus:Z,shadowRootMode:null,shadowRootSerializable:Z,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:L1,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Z,useMap:null,value:L1,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:z1,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Z,declare:Z,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Z,noHref:Z,noShade:Z,noWrap:Z,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:L1,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Z,disablePictureInPicture:Z,disableRemotePlayback:Z,exportParts:B1,part:z1,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:Y1}),Z1=K1({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:V1,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:z1,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Z,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:B1,g2:B1,glyphName:B1,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:V1,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:z1,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:V1,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:V1,rev:V1,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:V1,requiredFeatures:V1,requiredFonts:V1,requiredFormats:V1,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:V1,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:V1,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:V1,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:J1}),Q1=K1({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),$1=K1({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Y1}),e0=K1({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),t0={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},n0=/[A-Z]/g,r0=/-[a-z]/g,i0=/^data[-\w.:]+$/i;function a0(e,t){let n=N1(t),r=t,i=P1;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&i0.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(r0,s0);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!r0.test(e)){let n=e.replace(n0,o0);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=W1}return new i(r,t)}function o0(e){return`-`+e.toLowerCase()}function s0(e){return e.charAt(1).toUpperCase()}var c0=M1([q1,X1,Q1,$1,e0],`html`),l0=M1([q1,Z1,Q1,$1,e0],`svg`);function u0(e){return e.join(` `).trim()}var d0=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
96
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),f0=n(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var i=r(d0());function a(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=(0,i.default)(e),a=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:i}=e;a?t(r,i,e):i&&(n||={},n[r]=i)}),n}})),p0=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),m0=n(((e,t,n)=>{var r=(n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(f0()),i=p0();function a(e,t){var n={};return!e||typeof e!=`string`||(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}a.default=a,t.exports=a})),h0=_0(`end`),g0=_0(`start`);function _0(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function v0(e){let t=g0(e),n=h0(e);if(t&&n)return{start:t,end:n}}function y0(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?x0(e.position):`start`in e||`end`in e?x0(e):`line`in e||`column`in e?b0(e):``}function b0(e){return S0(e&&e.line)+`:`+S0(e&&e.column)}function x0(e){return b0(e&&e.start)+`-`+b0(e&&e.end)}function S0(e){return e&&typeof e==`number`?e:1}var C0=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=y0(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};C0.prototype.file=``,C0.prototype.name=``,C0.prototype.reason=``,C0.prototype.message=``,C0.prototype.stack=``,C0.prototype.column=void 0,C0.prototype.line=void 0,C0.prototype.ancestors=void 0,C0.prototype.cause=void 0,C0.prototype.fatal=void 0,C0.prototype.place=void 0,C0.prototype.ruleId=void 0,C0.prototype.source=void 0;var w0=t(m0(),1),T0={}.hasOwnProperty,E0=new Map,D0=/[A-Z]/g,O0=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),k0=new Set([`td`,`th`]),A0=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function j0(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=H0(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=V0(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?l0:c0,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=M0(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function M0(e,t,n){if(t.type===`element`)return N0(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return P0(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return I0(e,t,n);if(t.type===`mdxjsEsm`)return F0(e,t);if(t.type===`root`)return L0(e,t,n);if(t.type===`text`)return R0(e,t)}function N0(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=l0,e.schema=i),e.ancestors.push(t);let a=J0(e,t.tagName,!1),o=U0(e,t),s=G0(e,t);return O0.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!k1(e)})),z0(e,o,a,t),B0(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function P0(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Y0(e,t.position)}function F0(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Y0(e,t.position)}function I0(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=l0,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:J0(e,t.name,!0),o=W0(e,t),s=G0(e,t);return z0(e,o,a,t),B0(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function L0(e,t,n){let r={};return B0(r,G0(e,t)),e.create(t,e.Fragment,r,n)}function R0(e,t){return t.value}function z0(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function B0(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function V0(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function H0(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=g0(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function U0(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&T0.call(t.properties,i)){let a=K0(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&k0.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function W0(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Y0(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Y0(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function G0(e,t){let n=[],r=-1,i=e.passKeys?new Map:E0;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=M0(e,a,o);s!==void 0&&n.push(s)}return n}function K0(e,t,n){let r=a0(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?v1(n):u0(n)),r.property===`style`){let t=typeof n==`object`?n:q0(e,String(n));return e.stylePropertyNameCase===`css`&&(t=X0(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?t0[r.property]||r.property:r.attribute,n]}}function q0(e,t){try{return(0,w0.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new C0("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=A0+`#cannot-parse-style-attribute`,r}}function J0(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=D1(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=D1(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return T0.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Y0(e)}function Y0(e,t){let n=new C0("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=A0+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function X0(e){let t={},n;for(n in e)T0.call(e,n)&&(t[Z0(n)]=e[n]);return t}function Z0(e){let t=e.replace(D0,Q0);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Q0(e){return`-`+e.toLowerCase()}var $0={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},e2={};function t2(e,t){let n=t||e2;return n2(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function n2(e,t,n){if(i2(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return r2(e.children,t,n)}return Array.isArray(e)?r2(e,t,n):``}function r2(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=n2(e[i],t,n);return r.join(``)}function i2(e){return!!(e&&typeof e==`object`)}var a2=document.createElement(`i`);function o2(e){let t=`&`+e+`;`;a2.innerHTML=t;let n=a2.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function s2(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function c2(e,t){return e.length>0?(s2(e,e.length,0,t),e):t}var l2={}.hasOwnProperty;function u2(e){let t={},n=-1;for(;++n<e.length;)d2(t,e[n]);return t}function d2(e,t){let n;for(n in t){let r=(l2.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){l2.call(r,a)||(r[a]=[]);let e=i[a];f2(r[a],Array.isArray(e)?e:e?[e]:[])}}}function f2(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);s2(e,0,0,r)}function p2(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function m2(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var h2=E2(/[A-Za-z]/),g2=E2(/[\dA-Za-z]/),_2=E2(/[#-'*+\--9=?A-Z^-~]/);function v2(e){return e!==null&&(e<32||e===127)}var y2=E2(/\d/),b2=E2(/[\dA-Fa-f]/),x2=E2(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function S2(e){return e!==null&&(e<0||e===32)}function C2(e){return e===-2||e===-1||e===32}var w2=E2(/\p{P}|\p{S}/u),T2=E2(/\s/);function E2(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function D2(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&g2(e.charCodeAt(n+1))&&g2(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function O2(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return C2(r)?(e.enter(n),s(r)):t(r)}function s(r){return C2(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function k2(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&C2(t)?(e.enter(r),c(t)):l(t)}function c(t){return C2(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var A2={tokenize:j2};function j2(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),O2(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var M2=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){N2(this,e,t,n,!1)}addBefore(e,t,n){N2(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function N2(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var P2={tokenize:I2},F2={tokenize:L2};function I2(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new M2;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(F2,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(F2,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return $(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new M2;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function L2(e,t,n){return O2(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function R2(e){if(e===null||S2(e)||T2(e))return 1;if(w2(e))return 2}function z2(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var B2={name:`attention`,resolveAll:V2,tokenize:H2};function V2(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};U2(o,-a),U2(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=c2(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=c2(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=c2(r,z2(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=c2(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=c2(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),s2(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function H2(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=R2(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=R2(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function U2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var W2={name:`autolink`,tokenize:G2};function G2(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return h2(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||g2(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||g2(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||v2(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):_2(t)?(e.consume(t),l):n(t)}function u(e){return g2(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||g2(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var K2={partial:!0,tokenize:q2};function q2(e,t,n){return r;function r(t){return C2(t)?O2(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var J2={continuation:{tokenize:X2},exit:Z2,name:`blockQuote`,tokenize:Y2};function Y2(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return C2(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function X2(e,t,n){let r=this;return i;function i(t){return C2(t)?O2(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(J2,t,n)(r)}}function Z2(e){e.exit(`blockQuote`)}var Q2={name:`characterEscape`,tokenize:$2};function $2(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return x2(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var e4={name:`characterReference`,tokenize:t4};function t4(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=g2,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=b2,u):(e.enter(`characterReferenceValue`),a=7,o=y2,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===g2&&!o2(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var n4={partial:!0,tokenize:r4};function r4(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var i4={concrete:!0,name:`codeFenced`,tokenize:a4};function a4(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),C2(t)?O2(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(n4,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):C2(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),O2(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&C2(t)?O2(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(n4,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),C2(t)?O2(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),C2(t)?O2(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var o4={name:`codeIndented`,tokenize:c4},s4={partial:!0,tokenize:l4};function c4(e,t,n){return r;function r(t){return e.enter(`codeIndented`),k2(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):$(t)?e.attempt(s4,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||$(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function l4(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):$(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):k2(e,t,a,`linePrefix`,4,4)(o)}function a(e){return $(e)?i(e):n(e)}}var u4={name:`codeText`,previous:f4,resolve:d4,tokenize:p4};function d4(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function f4(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function p4(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var m4=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&h4(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),h4(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),h4(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);h4(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);h4(this.left,t.reverse())}}}};function h4(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function g4(e){let t={},n=-1,r,i,a,o,s,c,l,u=new m4(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,_4(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return s2(e,0,1/0,u.slice(0)),!l}function _4(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var v4={resolve:b4,tokenize:x4},y4={partial:!0,tokenize:S4};function b4(e){return g4(e),e}function x4(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$(t)?e.check(y4,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function S4(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),O2(e,a,`linePrefix`)}function a(i){if(i===null||$(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function C4(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||v2(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||S2(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||v2(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function w4(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!C2(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function T4(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),O2(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function E4(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):C2(i)?O2(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var D4={name:`definition`,tokenize:k4},O4={partial:!0,tokenize:A4};function k4(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return w4.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=m2(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return S2(t)?E4(e,l)(t):l(t)}function l(t){return C4(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(O4,d,d)(t)}function d(t){return C2(t)?O2(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function A4(e,t,n){return r;function r(t){return S2(t)?E4(e,i)(t):n(t)}function i(t){return T4(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return C2(t)?O2(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var j4={name:`hardBreakEscape`,tokenize:M4};function M4(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var N4={name:`headingAtx`,resolve:P4,tokenize:F4};function P4(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};s2(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function F4(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||S2(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):C2(n)?O2(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||S2(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var I4=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),L4=[`pre`,`script`,`style`,`textarea`],R4={concrete:!0,name:`htmlFlow`,resolveTo:B4,tokenize:V4},z4={partial:!0,tokenize:H4};function B4(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function V4(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ee):h2(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):h2(a)?(e.consume(a),i=4,r.interrupt?t:ee):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ee):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return h2(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||S2(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&L4.includes(l)?(i=1,r.interrupt?t(s):O(s)):I4.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||g2(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return C2(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||h2(t)?(e.consume(t),b):C2(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||g2(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):C2(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):C2(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||S2(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||C2(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):C2(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),I):t===63&&i===3?(e.consume(t),ee):t===93&&i===5?(e.consume(t),F):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(z4,te,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(n4,A,te)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),ee):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return L4.includes(n)?(e.consume(t),I):O(t)}return h2(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),ee):O(t)}function ee(t){return t===62?(e.consume(t),I):t===45&&i===2?(e.consume(t),ee):O(t)}function I(t){return t===null||$(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),I)}function te(n){return e.exit(`htmlFlow`),t(n)}}function H4(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(K2,t,n)}}var U4={name:`htmlText`,tokenize:W4};function W4(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):h2(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):h2(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return h2(t)?(e.consume(t),S):n(t)}function S(t){return t===45||g2(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):C2(t)?(e.consume(t),C):M(t)}function w(t){return t===45||g2(t)?(e.consume(t),w):t===47||t===62||S2(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||h2(t)?(e.consume(t),E):$(t)?(o=T,N(t)):C2(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||g2(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):C2(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$(t)?(o=O,N(t)):C2(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||S2(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||S2(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return C2(t)?O2(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var G4={name:`labelEnd`,resolveAll:Y4,resolveTo:X4,tokenize:Z4},K4={tokenize:Q4},q4={tokenize:$4},J4={tokenize:e3};function Y4(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&s2(e,0,e.length,n),e}function X4(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=c2(o,e.slice(i+1,i+r+3)),o=c2(o,[[`enter`,l,t]]),o=c2(o,z2(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=c2(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=c2(o,e.slice(a+1)),o=c2(o,[[`exit`,s,t]]),s2(e,i,e.length,o),e}function Z4(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(m2(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(K4,u,o?u:d)(t):t===91?e.attempt(q4,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(J4,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function Q4(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return S2(t)?E4(e,a)(t):a(t)}function a(t){return t===41?u(t):C4(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return S2(t)?E4(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?T4(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return S2(t)?E4(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function $4(e,t,n){let r=this;return i;function i(t){return w4.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(m2(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function e3(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var t3={name:`labelStartImage`,resolveAll:G4.resolveAll,tokenize:n3};function n3(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var r3={name:`labelStartLink`,resolveAll:G4.resolveAll,tokenize:i3};function i3(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var a3={name:`lineEnding`,tokenize:o3};function o3(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),O2(e,t,`linePrefix`)}}var s3={name:`thematicBreak`,tokenize:c3};function c3(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),C2(t)?O2(e,s,`whitespace`)(t):s(t))}}var l3={continuation:{tokenize:p3},exit:h3,name:`list`,tokenize:f3},u3={partial:!0,tokenize:g3},d3={partial:!0,tokenize:m3};function f3(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:y2(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(s3,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return y2(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(K2,r.interrupt?n:u,e.attempt(u3,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return C2(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function p3(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(K2,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,O2(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!C2(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(d3,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,O2(e,e.attempt(l3,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function m3(e,t,n){let r=this;return O2(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function h3(e){e.exit(this.containerState.type)}function g3(e,t,n){let r=this;return O2(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!C2(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var _3={name:`setextUnderline`,resolveTo:v3,tokenize:y3};function v3(e,t){let n=new M2,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function y3(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),C2(t)?O2(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var b3={tokenize:x3};function x3(e){let t=this,n=e.attempt(K2,r,e.attempt(this.parser.constructs.flowInitial,i,O2(e,e.attempt(this.parser.constructs.flow,i,e.attempt(v4,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var eie={resolveAll:T3()},S3=w3(`string`),C3=w3(`text`);function w3(e){return{resolveAll:T3(e===`text`?E3:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function T3(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function E3(e,t){let n=new M2,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var D3=e({attentionMarkers:()=>F3,contentInitial:()=>k3,disable:()=>I3,document:()=>O3,flow:()=>j3,flowInitial:()=>A3,insideSpan:()=>P3,string:()=>M3,text:()=>N3}),O3={42:l3,43:l3,45:l3,48:l3,49:l3,50:l3,51:l3,52:l3,53:l3,54:l3,55:l3,56:l3,57:l3,62:J2},k3={91:D4},A3={[-2]:o4,[-1]:o4,32:o4},j3={35:N4,42:s3,45:[_3,s3],60:R4,61:_3,95:s3,96:i4,126:i4},M3={38:e4,92:Q2},N3={[-5]:a3,[-4]:a3,[-3]:a3,33:t3,38:e4,42:B2,60:[W2,U4],91:r3,92:[j4,Q2],93:G4,95:B2,96:u4},P3={null:[B2,eie]},F3={null:[42,95]},I3={null:[]};function L3(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=c2(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=z2(a,l.events,l),l.events):[]}function f(e,t){return z3(p(e),t)}function p(e){return R3(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){$(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&s2(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function R3(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function z3(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
95
|
+
) WHERE n <= ? ORDER BY grade, tbl, k`,params:[t,n]}}function h$(e){return{table:String(e.tbl),key:String(e.k),label:e.lbl===null||e.lbl===void 0?null:String(e.lbl),column:String(e.col),value:String(e.val??``),rank:Number(e.grade),total:Number(e.total)}}var g$=30,_$=e=>[...n$(e.trim())].length>=2,v$=e=>e.replace(/^[ \t]*(?:#{1,6}|[-*+]|>)[ \t]+/gm,``).replace(/\s+/g,` `);function y$(e,t){let n=n$(t.toLowerCase());if(n===``)return null;let r=``,i=[];for(let t=0;t<e.length;t++){if(t$(e[t]))continue;let n=e[t].toLowerCase();r+=n;for(let e=0;e<n.length;e++)i.push(t)}let a=r.indexOf(n);return a<0?null:[i[a],i[a+n.length-1]+1]}function b$(e,t,n=g$){let r=y$(e,t);if(!r){let t=e.slice(0,n*2);return{before:``,match:``,after:v$(t)+(e.length>t.length?`…`:``)}}let[i,a]=r,o=Math.max(0,i-n),s=Math.min(e.length,a+n);return{before:(o>0?`…`:``)+v$(e.slice(o,i)),match:v$(e.slice(i,a)),after:v$(e.slice(a,s))+(s<e.length?`…`:``)}}var x$=200;function S$(e,t){let n=new Map(e.map(e=>[e,TQ(e.value.slice(0,x$),t)]));return[...e].sort((e,t)=>e.rank-t.rank||(n.get(t)??0)-(n.get(e)??0)||e.table.localeCompare(t.table)||e.key.localeCompare(t.key))}function C$(e,t){let n=new Map;for(let r of S$(e,t)){let e=n.get(r.table)??{table:r.table,total:r.total,hits:[]};e.hits.push(r),n.set(r.table,e)}return[...n.values()]}function w$(e,t){let n=e.trim();return V_({queryKey:[`search`,n,t],queryFn:()=>Uv.search(n,t),enabled:_$(n),placeholderData:Hg})}var T$=`rounded-[3px] bg-tomato-soft text-inherit`;function E$({value:e,needle:t,around:n}){let r=b$(e,t,n);return(0,z.jsxs)(`span`,{children:[r.before,r.match&&(0,z.jsx)(`mark`,{className:T$,children:r.match}),r.after]})}function D$({text:e,needle:t}){return(0,z.jsx)(E$,{value:e,needle:t,around:1/0})}function O$(e,t){let[n,r]=(0,B.useState)(e);return(0,B.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var k$=$h()({beforeLoad:({context:e,matches:t})=>{if(e.app===void 0)return;let n=t.at(-1);if(n?.routeId!==`/app/$page`||n.params.page!==e.app)throw Hf({to:`/app/$page`,params:{page:e.app},replace:!0})}}),A$=Qh({getParentRoute:()=>k$,path:`/t/$table`,validateSearch:e=>({key:typeof e.key==`string`?e.key:void 0,sort:typeof e.sort==`string`?e.sort:void 0,q:typeof e.q==`string`?e.q:void 0,filter:Array.isArray(e.filter)?e.filter:void 0})}),j$=Qh({getParentRoute:()=>k$,path:`/sql`}),M$=Qh({getParentRoute:()=>k$,path:`/sync`}),N$=Qh({getParentRoute:()=>k$,path:`/erd`}),P$=Qh({getParentRoute:()=>k$,path:`/p/$page`}),F$=Qh({getParentRoute:()=>k$,path:`/app/$page`,beforeLoad:({context:e,params:t})=>{if(e.app===void 0)throw Hf({to:`/p/$page`,params:{page:t.page},replace:!0})}}),I$=Qh({getParentRoute:()=>k$,path:`/search`,validateSearch:e=>({q:typeof e.q==`string`?e.q:void 0})}),L$=20;function R$(){let{q:e}=I$.useSearch(),t=Nh(),[n,r]=(0,B.useState)(e??``);(0,B.useEffect)(()=>r(t=>t.trim()===(e??``)?t:e??``),[e]);let i=O$(n.trim(),200);(0,B.useEffect)(()=>{i!==(e??``)&&t({to:`/search`,search:{q:i||void 0},replace:!0})},[i,e,t]);let a=(e??``).trim(),o=_$(a),{data:s,isPending:c,error:l}=w$(a,L$),u=o&&s?C$(s.hits,a):[],d;if(!o)d=(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:yl()});else if(l)d=(0,z.jsx)(`p`,{role:`alert`,className:`text-destructive`,children:l.message});else if(c)d=(0,z.jsx)(`div`,{"aria-busy":`true`,className:`h-24 animate-pulse rounded-md bg-panel-2`});else if(u.length===0)d=(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:vl()});else{let e=u.reduce((e,t)=>e+t.total,0);d=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`text-[15px] text-muted-foreground`,children:`${Sl({count:e})} · ${kl({count:u.length})}`}),u.map(e=>(0,z.jsxs)(`section`,{"aria-label":e.table,className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2.5 px-1`,children:[(0,z.jsx)(xk,{className:`size-[18px] text-muted-foreground`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-[19px] font-semibold`,children:e.table}),(0,z.jsx)(`span`,{className:`rounded-full border px-2.5 text-[13px] text-muted-foreground`,children:Sl({count:e.total})}),e.total>e.hits.length&&(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.table},search:{q:a},className:`ml-auto text-[15px] font-medium text-tomato hover:underline`,children:El({count:e.total})})]}),(0,z.jsx)(`ul`,{className:`divide-y overflow-hidden rounded-xl border`,children:e.hits.map(t=>(0,z.jsx)(`li`,{children:(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.table},search:{key:t.key},className:`group grid grid-cols-[1fr_auto] items-center gap-x-4 gap-y-0.5 px-4 py-3 outline-none hover:bg-panel focus-visible:bg-panel`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2.5`,children:[(0,z.jsx)(`span`,{className:`truncate text-[17px] font-semibold`,children:(0,z.jsx)(D$,{text:t.label??t.key,needle:a})}),t.label!==null&&(0,z.jsx)(`span`,{className:`shrink-0 font-mono text-[13px] text-muted-foreground`,children:(0,z.jsx)(D$,{text:t.key,needle:a})})]}),(0,z.jsx)(hO,{className:`row-span-2 size-[18px] text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t.value!==t.key&&t.value!==t.label&&(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`shrink-0 rounded-md bg-chip px-1.5 font-mono text-xs text-chip-foreground`,children:t.column}),(0,z.jsx)(`span`,{className:`truncate text-[15px] text-muted-foreground`,children:(0,z.jsx)(E$,{value:t.value,needle:a})})]})]})},t.key))})]},e.table))]})}return(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col gap-5 overflow-auto px-4 py-6 md:px-8`,children:[(0,z.jsx)(`h1`,{className:`sr-only`,children:Al()}),(0,z.jsxs)(`label`,{className:`flex items-center gap-3 rounded-xl border bg-panel px-4 focus-within:ring-2 focus-within:ring-ring`,children:[(0,z.jsx)(dk,{className:`size-[22px] shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,z.jsx)(`input`,{type:`search`,"aria-label":Al(),placeholder:Cl(),value:n,onChange:e=>r(e.target.value),autoFocus:!0,className:`h-14 w-full bg-transparent text-[19px] outline-none placeholder:text-muted-foreground`})]}),d]})}var z$=e=>{let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()},B$=()=>document.documentElement.dataset.theme,V$=({...e})=>{let t=(0,B.useSyncExternalStore)(z$,B$);return(0,z.jsx)(yv,{theme:t,className:`toaster group`,icons:{success:(0,z.jsx)(_O,{className:`size-4`}),info:(0,z.jsx)(kO,{className:`size-4`}),warning:(0,z.jsx)(kk,{className:`size-4`}),error:(0,z.jsx)(YO,{className:`size-4`}),loading:(0,z.jsx)(zO,{className:`size-4 animate-spin`})},style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`,pointerEvents:`auto`},...e})},H$=`yamlite-ai`,U$={};function W$(){try{return JSON.parse(localStorage.getItem(H$)??`{}`)}catch{return{}}}function G$(e){try{localStorage.setItem(H$,JSON.stringify(e))}catch{}}function K$(){let e=ry();return Yv()?null:e.data?.ai?.providers??null}function q$(){let e=ry(),t=Yv()?null:e.data?.ai;return t?{viewerKeys:t.viewerKeys,settingsUrl:t.settingsUrl,unavailable:t.unavailable??!1}:null}function J$(e){return U$[e]??W$().keys?.[e]??``}function Y$(e){return!!W$().keys?.[e]}function X$(e,{viewerKeys:t}={viewerKeys:!0}){let n=W$(),r=e.find(e=>e.id===n.provider)??e.find(e=>e.hasKey)??e[0];if(!r)return null;let i=r.id===n.provider&&n.model?n.model:void 0,a=i&&(!r.fixedModels||r.models.includes(i))?i:r.models[0],o=t?J$(r.id):``;return o||r.hasKey?{provider:r.id,model:a,apiKey:o}:null}function Z$(e,t){let n={...W$().keys};delete n[e.provider],delete U$[e.provider],e.apiKey&&(t?n[e.provider]=e.apiKey:U$[e.provider]=e.apiKey),G$({provider:e.provider,model:e.model,keys:n})}var Q$={get:()=>Ov(`GET`,`/api/ai/instructions`),save:e=>Ov(`PUT`,`/api/ai/instructions`,e)},$$={items:[],busy:!1,closed:!1};function e1(e,t){let n=e.items;switch(t.type){case`user`:return{...e,items:[...n,{kind:`user`,text:t.text}]};case`text`:{let r=n.at(-1);return r?.kind===`agent`?{...e,items:[...n.slice(0,-1),{...r,text:r.text+t.text}]}:{...e,items:[...n,{kind:`agent`,text:t.text}]}}case`source`:{let r=n.at(-1),i={url:t.url,...t.title?{title:t.title}:{}};return r?.kind!==`agent`&&r?.kind!==`tool`?{...e,items:[...n,{kind:`agent`,text:``,sources:[i]}]}:r.sources?.some(e=>e.url===t.url)?e:{...e,items:[...n.slice(0,-1),{...r,sources:[...r.sources??[],i]}]}}case`tool`:{let r=n.findIndex(e=>e.kind===`tool`&&e.id===t.id);if(r<0){let r={kind:`tool`,id:t.id,title:t.title??t.id,status:t.status??null,...t.input===void 0?{}:{input:t.input}};return{...e,items:[...n,r]}}let i={...n[r],...t.title?{title:t.title}:{},...t.status===void 0?{}:{status:t.status??null},...t.input===void 0?{}:{input:t.input}};return{...e,items:n.map((e,t)=>t===r?i:e)}}case`proposal`:{let r=n.findIndex(e=>e.kind===`proposal`&&e.proposal.id===t.proposal.id),i={kind:`proposal`,proposal:t.proposal};return{...e,items:r<0?[...n,i]:n.map((e,t)=>t===r?i:e)}}case`busy`:return{...e,busy:t.busy};case`error`:return{...e,items:[...n,{kind:`error`,message:t.code===`auth`?ce():t.message,...t.code?{code:t.code}:{}}]};case`closed`:return{...e,busy:!1,closed:!0}}}var t1=encodeURIComponent,n1=e=>`/api/agent/conversations/${t1(e)}`,r1={conversations:()=>Ov(`GET`,`/api/agent/conversations`),start:e=>Ov(`POST`,`/api/agent/conversations`,{provider:e.provider,model:e.model,...e.apiKey?{apiKey:e.apiKey}:{}}),prompt:(e,t)=>Ov(`POST`,`${n1(e)}/prompt`,{text:t}),cancel:e=>Ov(`POST`,`${n1(e)}/cancel`),proposals:()=>Ov(`GET`,`/api/agent/proposals`),apply:e=>Ov(`POST`,`/api/agent/proposals/${t1(e)}/apply`),discard:e=>Ov(`POST`,`/api/agent/proposals/${t1(e)}/discard`)};function i1(e,t){let n=new Map;for(let r of e)if(r.status===`pending`)for(let e of r.rows)e.table===t&&n.set(e.key,{op:e.op,before:e.before,after:e.after,changed:e.changed});return n}var a1=2,o1=[`agent-proposals`],s1=[`agent-conversations`],c1=new class{make;state=$$;id=null;source=null;listeners=new Set;constructor(e=e=>xv().eventSource(e)){this.make=e}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async start(e){let{id:t}=await r1.start(e);this.open(t)}open(e){ny.invalidateQueries({queryKey:s1}),this.source?.close(),this.id=e,this.set($$);let t=this.make(`${n1(e)}/events`);this.source=t;let n=!1;t.addEventListener(`open`,()=>{this.source===t&&(n&&this.set($$),n=!0)}),t.addEventListener(`agent`,e=>{if(this.source!==t||!(e instanceof MessageEvent)||typeof e.data!=`string`)return;let n;try{n=JSON.parse(e.data)}catch{return}n.type===`proposal`&&ny.invalidateQueries({queryKey:o1}),this.set(e1(this.state,n)),n.type===`closed`&&this.disconnect(t)}),t.addEventListener(`error`,()=>{if(this.source===t&&t.readyState===a1&&(this.disconnect(t),!this.state.closed)){let e=e1(this.state,{type:`error`,message:de()});this.set(e1(e,{type:`closed`}))}})}async send(e){this.id&&await r1.prompt(this.id,e)}async stop(){this.id&&await r1.cancel(this.id)}async reset(){ny.invalidateQueries({queryKey:s1}),this.source?.close(),this.source=null,this.id=null,this.set($$)}disconnect(e){e.close(),this.source===e&&(this.source=null)}set(e){this.state=e;for(let e of this.listeners)e()}},l1=()=>(0,B.useSyncExternalStore)(e=>c1.subscribe(e),()=>c1.state);function u1(){let e=K$()!==null;return V_({queryKey:o1,queryFn:r1.proposals,enabled:e}).data?.proposals??[]}function d1(e){let t=V_({queryKey:s1,queryFn:r1.conversations,enabled:e,staleTime:0});return{conversations:t.data?.conversations??[],loading:t.isPending}}var f1=()=>ny.invalidateQueries({queryKey:o1}),p1=!1,m1=new Set,h1=e=>{p1=e;for(let e of m1)e()},g1={open:()=>h1(!0),close:()=>h1(!1),toggle:()=>h1(!p1)},_1=()=>(0,B.useSyncExternalStore)(e=>(m1.add(e),()=>m1.delete(e)),()=>p1);function v1(){}function y1(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var b1=/[$_\p{ID_Start}]/u,x1=/[$_\u{200C}\u{200D}\p{ID_Continue}]/u,S1=/[-$_\u{200C}\u{200D}\p{ID_Continue}]/u,C1=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w1=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,T1={};function E1(e){return e?b1.test(String.fromCodePoint(e)):!1}function D1(e,t){let n=(t||T1).jsx?S1:x1;return e?n.test(String.fromCodePoint(e)):!1}function O1(e,t){return((t||T1).jsx?w1:C1).test(e)}var k1=/[ \t\n\f\r]/g;function A1(e){return typeof e==`object`?e.type===`text`&&j1(e.value):j1(e)}function j1(e){return e.replace(k1,``)===``}var M1=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};M1.prototype.normal={},M1.prototype.property={},M1.prototype.space=void 0;function N1(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new M1(n,r,t)}function P1(e){return e.toLowerCase()}var F1=class{constructor(e,t){this.attribute=t,this.property=e}};F1.prototype.attribute=``,F1.prototype.booleanish=!1,F1.prototype.boolean=!1,F1.prototype.commaOrSpaceSeparated=!1,F1.prototype.commaSeparated=!1,F1.prototype.defined=!1,F1.prototype.mustUseProperty=!1,F1.prototype.number=!1,F1.prototype.overloadedBoolean=!1,F1.prototype.property=``,F1.prototype.spaceSeparated=!1,F1.prototype.space=void 0;var I1=e({boolean:()=>Z,booleanish:()=>R1,commaOrSpaceSeparated:()=>H1,commaSeparated:()=>V1,number:()=>Q,overloadedBoolean:()=>z1,spaceSeparated:()=>B1}),L1=0,Z=U1(),R1=U1(),z1=U1(),Q=U1(),B1=U1(),V1=U1(),H1=U1();function U1(){return 2**++L1}var W1=Object.keys(I1),G1=class extends F1{constructor(e,t,n,r){let i=-1;if(super(e,t),K1(this,`space`,r),typeof n==`number`)for(;++i<W1.length;){let e=W1[i];K1(this,W1[i],(n&I1[e])===I1[e])}}};G1.prototype.defined=!0;function K1(e,t,n){n&&(e[t]=n)}function q1(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new G1(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[P1(r)]=r,n[P1(a.attribute)]=r}return new M1(t,n,e.space)}var J1=q1({properties:{ariaActiveDescendant:null,ariaAtomic:R1,ariaAutoComplete:null,ariaBusy:R1,ariaChecked:R1,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:B1,ariaCurrent:null,ariaDescribedBy:B1,ariaDetails:null,ariaDisabled:R1,ariaDropEffect:B1,ariaErrorMessage:null,ariaExpanded:R1,ariaFlowTo:B1,ariaGrabbed:R1,ariaHasPopup:null,ariaHidden:R1,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:B1,ariaLevel:Q,ariaLive:null,ariaModal:R1,ariaMultiLine:R1,ariaMultiSelectable:R1,ariaOrientation:null,ariaOwns:B1,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:R1,ariaReadOnly:R1,ariaRelevant:null,ariaRequired:R1,ariaRoleDescription:B1,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:R1,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Y1(e,t){return t in e?e[t]:t}function X1(e,t){return Y1(e,t.toLowerCase())}var Z1=q1({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:V1,acceptCharset:B1,accessKey:B1,action:null,allow:null,allowFullScreen:Z,allowPaymentRequest:Z,allowUserMedia:Z,alpha:Z,alt:null,as:null,async:Z,autoCapitalize:null,autoComplete:B1,autoFocus:Z,autoPlay:Z,blocking:B1,capture:null,charSet:null,checked:Z,cite:null,className:B1,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:R1,controls:Z,controlsList:B1,coords:Q|V1,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Z,defer:Z,dir:null,dirName:null,disabled:Z,download:z1,draggable:R1,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Z,formTarget:null,headers:B1,height:Q,hidden:z1,high:Q,href:null,hrefLang:null,htmlFor:B1,httpEquiv:B1,id:null,imageSizes:null,imageSrcSet:null,inert:Z,inputMode:null,integrity:null,is:null,isMap:Z,itemId:null,itemProp:B1,itemRef:B1,itemScope:Z,itemType:B1,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Z,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Z,muted:Z,name:null,nonce:null,noModule:Z,noValidate:Z,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Z,optimum:Q,pattern:null,ping:B1,placeholder:null,playsInline:Z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Z,referrerPolicy:null,rel:B1,required:Z,reversed:Z,rows:Q,rowSpan:Q,sandbox:B1,scope:null,scoped:Z,seamless:Z,selected:Z,shadowRootClonable:Z,shadowRootCustomElementRegistry:Z,shadowRootDelegatesFocus:Z,shadowRootMode:null,shadowRootSerializable:Z,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:R1,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Z,useMap:null,value:R1,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:B1,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Z,declare:Z,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Z,noHref:Z,noShade:Z,noWrap:Z,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:R1,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Z,disablePictureInPicture:Z,disableRemotePlayback:Z,exportParts:V1,part:B1,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:X1}),Q1=q1({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:H1,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:B1,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Z,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:V1,g2:V1,glyphName:V1,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:H1,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:B1,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:H1,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:H1,rev:H1,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:H1,requiredFeatures:H1,requiredFonts:H1,requiredFormats:H1,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:H1,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:H1,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:H1,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Y1}),$1=q1({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),e0=q1({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:X1}),t0=q1({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),n0={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},r0=/[A-Z]/g,i0=/-[a-z]/g,a0=/^data[-\w.:]+$/i;function o0(e,t){let n=P1(t),r=t,i=F1;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&a0.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(i0,c0);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!i0.test(e)){let n=e.replace(r0,s0);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=G1}return new i(r,t)}function s0(e){return`-`+e.toLowerCase()}function c0(e){return e.charAt(1).toUpperCase()}var l0=N1([J1,Z1,$1,e0,t0],`html`),u0=N1([J1,Q1,$1,e0,t0],`svg`);function d0(e){return e.join(` `).trim()}var f0=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
96
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),p0=n(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=a;var i=r(f0());function a(e,t){let n=null;if(!e||typeof e!=`string`)return n;let r=(0,i.default)(e),a=typeof t==`function`;return r.forEach(e=>{if(e.type!==`declaration`)return;let{property:r,value:i}=e;a?t(r,i,e):i&&(n||={},n[r]=i)}),n}})),m0=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),h0=n(((e,t,n)=>{var r=(n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(p0()),i=m0();function a(e,t){var n={};return!e||typeof e!=`string`||(0,r.default)(e,function(e,r){e&&r&&(n[(0,i.camelCase)(e,t)]=r)}),n}a.default=a,t.exports=a})),g0=v0(`end`),_0=v0(`start`);function v0(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function y0(e){let t=_0(e),n=g0(e);if(t&&n)return{start:t,end:n}}function b0(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?S0(e.position):`start`in e||`end`in e?S0(e):`line`in e||`column`in e?x0(e):``}function x0(e){return C0(e&&e.line)+`:`+C0(e&&e.column)}function S0(e){return x0(e&&e.start)+`-`+x0(e&&e.end)}function C0(e){return e&&typeof e==`number`?e:1}var w0=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=b0(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};w0.prototype.file=``,w0.prototype.name=``,w0.prototype.reason=``,w0.prototype.message=``,w0.prototype.stack=``,w0.prototype.column=void 0,w0.prototype.line=void 0,w0.prototype.ancestors=void 0,w0.prototype.cause=void 0,w0.prototype.fatal=void 0,w0.prototype.place=void 0,w0.prototype.ruleId=void 0,w0.prototype.source=void 0;var T0=t(h0(),1),E0={}.hasOwnProperty,D0=new Map,O0=/[A-Z]/g,k0=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),A0=new Set([`td`,`th`]),j0=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function M0(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=U0(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=H0(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?u0:l0,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=N0(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function N0(e,t,n){if(t.type===`element`)return P0(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return F0(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return L0(e,t,n);if(t.type===`mdxjsEsm`)return I0(e,t);if(t.type===`root`)return R0(e,t,n);if(t.type===`text`)return z0(e,t)}function P0(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=u0,e.schema=i),e.ancestors.push(t);let a=Y0(e,t.tagName,!1),o=W0(e,t),s=K0(e,t);return k0.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!A1(e)})),B0(e,o,a,t),V0(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function F0(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}X0(e,t.position)}function I0(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);X0(e,t.position)}function L0(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=u0,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Y0(e,t.name,!0),o=G0(e,t),s=K0(e,t);return B0(e,o,a,t),V0(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function R0(e,t,n){let r={};return V0(r,K0(e,t)),e.create(t,e.Fragment,r,n)}function z0(e,t){return t.value}function B0(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function V0(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function H0(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function U0(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=_0(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function W0(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&E0.call(t.properties,i)){let a=q0(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&A0.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function G0(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else X0(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else X0(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function K0(e,t){let n=[],r=-1,i=e.passKeys?new Map:D0;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=N0(e,a,o);s!==void 0&&n.push(s)}return n}function q0(e,t,n){let r=o0(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?y1(n):d0(n)),r.property===`style`){let t=typeof n==`object`?n:J0(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Z0(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?n0[r.property]||r.property:r.attribute,n]}}function J0(e,t){try{return(0,T0.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new w0("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=j0+`#cannot-parse-style-attribute`,r}}function Y0(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=O1(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=O1(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return E0.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);X0(e)}function X0(e,t){let n=new w0("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=j0+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Z0(e){let t={},n;for(n in e)E0.call(e,n)&&(t[Q0(n)]=e[n]);return t}function Q0(e){let t=e.replace(O0,$0);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function $0(e){return`-`+e.toLowerCase()}var e2={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},t2={};function n2(e,t){let n=t||t2;return r2(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function r2(e,t,n){if(a2(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return i2(e.children,t,n)}return Array.isArray(e)?i2(e,t,n):``}function i2(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=r2(e[i],t,n);return r.join(``)}function a2(e){return!!(e&&typeof e==`object`)}var o2=document.createElement(`i`);function s2(e){let t=`&`+e+`;`;o2.innerHTML=t;let n=o2.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function c2(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function l2(e,t){return e.length>0?(c2(e,e.length,0,t),e):t}var u2={}.hasOwnProperty;function d2(e){let t={},n=-1;for(;++n<e.length;)f2(t,e[n]);return t}function f2(e,t){let n;for(n in t){let r=(u2.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){u2.call(r,a)||(r[a]=[]);let e=i[a];p2(r[a],Array.isArray(e)?e:e?[e]:[])}}}function p2(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);c2(e,0,0,r)}function m2(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function h2(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var g2=D2(/[A-Za-z]/),_2=D2(/[\dA-Za-z]/),v2=D2(/[#-'*+\--9=?A-Z^-~]/);function y2(e){return e!==null&&(e<32||e===127)}var b2=D2(/\d/),x2=D2(/[\dA-Fa-f]/),S2=D2(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function C2(e){return e!==null&&(e<0||e===32)}function w2(e){return e===-2||e===-1||e===32}var T2=D2(/\p{P}|\p{S}/u),E2=D2(/\s/);function D2(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function O2(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&_2(e.charCodeAt(n+1))&&_2(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function k2(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return w2(r)?(e.enter(n),s(r)):t(r)}function s(r){return w2(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function A2(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&w2(t)?(e.enter(r),c(t)):l(t)}function c(t){return w2(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var j2={tokenize:M2};function M2(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null)e.consume(n);else return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),k2(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null)e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);else return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var N2=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){P2(this,e,t,n,!1)}addBefore(e,t,n){P2(this,e,t,n,!0)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function P2(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var F2={tokenize:L2},I2={tokenize:R2};function L2(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new N2;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(I2,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(I2,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null)i&&v(),_(0),e.consume(n);else return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null)g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);else return $(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new N2;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function R2(e,t,n){return k2(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function z2(e){if(e===null||C2(e)||E2(e))return 1;if(T2(e))return 2}function B2(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var V2={name:`attention`,resolveAll:H2,tokenize:U2};function H2(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};W2(o,-a),W2(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=l2(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=l2(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=l2(r,B2(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=l2(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=l2(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),c2(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function U2(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=z2(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=z2(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function W2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var G2={name:`autolink`,tokenize:K2};function K2(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return g2(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||_2(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||_2(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||y2(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):v2(t)?(e.consume(t),l):n(t)}function u(e){return _2(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||_2(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var q2={partial:!0,tokenize:J2};function J2(e,t,n){return r;function r(t){return w2(t)?k2(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var Y2={continuation:{tokenize:Z2},exit:Q2,name:`blockQuote`,tokenize:X2};function X2(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return w2(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Z2(e,t,n){let r=this;return i;function i(t){return w2(t)?k2(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Y2,t,n)(r)}}function Q2(e){e.exit(`blockQuote`)}var $2={name:`characterEscape`,tokenize:e4};function e4(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return S2(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var t4={name:`characterReference`,tokenize:n4};function n4(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=_2,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=x2,u):(e.enter(`characterReferenceValue`),a=7,o=b2,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===_2&&!s2(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var r4={partial:!0,tokenize:i4};function i4(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var a4={concrete:!0,name:`codeFenced`,tokenize:o4};function o4(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),w2(t)?k2(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(r4,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):w2(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),k2(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&w2(t)?k2(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(r4,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),w2(t)?k2(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),w2(t)?k2(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var s4={name:`codeIndented`,tokenize:l4},c4={partial:!0,tokenize:u4};function l4(e,t,n){return r;function r(t){return e.enter(`codeIndented`),A2(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):$(t)?e.attempt(c4,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||$(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function u4(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):$(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):A2(e,t,a,`linePrefix`,4,4)(o)}function a(e){return $(e)?i(e):n(e)}}var d4={name:`codeText`,previous:p4,resolve:f4,tokenize:m4};function f4(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function p4(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function m4(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var h4=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&g4(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),g4(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),g4(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);g4(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);g4(this.left,t.reverse())}}}};function g4(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function _4(e){let t={},n=-1,r,i,a,o,s,c,l,u=new h4(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,v4(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return c2(e,0,1/0,u.slice(0)),!l}function v4(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var y4={resolve:x4,tokenize:S4},b4={partial:!0,tokenize:C4};function x4(e){return _4(e),e}function S4(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$(t)?e.check(b4,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function C4(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),k2(e,a,`linePrefix`)}function a(i){if(i===null||$(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function w4(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||y2(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||C2(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||y2(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function T4(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!w2(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function E4(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),k2(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function D4(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):w2(i)?k2(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var O4={name:`definition`,tokenize:A4},k4={partial:!0,tokenize:j4};function A4(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return T4.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=h2(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return C2(t)?D4(e,l)(t):l(t)}function l(t){return w4(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(k4,d,d)(t)}function d(t){return w2(t)?k2(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function j4(e,t,n){return r;function r(t){return C2(t)?D4(e,i)(t):n(t)}function i(t){return E4(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return w2(t)?k2(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var M4={name:`hardBreakEscape`,tokenize:N4};function N4(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var P4={name:`headingAtx`,resolve:F4,tokenize:I4};function F4(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};c2(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function I4(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||C2(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):w2(n)?k2(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||C2(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var L4=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),R4=[`pre`,`script`,`style`,`textarea`],z4={concrete:!0,name:`htmlFlow`,resolveTo:V4,tokenize:H4},B4={partial:!0,tokenize:U4};function V4(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function H4(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:ee):g2(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):g2(a)?(e.consume(a),i=4,r.interrupt?t:ee):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:ee):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return g2(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||C2(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&R4.includes(l)?(i=1,r.interrupt?t(s):O(s)):L4.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||_2(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return w2(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||g2(t)?(e.consume(t),b):w2(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||_2(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):w2(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):w2(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||C2(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||w2(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):w2(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),I):t===63&&i===3?(e.consume(t),ee):t===93&&i===5?(e.consume(t),F):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(B4,te,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(r4,A,te)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),ee):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return R4.includes(n)?(e.consume(t),I):O(t)}return g2(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),ee):O(t)}function ee(t){return t===62?(e.consume(t),I):t===45&&i===2?(e.consume(t),ee):O(t)}function I(t){return t===null||$(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),I)}function te(n){return e.exit(`htmlFlow`),t(n)}}function U4(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(q2,t,n)}}var W4={name:`htmlText`,tokenize:G4};function G4(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):g2(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):g2(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return g2(t)?(e.consume(t),S):n(t)}function S(t){return t===45||_2(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):w2(t)?(e.consume(t),C):M(t)}function w(t){return t===45||_2(t)?(e.consume(t),w):t===47||t===62||C2(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||g2(t)?(e.consume(t),E):$(t)?(o=T,N(t)):w2(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||_2(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):w2(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$(t)?(o=O,N(t)):w2(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||C2(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||C2(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return w2(t)?k2(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var K4={name:`labelEnd`,resolveAll:X4,resolveTo:Z4,tokenize:Q4},q4={tokenize:$4},J4={tokenize:e3},Y4={tokenize:t3};function X4(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&c2(e,0,e.length,n),e}function Z4(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=l2(o,e.slice(i+1,i+r+3)),o=l2(o,[[`enter`,l,t]]),o=l2(o,B2(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=l2(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=l2(o,e.slice(a+1)),o=l2(o,[[`exit`,s,t]]),c2(e,i,e.length,o),e}function Q4(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(h2(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(q4,u,o?u:d)(t):t===91?e.attempt(J4,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Y4,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function $4(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return C2(t)?D4(e,a)(t):a(t)}function a(t){return t===41?u(t):w4(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return C2(t)?D4(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?E4(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return C2(t)?D4(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function e3(e,t,n){let r=this;return i;function i(t){return T4.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(h2(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function t3(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var n3={name:`labelStartImage`,resolveAll:K4.resolveAll,tokenize:r3};function r3(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var i3={name:`labelStartLink`,resolveAll:K4.resolveAll,tokenize:a3};function a3(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var o3={name:`lineEnding`,tokenize:s3};function s3(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),k2(e,t,`linePrefix`)}}var c3={name:`thematicBreak`,tokenize:l3};function l3(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),w2(t)?k2(e,s,`whitespace`)(t):s(t))}}var u3={continuation:{tokenize:m3},exit:g3,name:`list`,tokenize:p3},d3={partial:!0,tokenize:_3},f3={partial:!0,tokenize:h3};function p3(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:b2(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(c3,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return b2(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(q2,r.interrupt?n:u,e.attempt(d3,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return w2(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function m3(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(q2,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,k2(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!w2(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(f3,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,k2(e,e.attempt(u3,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function h3(e,t,n){let r=this;return k2(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function g3(e){e.exit(this.containerState.type)}function _3(e,t,n){let r=this;return k2(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!w2(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var v3={name:`setextUnderline`,resolveTo:y3,tokenize:b3};function y3(e,t){let n=new N2,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function b3(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),w2(t)?k2(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var tie={tokenize:x3};function x3(e){let t=this,n=e.attempt(q2,r,e.attempt(this.parser.constructs.flowInitial,i,k2(e,e.attempt(this.parser.constructs.flow,i,e.attempt(y4,i)),`linePrefix`)));return n;function r(r){if(r===null)e.consume(r);else return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null)e.consume(r);else return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var S3={resolveAll:E3()},C3=T3(`string`),w3=T3(`text`);function T3(e){return{resolveAll:E3(e===`text`?D3:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null)t.consume(e);else return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function E3(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function D3(e,t){let n=new N2,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var O3=e({attentionMarkers:()=>I3,contentInitial:()=>A3,disable:()=>L3,document:()=>k3,flow:()=>M3,flowInitial:()=>j3,insideSpan:()=>F3,string:()=>N3,text:()=>P3}),k3={42:u3,43:u3,45:u3,48:u3,49:u3,50:u3,51:u3,52:u3,53:u3,54:u3,55:u3,56:u3,57:u3,62:Y2},A3={91:O4},j3={[-2]:s4,[-1]:s4,32:s4},M3={35:P4,42:c3,45:[v3,c3],60:z4,61:v3,95:c3,96:a4,126:a4},N3={38:t4,92:$2},P3={[-5]:o3,[-4]:o3,[-3]:o3,33:n3,38:t4,42:V2,60:[G2,W4],91:i3,92:[M4,$2],93:K4,95:V2,96:d4},F3={null:[V2,S3]},I3={null:[42,95]},L3={null:[]};function R3(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=l2(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=B2(a,l.events,l),l.events):[]}function f(e,t){return B3(p(e),t)}function p(e){return z3(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){$(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&c2(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function z3(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function B3(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
97
97
|
`;break;case-3:o=`\r
|
|
98
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function B3(e){let t={constructs:u2([D3,...(e||{}).extensions||[]]),content:n(A2),defined:[],document:n(P2),flow:n(b3),lazy:{},string:n(S3),text:n(C3)};return t;function n(e){return n;function n(n){return L3(t,e,n)}}}function V3(e){for(;!g4(e););return e}var H3=/[\0\t\n\r]/g;function U3(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){H3.lastIndex=c;let n=H3.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var W3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function G3(e){return e.replace(W3,K3)}function K3(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return p2(n.slice(t?2:1),t?16:10)}return o2(n)||e}var q3={}.hasOwnProperty;function J3(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Y3(n)(V3(B3(n).document().write(U3()(e,t,!0))))}function Y3(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(ve),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(me),blockQuote:o(ue),characterEscape:E,characterReference:E,codeFenced:o(de),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(de,s),codeText:o(fe,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(pe),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(L),hardBreakEscape:o(he),hardBreakTrailing:o(he),htmlFlow:o(ge,s),htmlFlowData:E,htmlText:o(ge,s),htmlTextData:E,image:o(_e),label:s,link:o(ve),listItem:o(be),listItemValue:p,listOrdered:o(ye,f),listUnordered:o(ye),paragraph:o(xe),reference:re,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(me),strong:o(Se),thematicBreak:o(we)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:le,autolinkProtocol:ce,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:oe,characterReference:se,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:ee,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ie,resourceDestinationString:I,resourceTitleString:te,resource:ne,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};Z3(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),q3.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||$3).call(o,void 0,e[0])}for(r.position={start:X3(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:X3(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:X3(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+y0({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||$3).call(this,e,r[0])),n.position.end=X3(e.end)}function d(){return t2(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=m2(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ce(),n.position={start:X3(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=X3(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=X3(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=G3(t),n.identifier=m2(t).toLowerCase()}function ee(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=m2(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function oe(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=p2(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=o2(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=X3(e.end)}function ce(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function le(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[],position:void 0}}function de(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function fe(){return{type:`inlineCode`,value:``,position:void 0}}function pe(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function L(){return{type:`emphasis`,children:[],position:void 0}}function me(){return{type:`heading`,depth:0,children:[],position:void 0}}function he(){return{type:`break`,position:void 0}}function ge(){return{type:`html`,value:``,position:void 0}}function _e(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function ve(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function ye(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function be(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function xe(){return{type:`paragraph`,children:[],position:void 0}}function Se(){return{type:`strong`,children:[],position:void 0}}function Ce(){return{type:`text`,value:``,position:void 0}}function we(){return{type:`thematicBreak`,position:void 0}}}function X3(e){return{line:e.line,column:e.column,offset:e.offset}}function Z3(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Z3(e,r):Q3(e,r)}}function Q3(e,t){let n;for(n in t)if(q3.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function $3(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+y0({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+y0({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+y0({start:t.start,end:t.end})+`) is still open`)}function e6(e){let t=this;t.parser=n;function n(n){return J3(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function t6(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function n6(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
99
|
-
`}]}function
|
|
100
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function
|
|
98
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function V3(e){let t={constructs:d2([O3,...(e||{}).extensions||[]]),content:n(j2),defined:[],document:n(F2),flow:n(tie),lazy:{},string:n(C3),text:n(w3)};return t;function n(e){return n;function n(n){return R3(t,e,n)}}}function H3(e){for(;!_4(e););return e}var U3=/[\0\t\n\r]/g;function W3(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){U3.lastIndex=c;let n=U3.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var G3=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function K3(e){return e.replace(G3,q3)}function q3(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return m2(n.slice(t?2:1),t?16:10)}return s2(n)||e}var J3={}.hasOwnProperty;function Y3(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),X3(n)(H3(V3(n).document().write(W3()(e,t,!0))))}function X3(e){let t={afterExit:[],beforeEnter:[],transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:o(ve),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(me),blockQuote:o(ue),characterEscape:E,characterReference:E,codeFenced:o(de),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(de,s),codeText:o(fe,s),codeTextData:E,data:E,codeFlowValue:E,definition:o(pe),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o(L),hardBreakEscape:o(he),hardBreakTrailing:o(he),htmlFlow:o(ge,s),htmlFlowData:E,htmlText:o(ge,s),htmlTextData:E,image:o(_e),label:s,link:o(ve),listItem:o(be),listItemValue:p,listOrdered:o(ye,f),listUnordered:o(ye),paragraph:o(xe),reference:re,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(me),strong:o(Se),thematicBreak:o(we)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:le,autolinkProtocol:ce,blockQuote:l(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:oe,characterReference:se,codeFenced:l(_),codeFencedFence:g,codeFencedFenceInfo:m,codeFencedFenceMeta:h,codeFlowValue:D,codeIndented:l(v),codeText:l(M),codeTextData:D,data:D,definition:l(),definitionDestinationString:x,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(k),hardBreakTrailing:l(k),htmlFlow:l(A),htmlFlowData:D,htmlText:l(j),htmlTextData:D,image:l(P),label:ee,labelText:F,lineEnding:O,link:l(N),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ie,resourceDestinationString:I,resourceTitleString:te,resource:ne,setextHeading:l(T),setextHeadingLineSequence:w,setextHeadingText:C,strong:l(),thematicBreak:l()}};Q3(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[],position:void 0},o={stack:[r],tokenStack:[],config:t,enter:c,exit:u,buffer:s,resume:d,data:n},l=[],f=[],p=-1;for(;++p<e.length;)f.push(e[p]),(e[p][1].type===`listOrdered`||e[p][1].type===`listUnordered`)&&(e[p][0]===`enter`?l.push(f.length-1):a(f,l.pop()));for(e=f,p=-1;++p<e.length;){let n=t[e[p][0]];e[p][0]===`enter`&&t.beforeEnter.length>0&&i(t.beforeEnter,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),J3.call(n,e[p][1].type)&&n[e[p][1].type].call({...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1]),e[p][0]===`exit`&&t.afterExit.length>0&&i(t.afterExit,{...o,sliceSerialize:e[p][2].sliceSerialize},e[p][1])}if(o.tokenStack.length>0){let e=o.tokenStack[o.tokenStack.length-1];(e[1]||e6).call(o,void 0,e[0])}for(r.position={start:Z3(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Z3(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},p=-1;++p<t.transforms.length;)r=t.transforms[p](r)||r;return r}function i(e,t,n){let r=-1;for(;++r<e.length;)e[r].call(t,n)}function a(e,t){let n=e.length-1,r=t-1,i=-1,a=!1,o,s,c,l,u=[];for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let n=r;for(s=void 0;n--;){let t=e[n];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=n}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),u.push({at:s||r,event:[`exit`,o,t[2]]})}if(t[1].type===`listItemPrefix`){let e={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=e,u.push({at:r,event:[`enter`,e,t[2]]}),c=void 0,l=!0}}}let d=e.splice(t),f=0;for(r=-1;++r<d.length;){for(;f<u.length&&u[f].at===t+r;)e.push(u[f++].event);e.push(d[r])}e[t][1]._spread=a}function o(e,t){return n;function n(n){c.call(this,e(n),n),t&&t.call(this,n)}}function s(){this.stack.push({type:`fragment`,children:[]})}function c(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Z3(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),u.call(this,t)}}function u(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw Error("Cannot close `"+e.type+"` ("+b0({start:e.start,end:e.end})+`): it’s not open`);r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||e6).call(this,e,r[0])),n.position.end=Z3(e.end)}function d(){return n2(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function h(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function v(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function y(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=h2(this.sliceSerialize(e)).toLowerCase()}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function x(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function S(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function C(){this.data.setextHeadingSlurpLineEnding=!0}function w(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ce(),n.position={start:Z3(e.start),end:void 0},t.push(n)),this.stack.push(n)}function D(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Z3(e.end)}function O(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Z3(e.end),this.data.atHardBreak=void 0}else!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),D.call(this,e))}function k(){this.data.atHardBreak=!0}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=K3(t),n.identifier=h2(t).toLowerCase()}function ee(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=h2(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function oe(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=m2(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=s2(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=Z3(e.end)}function ce(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function le(e){D.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[],position:void 0}}function de(){return{type:`code`,lang:null,meta:null,value:``,position:void 0}}function fe(){return{type:`inlineCode`,value:``,position:void 0}}function pe(){return{type:`definition`,identifier:``,label:null,title:null,url:``,position:void 0}}function L(){return{type:`emphasis`,children:[],position:void 0}}function me(){return{type:`heading`,depth:0,children:[],position:void 0}}function he(){return{type:`break`,position:void 0}}function ge(){return{type:`html`,value:``,position:void 0}}function _e(){return{type:`image`,title:null,url:``,alt:null,position:void 0}}function ve(){return{type:`link`,title:null,url:``,children:[],position:void 0}}function ye(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[],position:void 0}}function be(e){return{type:`listItem`,spread:e._spread,checked:null,children:[],position:void 0}}function xe(){return{type:`paragraph`,children:[],position:void 0}}function Se(){return{type:`strong`,children:[],position:void 0}}function Ce(){return{type:`text`,value:``,position:void 0}}function we(){return{type:`thematicBreak`,position:void 0}}}function Z3(e){return{line:e.line,column:e.column,offset:e.offset}}function Q3(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Q3(e,r):$3(e,r)}}function $3(e,t){let n;for(n in t)if(J3.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`afterExit`:case`beforeEnter`:{let r=t[n];r&&e[n].push(r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function e6(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+b0({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+b0({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+b0({start:t.start,end:t.end})+`) is still open`)}function t6(e){let t=this;t.parser=n;function n(n){return Y3(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function n6(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function r6(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
99
|
+
`}]}function i6(e,t){let n=t.value?t.value+`
|
|
100
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function a6(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function o6(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function s6(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=O2(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function c6(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function l6(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function u6(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function d6(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return u6(e,t);let i={src:O2(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function f6(e,t){let n={src:O2(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function p6(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function m6(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return u6(e,t);let i={href:O2(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function h6(e,t){let n={href:O2(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function g6(e,t,n){let r=e.all(t),i=n?_6(n):v6(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
101
101
|
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
102
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function
|
|
102
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function _6(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=v6(n[r])}return t}function v6(e){return e.spread??e.children.length>1}function y6(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function b6(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function x6(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function S6(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function C6(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=_0(t.children[1]),o=g0(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function w6(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function T6(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var E6=9,D6=32;function O6(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(k6(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(k6(t.slice(i),i>0,!1)),a.join(``)}function k6(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===E6||t===D6;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===E6||t===D6;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function A6(e,t){let n={type:`text`,value:O6(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function j6(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var M6={blockquote:n6,break:r6,code:i6,delete:a6,emphasis:o6,footnoteReference:s6,heading:c6,html:l6,imageReference:d6,image:f6,inlineCode:p6,linkReference:m6,link:h6,listItem:g6,list:y6,paragraph:b6,root:x6,strong:S6,table:C6,tableCell:T6,tableRow:w6,text:A6,thematicBreak:j6,toml:N6,yaml:N6,definition:N6,footnoteDefinition:N6};function N6(){}var{defineProperty:P6}=Object,F6=typeof self==`object`?self:globalThis,I6=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new F6[e](t)},L6=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?P6(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof F6[e]==`function`?I6(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(I6(a,o),i)};return r},R6=e=>L6(new Map,e)(0),z6=``,{toString:B6}={},{keys:V6,is:H6}=Object,U6=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=B6.call(e).slice(8,-1);switch(n){case`Array`:return[1,z6];case`Object`:return[2,z6];case`Date`:return[3,z6];case`RegExp`:return[4,z6];case`Map`:return[5,z6];case`Set`:return[6,z6];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},W6=([e,t])=>e===0&&(t===`function`||t===`symbol`),G6=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=U6(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&H6(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of V6(o))(e||!W6(U6(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?z6:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(W6(U6(n))||W6(U6(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!W6(U6(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},K6=(e,{json:t,lossy:n}={})=>{let r=[];return G6(!(t||n),!!t,new Map,r)(e),r},q6=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?R6(K6(e,t)):structuredClone(e):(e,t)=>R6(K6(e,t));function J6(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function Y6(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function X6(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||J6,r=e.options.footnoteBackLabel||Y6,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=O2(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...q6(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
103
103
|
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
104
|
-
`}]}}var
|
|
104
|
+
`}]}}var Z6=(function(e){if(e==null)return n8;if(typeof e==`function`)return t8(e);if(typeof e==`object`)return Array.isArray(e)?Q6(e):$6(e);if(typeof e==`string`)return e8(e);throw Error(`Expected function, string, or object as test`)});function Q6(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Z6(e[n]);return t8(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function $6(e){let t=e;return t8(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function e8(e){return t8(t);function t(t){return t&&t.type===e}}function t8(e){return t;function t(t,n,r){return!!(r8(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function n8(){return!0}function r8(e){return typeof e==`object`&&!!e&&`type`in e}function i8(e){return e}var a8=[];function o8(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Z6(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+i8(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=a8,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=s8(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function s8(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?a8:[e]}function c8(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),o8(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var l8={}.hasOwnProperty,nie={};function rie(e,t){let n=t||nie,r=new Map,i=new Map,a={all:s,applyData:aie,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...M6,...n.handlers},one:o,options:n,patch:iie,wrap:sie};return c8(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(l8.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=q6(n);return r.children=a.all(e),r}return q6(e)}return(a.options.unknownHandler||oie)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=u8(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=u8(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function iie(e,t){e.position&&(t.position=y0(e))}function aie(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,q6(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function oie(e,t){let n=t.data||{},r=`value`in t&&!(l8.call(n,`hProperties`)||l8.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function sie(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
105
105
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
106
106
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
107
|
-
`}),n}function u8(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function d8(e,t){let n=
|
|
108
|
-
`},i)),a}function oie(e,t){return e&&`run`in e?async function(n,r){let i=d8(n,{file:r,...t});await e.run(i,r)}:function(n,r){return d8(n,{file:r,...e||t})}}function f8(e){if(e)throw e}var sie=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function p8(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function cie(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?lie(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function lie(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var m8={basename:uie,dirname:die,extname:fie,join:pie,sep:`/`};function uie(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);h8(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function die(e){if(h8(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function fie(e){h8(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function pie(...e){let t=-1,n;for(;++t<e.length;)h8(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:mie(n)}function mie(e){h8(e);let t=e.codePointAt(0)===47,n=hie(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function hie(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function h8(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var gie={cwd:_ie};function _ie(){return`/`}function g8(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function vie(e){if(typeof e==`string`)e=new URL(e);else if(!g8(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return yie(e)}function yie(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var _8=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],v8=class{constructor(e){let t;t=e?g8(e)?{path:e}:typeof e==`string`||bie(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:gie.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<_8.length;){let e=_8[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)_8.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?m8.basename(this.path):void 0}set basename(e){b8(e,`basename`),y8(e,`basename`),this.path=m8.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?m8.dirname(this.path):void 0}set dirname(e){x8(this.basename,`dirname`),this.path=m8.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?m8.extname(this.path):void 0}set extname(e){if(y8(e,`extname`),x8(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=m8.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){g8(e)&&(e=vie(e)),b8(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?m8.basename(this.path,this.extname):void 0}set stem(e){b8(e,`stem`),y8(e,`stem`),this.path=m8.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new C0(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function y8(e,t){if(e&&e.includes(m8.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+m8.sep+"`")}function b8(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function x8(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function bie(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var xie=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),S8=t(sie(),1),Sie={}.hasOwnProperty,Cie=new class e extends xie{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=cie()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,S8.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(T8(`data`,this.frozen),this.namespace[e]=t,this):Sie.call(this.namespace,e)&&this.namespace[e]||void 0:e?(T8(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=O8(e),n=this.parser||this.Parser;return C8(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),C8(`process`,this.parser||this.Parser),w8(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=O8(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Tie(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),C8(`processSync`,this.parser||this.Parser),w8(`processSync`,this.compiler||this.Compiler),this.process(e,r),D8(`processSync`,`process`,t),n;function r(e,r){t=!0,f8(e),n=r}}run(e,t,n){E8(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=O8(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),D8(`runSync`,`run`,n),r;function i(e,t){f8(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=O8(t),r=this.compiler||this.Compiler;return w8(`stringify`,r),E8(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(T8(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,S8.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];p8(o)&&p8(r)&&(r=(0,S8.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function C8(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function w8(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function T8(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function E8(e){if(!p8(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function D8(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function O8(e){return wie(e)?e:new v8(e)}function wie(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Tie(e){return typeof e==`string`||Eie(e)}function Eie(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var k8=[],A8={allowDangerousHtml:!0},Die=/^(https?|ircs?|mailto|xmpp)$/i,Oie=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function j8(e){let t=kie(e),n=Aie(e);return jie(t.runSync(t.parse(n),n),e)}function kie(e){let t=e.rehypePlugins||k8,n=e.remarkPlugins||k8,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...A8}:A8;return Cie().use(e6).use(n).use(oie,r).use(t)}function Aie(e){let t=e.children||``,n=new v8;return typeof t==`string`?n.value=t:``+t,n}function jie(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Mie;for(let e of Oie)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return s8(e,l),j0(e,{Fragment:z.Fragment,components:i,ignoreInvalidStyle:!0,jsx:z.jsx,jsxs:z.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in $0)if(Object.hasOwn($0,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=$0[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Mie(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Die.test(e.slice(0,t))?e:``}function M8(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Nie(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Pie(e,t,n){let r=X6((n||{}).ignore||[]),i=Fie(t),a=-1;for(;++a<i.length;)a8(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Fie(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Iie(e[0]),Lie(e[1])])}return t}function Iie(e){return typeof e==`string`?new RegExp(Nie(e),`g`):e}function Lie(e){return typeof e==`function`?e:function(){return e}}var N8=`phrasing`,P8=[`autolink`,`link`,`image`,`label`];function Rie(){return{transforms:[Gie],enter:{literalAutolink:Bie,literalAutolinkEmail:F8,literalAutolinkHttp:F8,literalAutolinkWww:F8},exit:{literalAutolink:Wie,literalAutolinkEmail:Uie,literalAutolinkHttp:Vie,literalAutolinkWww:Hie}}}function zie(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:N8,notInConstruct:P8},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:N8,notInConstruct:P8},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:N8,notInConstruct:P8}]}}function Bie(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function F8(e){this.config.enter.autolinkProtocol.call(this,e)}function Vie(e){this.config.exit.autolinkProtocol.call(this,e)}function Hie(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Uie(e){this.config.exit.autolinkEmail.call(this,e)}function Wie(e){this.exit(e)}function Gie(e){Pie(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Kie],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,qie]],{ignore:[`link`,`linkReference`]})}function Kie(e,t,n,r,i){let a=``;if(!I8(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Jie(n)))return!1;let o=Yie(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function qie(e,t,n,r){return!I8(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Jie(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Yie(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=M8(e,`(`),a=M8(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function I8(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||T2(n)||w2(n))&&(!t||n!==47)}L8.peek=iae;function Xie(){this.buffer()}function Zie(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Qie(){this.buffer()}function $ie(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function eae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=m2(this.sliceSerialize(e)).toLowerCase(),n.label=t}function tae(e){this.exit(e)}function nae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=m2(this.sliceSerialize(e)).toLowerCase(),n.label=t}function rae(e){this.exit(e)}function iae(){return`[`}function L8(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function aae(){return{enter:{gfmFootnoteCallString:Xie,gfmFootnoteCall:Zie,gfmFootnoteDefinitionLabelString:Qie,gfmFootnoteDefinition:$ie},exit:{gfmFootnoteCallString:eae,gfmFootnoteCall:tae,gfmFootnoteDefinitionLabelString:nae,gfmFootnoteDefinition:rae}}}function oae(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:L8},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
109
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?R8:
|
|
110
|
-
`)}function
|
|
111
|
-
`&&!e.before&&!e.after&&
|
|
112
|
-
`}function
|
|
107
|
+
`}),n}function u8(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function d8(e,t){let n=rie(e,t),r=n.one(e,void 0),i=X6(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
108
|
+
`},i)),a}function cie(e,t){return e&&`run`in e?async function(n,r){let i=d8(n,{file:r,...t});await e.run(i,r)}:function(n,r){return d8(n,{file:r,...e||t})}}function f8(e){if(e)throw e}var lie=n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function p8(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function uie(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a)r(a);else{for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?die(s,i)(...o):r(null,...o)}}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function die(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var m8={basename:fie,dirname:pie,extname:mie,join:hie,sep:`/`};function fie(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);h8(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function pie(e){if(h8(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function mie(e){h8(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}}else n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function hie(...e){let t=-1,n;for(;++t<e.length;)h8(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:gie(n)}function gie(e){h8(e);let t=e.codePointAt(0)===47,n=_ie(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function _ie(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function h8(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var vie={cwd:yie};function yie(){return`/`}function g8(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function bie(e){if(typeof e==`string`)e=new URL(e);else if(!g8(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return xie(e)}function xie(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var _8=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],v8=class{constructor(e){let t;t=e?g8(e)?{path:e}:typeof e==`string`||Sie(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:vie.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<_8.length;){let e=_8[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)_8.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?m8.basename(this.path):void 0}set basename(e){b8(e,`basename`),y8(e,`basename`),this.path=m8.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?m8.dirname(this.path):void 0}set dirname(e){x8(this.basename,`dirname`),this.path=m8.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?m8.extname(this.path):void 0}set extname(e){if(y8(e,`extname`),x8(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=m8.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){g8(e)&&(e=bie(e)),b8(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?m8.basename(this.path,this.extname):void 0}set stem(e){b8(e,`stem`),y8(e,`stem`),this.path=m8.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new w0(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function y8(e,t){if(e&&e.includes(m8.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+m8.sep+"`")}function b8(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function x8(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Sie(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Cie=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),S8=t(lie(),1),wie={}.hasOwnProperty,Tie=new class e extends Cie{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=uie()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,S8.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(T8(`data`,this.frozen),this.namespace[e]=t,this):wie.call(this.namespace,e)&&this.namespace[e]||void 0:e?(T8(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=O8(e),n=this.parser||this.Parser;return C8(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),C8(`process`,this.parser||this.Parser),w8(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=O8(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);Die(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),C8(`processSync`,this.parser||this.Parser),w8(`processSync`,this.compiler||this.Compiler),this.process(e,r),D8(`processSync`,`process`,t),n;function r(e,r){t=!0,f8(e),n=r}}run(e,t,n){E8(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=O8(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),D8(`runSync`,`run`,n),r;function i(e,t){f8(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=O8(t),r=this.compiler||this.Compiler;return w8(`stringify`,r),E8(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(T8(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,S8.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];p8(o)&&p8(r)&&(r=(0,S8.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function C8(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function w8(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function T8(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function E8(e){if(!p8(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function D8(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function O8(e){return Eie(e)?e:new v8(e)}function Eie(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Die(e){return typeof e==`string`||Oie(e)}function Oie(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var k8=[],A8={allowDangerousHtml:!0},kie=/^(https?|ircs?|mailto|xmpp)$/i,Aie=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function j8(e){let t=jie(e),n=Mie(e);return Nie(t.runSync(t.parse(n),n),e)}function jie(e){let t=e.rehypePlugins||k8,n=e.remarkPlugins||k8,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...A8}:A8;return Tie().use(t6).use(n).use(cie,r).use(t)}function Mie(e){let t=e.children||``,n=new v8;return typeof t==`string`?n.value=t:``+t,n}function Nie(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Pie;for(let e of Aie)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return c8(e,l),M0(e,{Fragment:z.Fragment,components:i,ignoreInvalidStyle:!0,jsx:z.jsx,jsxs:z.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in e2)if(Object.hasOwn(e2,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=e2[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function Pie(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||kie.test(e.slice(0,t))?e:``}function M8(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Fie(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Iie(e,t,n){let r=Z6((n||{}).ignore||[]),i=Lie(t),a=-1;for(;++a<i.length;)o8(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Lie(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Rie(e[0]),zie(e[1])])}return t}function Rie(e){return typeof e==`string`?new RegExp(Fie(e),`g`):e}function zie(e){return typeof e==`function`?e:function(){return e}}var N8=`phrasing`,P8=[`autolink`,`link`,`image`,`label`];function Bie(){return{transforms:[qie],enter:{literalAutolink:Hie,literalAutolinkEmail:F8,literalAutolinkHttp:F8,literalAutolinkWww:F8},exit:{literalAutolink:Kie,literalAutolinkEmail:Gie,literalAutolinkHttp:Uie,literalAutolinkWww:Wie}}}function Vie(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:N8,notInConstruct:P8},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:N8,notInConstruct:P8},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:N8,notInConstruct:P8}]}}function Hie(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function F8(e){this.config.enter.autolinkProtocol.call(this,e)}function Uie(e){this.config.exit.autolinkProtocol.call(this,e)}function Wie(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Gie(e){this.config.exit.autolinkEmail.call(this,e)}function Kie(e){this.exit(e)}function qie(e){Iie(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Jie],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Yie]],{ignore:[`link`,`linkReference`]})}function Jie(e,t,n,r,i){let a=``;if(!I8(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Xie(n)))return!1;let o=Zie(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Yie(e,t,n,r){return!I8(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Xie(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Zie(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=M8(e,`(`),a=M8(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function I8(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||E2(n)||T2(n))&&(!t||n!==47)}L8.peek=oae;function Qie(){this.buffer()}function $ie(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function eae(){this.buffer()}function tae(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function nae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=h2(this.sliceSerialize(e)).toLowerCase(),n.label=t}function rae(e){this.exit(e)}function iae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=h2(this.sliceSerialize(e)).toLowerCase(),n.label=t}function aae(e){this.exit(e)}function oae(){return`[`}function L8(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function sae(){return{enter:{gfmFootnoteCallString:Qie,gfmFootnoteCall:$ie,gfmFootnoteDefinitionLabelString:eae,gfmFootnoteDefinition:tae},exit:{gfmFootnoteCallString:nae,gfmFootnoteCall:rae,gfmFootnoteDefinitionLabelString:iae,gfmFootnoteDefinition:aae}}}function cae(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:L8},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
109
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?R8:lae))),s(),o}}function lae(e,t,n){return t===0?e:R8(e,t,n)}function R8(e,t,n){return(n?``:` `)+e}var uae=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];z8.attention=hae,z8.peek=gae;function dae(){return{canContainEols:[`delete`],enter:{strikethrough:pae},exit:{strikethrough:mae}}}function fae(){return{handlers:{delete:z8},unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:uae}]}}function pae(e){this.enter({type:`delete`,children:[],position:void 0},e)}function mae(e){this.exit(e)}function z8(e,t,n,r){let i=n.createTracker(r),a=n.stack.includes(`strikethrough`)?`~`:`~~`,o=n.enter(`strikethrough`),s=i.move(a);return s+=n.containerPhrasing(e,{...i.current(),before:s,after:`~`}),s+=i.move(a),o(),s}function hae(){return{construct:`strikethrough`,markers:[`~`],sizes:[2,1]}}function gae(){return`~`}function _ae(e){return e.length}function vae(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||_ae,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=yae(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=B8(r[d]);else{let e=B8(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
110
|
+
`)}function yae(e){return e==null?``:String(e)}function B8(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}var bae=Z6([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function xae(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Sae);return i(),o}function Sae(e,t,n){return`>`+(n?``:` `)+e}function Cae(e,t){return V8(e,t.inConstruct,!0)&&!V8(e,t.notInConstruct,!1)}function V8(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function H8(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
|
|
111
|
+
`&&!e.before&&!e.after&&Cae(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
|
|
112
|
+
`}function wae(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function Tae(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function Eae(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Dae(e,t,n,r){let i=Eae(n),a=e.value||``;if(Tae(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Oae);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(wae(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,{before:u,after:`
|
|
113
113
|
`,encode:["`"],...o.current()})),t()}return u+=o.move(`
|
|
114
114
|
`),a&&(u+=o.move(a+`
|
|
115
|
-
`)),u+=o.move(s),c(),u}function
|
|
116
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function
|
|
115
|
+
`)),u+=o.move(s),c(),u}function Oae(e,t,n){return(n?``:` `)+e}function U8(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function kae(e,t,n,r){let i=U8(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
116
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Aae(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}W8.attention=jae,W8.peek=Mae;function W8(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function jae(e,t){return{construct:`emphasis`,markers:Aae(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function Mae(e,t,n){return n.options.emphasis||`*`}function Nae(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Pae(e,t){let n=!1;return c8(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&n2(e)&&(t.options.setext||n))}function Fae(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Pae(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
117
117
|
`,after:`
|
|
118
118
|
`});return r(),t(),o+`
|
|
119
119
|
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
120
120
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
121
|
-
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=
|
|
121
|
+
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=Nae(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}G8.peek=Iae;function G8(e){return e.value||``}function Iae(){return`<`}K8.peek=Lae;function K8(e,t,n,r){let i=U8(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Lae(){return`!`}q8.peek=Rae;function q8(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Rae(){return`!`}J8.peek=zae;function J8(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function zae(){return"`"}function Y8(e,t){let n=n2(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][+\-.a-z]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}X8.peek=Bae;function X8(e,t,n,r){let i=U8(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(Y8(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Bae(e,t,n){return Y8(e,n)?`<`:`[`}Z8.peek=Vae;function Z8(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=u.filter(function(e){return e!==`phrasing`}),o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Vae(){return`[`}function Q8(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Hae(e){let t=Q8(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Uae(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function $8(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Wae(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Uae(n):Q8(n),s=e.ordered?o===`.`?`)`:`.`:Hae(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),$8(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Gae(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Kae(e,t,n,r){let i=Gae(n),a=n.bulletCurrent||Q8(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function qae(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function Jae(e,t,n,r){if(!e.children.some(function(e){return bae(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function Yae(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}e5.attention=Xae,e5.peek=Zae;function e5(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function Xae(e,t){return{construct:`strong`,markers:Yae(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function Zae(e,t,n){return n.options.strong||`*`}function Qae(e,t,n,r){return n.safe(e.value,r)}function $ae(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function eoe(e,t,n){let r=($8(n)+(n.options.ruleSpaces?` `:``)).repeat($ae(n));return n.options.ruleSpaces?r.slice(0,-1):r}var t5={blockquote:xae,break:H8,code:Dae,definition:kae,emphasis:W8,hardBreak:H8,heading:Fae,html:G8,image:K8,imageReference:q8,inlineCode:J8,link:X8,linkReference:Z8,list:Wae,listItem:Kae,paragraph:qae,root:Jae,strong:e5,text:Qae,thematicBreak:eoe};function toe(){return{enter:{table:noe,tableData:r5,tableHeader:r5,tableRow:ioe},exit:{codeText:aoe,table:roe,tableData:n5,tableHeader:n5,tableRow:n5}}}function noe(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function roe(e){this.exit(e),this.data.inTable=void 0}function ioe(e){this.enter({type:`tableRow`,children:[]},e)}function n5(e){this.exit(e)}function r5(e){this.enter({type:`tableCell`,children:[]},e)}function aoe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,ooe));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function ooe(e,t){return t===`|`?t:e}function soe(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
122
122
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
123
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return gae(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=t5.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function ooe(){return{exit:{taskListCheckValueChecked:i5,taskListCheckValueUnchecked:i5,paragraph:coe}}}function soe(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:loe}}}function i5(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function coe(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function loe(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=t5.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function uoe(){return[Rie(),aae(),lae(),$ae(),ooe()]}function doe(e){return{extensions:[zie(),oae(e),uae(),aoe(e),soe()]}}var foe={tokenize:voe,partial:!0},a5={tokenize:yoe,partial:!0},o5={tokenize:boe,partial:!0},s5={tokenize:xoe,partial:!0},poe={tokenize:Soe,partial:!0},c5={name:`wwwAutolink`,tokenize:goe,previous:p5},l5={name:`protocolAutolink`,tokenize:_oe,previous:m5},u5={name:`emailAutolink`,tokenize:hoe,previous:h5},d5={};function moe(){return{text:d5}}for(var f5=48;f5<123;)d5[f5]=u5,f5++,f5===58?f5=65:f5===91&&(f5=97);d5[43]=u5,d5[45]=u5,d5[46]=u5,d5[95]=u5,d5[72]=[u5,l5],d5[104]=[u5,l5],d5[87]=[u5,c5],d5[119]=[u5,c5];function hoe(e,t,n){let r=this,i,a;return o;function o(t){return!g5(t)||!h5.call(r,r.previous)||_5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return g5(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(poe,u,l)(t):t===45||t===95||g2(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&h2(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function goe(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!p5.call(r,r.previous)||_5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(foe,e.attempt(a5,e.attempt(o5,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function _oe(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&m5.call(r,r.previous)&&!_5(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(h2(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||v2(t)||S2(t)||T2(t)||w2(t)?n(t):e.attempt(a5,e.attempt(o5,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function voe(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function yoe(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(s5,c,s)(t):t===null||S2(t)||T2(t)||t!==45&&w2(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function boe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(s5,t,a)(o):o===null||S2(o)||T2(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function xoe(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||S2(o)||T2(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||S2(e)||T2(e)?t(e):r(e)}function a(e){return h2(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):h2(t)?(e.consume(t),o):n(t)}}function Soe(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return g2(e)?n(e):t(e)}}function p5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||S2(e)}function m5(e){return!h2(e)}function h5(e){return!(e===47||g5(e))}function g5(e){return e===43||e===45||e===46||e===95||g2(e)}function _5(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Coe={tokenize:joe,partial:!0};function woe(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Ooe,continuation:{tokenize:koe},exit:Aoe}},text:{91:{name:`gfmFootnoteCall`,tokenize:Doe},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Toe,resolveTo:Eoe}}}}function Toe(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=m2(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Eoe(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Doe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||S2(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(m2(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return S2(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Ooe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||S2(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=m2(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return S2(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),O2(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function koe(e,t,n){return e.check(K2,t,e.attempt(Coe,t,n))}function Aoe(e){e.exit(`gfmFootnoteDefinition`)}function joe(e,t,n){let r=this;return O2(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Moe(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&s2(o,o.length,0,z2(s,e.slice(r+1,n),t)),s2(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),s2(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=R2(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=R2(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Noe=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Poe(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Poe(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Foe(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Ioe(){return{flow:{null:{name:`table`,tokenize:Loe,resolveAll:Roe}}}}function Loe(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):C2(t)?O2(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||S2(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,C2(t)?O2(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return C2(t)?O2(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return C2(t)?O2(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):C2(n)?O2(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||S2(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Roe(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Noe;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(y5(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=v5(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=v5(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=v5(f,t,o,i,n,d)):(o[0]=o[1],d=v5(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&y5(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Foe(t.events,n))}return e}function v5(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},b5(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=b5(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=b5(t.events,n[2]),a=b5(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},b5(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function y5(e,t,n,r,i){let a=[],o=b5(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function b5(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var zoe={name:`tasklistCheck`,tokenize:Voe};function Boe(){return{text:{91:zoe}}}function Voe(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return S2(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):C2(r)?e.check({tokenize:Hoe},t,n)(r):n(r)}}function Hoe(e,t,n){return O2(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Uoe(e){return u2([moe(),woe(),Moe(e),Ioe(),Boe()])}var Woe={};function x5(e){let t=this,n=e||Woe,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Uoe(n)),a.push(uoe()),o.push(doe(n))}function S5({...e}){return(0,z.jsx)(hT,{"data-slot":`dropdown-menu`,...e})}function C5({...e}){return(0,z.jsx)(_T,{"data-slot":`dropdown-menu-trigger`,...e})}function w5({className:e,sideOffset:t=4,...n}){return(0,z.jsx)(vT,{children:(0,z.jsx)(bT,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:T(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function T5({className:e,inset:t,variant:n=`default`,...r}){return(0,z.jsx)(xT,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:T(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function Goe({className:e,children:t,checked:n,...r}){return(0,z.jsxs)(ST,{"data-slot":`dropdown-menu-checkbox-item`,className:T(`relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,z.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(CT,{children:(0,z.jsx)(lO,{className:`size-4`})})}),t]})}var E5={hour:`2-digit`,minute:`2-digit`},Koe=e=>new Date(e).toLocaleTimeString(E(),E5),D5=e=>new Date(e).toLocaleTimeString(E());function qoe(e,t=new Date){let n=new Date(e);return n.toDateString()===t.toDateString()?Koe(e):n.toLocaleString(E(),{month:`numeric`,day:`numeric`,...E5})}function Joe(e,t){if(!e)return`—`;let n=Math.max(0,Math.round((t-Date.parse(e))/1e3)),r=new Intl.RelativeTimeFormat(E(),{numeric:`always`});return n<60?r.format(-n,`second`):r.format(-Math.round(n/60),`minute`)}var O5=[`git`],k5={state:()=>Ov(`GET`,`/api/git`).then(e=>e.git),review:e=>Ov(`POST`,`/api/git/review`,e),openPr:()=>Ov(`GET`,`/api/git/pr`).then(e=>e.url),draft:e=>Ov(`POST`,`/api/git/review/draft`,e),diff:e=>Ov(`GET`,`/api/git/diff?path=${encodeURIComponent(e)}`),revert:e=>Ov(`POST`,`/api/git/revert`,e),defaultChanges:()=>Ov(`GET`,`/api/git/default`).then(e=>e.files),restoreDefault:e=>Ov(`POST`,`/api/git/restore-default`,{files:e})};async function Yoe(e){for(let{table:t,key:n,before:r,after:i}of e)if(r===null)await Uv.remove(t,n);else if(i===null)await Uv.create(t,n,r);else{let e=Object.fromEntries(Object.keys(i).filter(e=>!(e in r)).map(e=>[e,null]));await Uv.update(t,n,{...e,...r},i)}}function A5(){let e=!Yv();return V_({queryKey:O5,queryFn:k5.state,enabled:e,refetchOnWindowFocus:!0}).data??null}function j5(e){let t=new Map;for(let n of e)t.set(n.table,[...t.get(n.table)??[],n]);return[...t.entries()].sort(([e],[t])=>e===null?1:t===null?-1:e.localeCompare(t)).map(([e,t])=>({table:e,changes:t}))}var M5=[`ai-instructions`];function N5({open:e,onOpenChange:t}){let n=Sg(),r=V_({queryKey:M5,queryFn:Z$.get,enabled:e,staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1);(0,B.useEffect)(()=>{r.data&&!c&&(a(r.data.instructions??``),s(r.data.pullRequests??``),l(!0))},[r.data,c]);let u=H_({mutationFn:()=>Z$.save({instructions:i,pullRequests:o,base:r.data?.base??``}),onSuccess:e=>{n.setQueryData(M5,e),n.invalidateQueries({queryKey:O5}),iv.success(tt()),t(!1)}}),d=e=>{t(e),e||(u.reset(),n.removeQueries({queryKey:M5}))},f=u.error instanceof Sv&&u.error.status===409?Xe():u.error instanceof Error?u.error.message:r.error instanceof Error?r.error.message:null;return(0,z.jsx)(qk,{open:e,onOpenChange:d,children:(0,z.jsxs)(Qk,{className:`sm:max-w-2xl`,children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{className:`text-[18px]`,children:nt()}),(0,z.jsx)(rA,{className:`text-[14px]`,children:Ze()})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:Je()}),(0,z.jsx)(uJ,{value:i,placeholder:Ye(),onChange:e=>a(e.target.value),disabled:!r.data,className:`min-h-28 text-[15px]`})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:$e()}),(0,z.jsx)(uJ,{value:o,placeholder:et(),onChange:e=>s(e.target.value),disabled:!r.data,className:`min-h-20 text-[15px]`})]}),f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-[13px] text-err`,children:f}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>d(!1),children:gt()}),(0,z.jsx)(V,{disabled:!r.data||u.isPending,onClick:()=>u.mutate(),children:St()})]})]})})}var P5=`w-full rounded-md border bg-panel px-2.5 py-1.5 text-[15px]`;function Xoe({viewerKeys:e,providers:t,initial:n,onSave:r}){let[i,a]=(0,B.useState)(n?.provider??t[0]?.id??``),o=t.find(e=>e.id===i)??t[0],[s,c]=(0,B.useState)(n?.provider===o.id?n.model:o.models[0]),l=t=>e?q$(t):``,u=t=>e&&J$(t),[d,f]=(0,B.useState)(()=>n?.provider===o.id?n.apiKey:l(o.id)),[p,m]=(0,B.useState)(()=>u(o.id)),h=s.trim(),g=h!==``&&(!e||d.trim()!==``||o.hasKey);return(0,z.jsxs)(`form`,{"aria-label":Ne(),className:`flex flex-col gap-3 border-b p-3.5 text-[15px]`,onSubmit:t=>{t.preventDefault(),g&&r({provider:o.id,model:h,apiKey:e?d.trim():``},e&&p)},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[we(),(0,z.jsx)(`select`,{className:P5,value:o.id,onChange:e=>{let n=t.find(t=>t.id===e.target.value);a(n.id),c(n.models[0]),f(l(n.id)),m(u(n.id))},children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),o.fixedModels?(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[he(),(0,z.jsx)(`select`,{className:P5,value:s,onChange:e=>c(e.target.value),children:o.models.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}):(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[he(),(0,z.jsx)(`input`,{className:P5,list:`ai-models-${o.id}`,autoComplete:`off`,spellCheck:!1,value:s,onChange:e=>c(e.target.value)}),(0,z.jsx)(`datalist`,{id:`ai-models-${o.id}`,children:o.models.map(e=>(0,z.jsx)(`option`,{value:e},e))}),h!==``&&!o.models.includes(h)&&(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:ge()})]}),e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[ae(),(0,z.jsx)(`input`,{className:P5,type:`password`,autoComplete:`off`,spellCheck:!1,value:d,placeholder:o.hasKey?se():``,onChange:e=>f(e.target.value)})]}),(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:oe()}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),Ee()]})]}),(0,z.jsx)(V,{type:`submit`,disabled:!g,className:`self-end`,children:je()})]})}var F5=e=>typeof e==`object`&&!!e&&!Array.isArray(e),I5=e=>typeof e!=`object`||!e,L5=e=>Array.isArray(e)?`[${e.map(L5).join(`,`)}]`:F5(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${L5(e[t])}`).join(`,`)}}`:JSON.stringify(e)??`null`,R5=(e,t)=>e===``?t:`${e} › ${t}`,z5=[`id`,`key`,`name`],Zoe=/(^|_)(id|key|code|uuid|slug|name)$/i,Qoe=/^[\w.\-:/]{1,64}$/;function $oe(e){return typeof e==`string`?e.length<=64&&!/\s/.test(e):typeof e==`number`||typeof e==`boolean`}function ese(e,t){let n=[...e,...t];if(n.length===0)return null;let r=r=>n.every(e=>Object.hasOwn(e,r)&&$oe(e[r]))&&new Set(n.map(e=>typeof e[r])).size===1&&[e,t].every(e=>new Set(e.map(e=>e[r])).size===e.length),i=n=>{if(e.length===0||t.length===0)return 1;let r=new Set(t.map(e=>e[n]));return e.filter(e=>r.has(e[n])).length},a=z5.find(e=>r(e)&&i(e)>0);if(a)return a;let o=Math.ceil(Math.min(e.length,t.length)/2),s=Object.keys(n[0]).filter(e=>!z5.includes(e)&&r(e)&&i(e)>=Math.max(o,1)),c=e=>n.every(t=>typeof t[e]!=`string`||Qoe.test(t[e]));return s.find(e=>Zoe.test(e))??s.find(e=>c(e)&&n.every(t=>typeof t[e]==`string`||Number.isInteger(t[e])))??null}function tse(e,t){let n=Array.from({length:e.length+1},()=>Array.from({length:t.length+1},()=>0));for(let r=e.length-1;r>=0;r--)for(let i=t.length-1;i>=0;i--)n[r][i]=e[r]===t[i]?n[r+1][i+1]+1:Math.max(n[r+1][i],n[r][i+1]);let r=[],i=0,a=0;for(;i<e.length&&a<t.length;)e[i]===t[a]?r.push([i++,a++]):n[i+1][a]>=n[i][a+1]?i++:a++;return r}function nse(e,t,n,r){if(e.every(F5)&&t.every(F5)){let i=ese(e,t);if(i!==null){let a=e=>new Map(e.map(e=>[String(e[i]),e])),o=a(e),s=a(t);for(let[e,t]of o){let i=s.get(e),a=R5(n,e);i===void 0?r.push({path:a,kind:`removed`,before:t}):B5(t,i,a,r)}for(let[e,t]of s)o.has(e)||r.push({path:R5(n,e),kind:`added`,after:t});return}}if(e.length===t.length){e.forEach((e,i)=>B5(e,t[i],R5(n,`[${i}]`),r));return}let i=e.map(L5),a=t.map(L5),o=0;for(;o<i.length&&o<a.length&&i[o]===a[o];)o++;let s=i.length,c=a.length;for(;s>o&&c>o&&i[s-1]===a[c-1];)s--,c--;if((s-o)*(c-o)>4e6){r.push({path:n,kind:`changed`,before:e,after:t});return}let l=tse(i.slice(o,s),a.slice(o,c)),u=new Set(l.map(([e])=>e+o)),d=new Set(l.map(([,e])=>e+o));for(let t=o;t<s;t++)u.has(t)||r.push({path:R5(n,`[${t}]`),kind:`removed`,before:e[t]});for(let e=o;e<c;e++)d.has(e)||r.push({path:R5(n,`[${e}]`),kind:`added`,after:t[e]})}function B5(e,t,n,r){if(F5(e)&&F5(t)){for(let i of Object.keys(e))Object.hasOwn(t,i)?B5(e[i],t[i],R5(n,i),r):r.push({path:R5(n,i),kind:`removed`,before:e[i]});for(let i of Object.keys(t))Object.hasOwn(e,i)||r.push({path:R5(n,i),kind:`added`,after:t[i]})}else Array.isArray(e)&&Array.isArray(t)&&!(e.every(I5)&&t.every(I5))?nse(e,t,n,r):L5(e)!==L5(t)&&r.push({path:n,kind:`changed`,before:e,after:t})}function rse(e,t){let n=[];return B5(e,t,``,n),n}var V5=e=>typeof e==`object`&&!!e,ise=e=>e==null?`—`:typeof e==`string`?e:JSON.stringify(e),ase={insert:ca,update:la,delete:sa},ose={applied:Bi,discarded:Xi,stale:fa,failed:Zi},sse={added:Gi,removed:qi,changed:Ki},cse=200,H5=50;function U5({value:e}){let t=JSON.stringify(e)??`null`,[n,r]=(0,B.useState)(!1),i=t.length>cse;return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:T(`font-mono text-[14px] [overflow-wrap:anywhere]`,i&&!n&&`line-clamp-6`),children:t}),i&&(0,z.jsx)(`button`,{type:`button`,className:`text-[14px] text-muted-foreground underline`,onClick:()=>r(!n),children:n?Ji():da()})]})}function lse({field:e,before:t,after:n}){let r=(0,B.useMemo)(()=>rse({[e]:t},{[e]:n}),[e,t,n]),i=r.slice(0,H5);return r.length===0?(0,z.jsxs)(`p`,{className:`text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e}),` `,(0,z.jsx)(`span`,{children:ua()})]}):(0,z.jsxs)(`ul`,{"aria-label":e,className:`flex flex-col gap-2`,children:[i.map(e=>(0,z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 rounded-md border bg-panel px-2.5 py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[14px]`,children:[(0,z.jsx)(`span`,{className:T(`shrink-0 rounded-full border px-2`,e.kind===`removed`?`border-err text-err`:e.kind===`added`?`border-ok text-ok`:`text-muted-foreground`),children:sse[e.kind]()}),(0,z.jsx)(`span`,{className:`font-mono [overflow-wrap:anywhere]`,children:e.path})]}),e.kind!==`added`&&(0,z.jsx)(U5,{value:e.before}),e.kind===`changed`&&(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:`→`}),e.kind!==`removed`&&(0,z.jsx)(U5,{value:e.after})]},`${e.kind}:${e.path}`)),r.length>H5&&(0,z.jsx)(`li`,{className:`text-[14px] text-muted-foreground`,children:ra({count:r.length-H5})})]})}function use({row:e}){let t=e.op===`update`?e.changed:Object.keys(e.after??e.before??{}),n=t=>e.op===`update`&&V5(e.before?.[t])&&V5(e.after?.[t]),r=t.filter(e=>!n(e));return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-b border-dashed py-2.5 last:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.key}),(0,z.jsx)(`span`,{className:T(`rounded-full border px-2 text-[14px]`,e.op===`delete`?`border-err text-err`:`border-ok text-ok`),children:ase[e.op]()})]}),e.op!==`delete`&&r.length>0&&(0,z.jsx)(WZ,{labels:[Wi(),zi()],format:ise,rows:r.map(t=>({field:t,a:e.before?.[t],b:e.after?.[t]}))}),e.op!==`delete`&&t.filter(n).map(t=>(0,z.jsx)(lse,{field:t,before:e.before?.[t],after:e.after?.[t]},t))]})}var dse={done:lr,failed:ur,skipped:jr};function fse(e){switch(e.kind){case`create_branch`:return e.from?sr({name:e.name,from:e.from}):ir({name:e.name});case`switch`:return Lr({branch:e.branch});case`commit`:return tr({message:e.message});case`push`:return Sr({branch:e.branch});case`pull`:return yr({branch:e.branch});case`open_pr`:return mr({title:e.title})}}function pse({git:e,ran:t}){let n=t||e.results.some(e=>e.status!==`skipped`);return(0,z.jsx)(`ol`,{className:`flex flex-col gap-2 py-2.5`,children:e.steps.map((t,r)=>{let i=e.results[r];return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1 text-[15px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`${r+1}.`}),(0,z.jsx)(`span`,{children:fse(t)}),n&&i&&(0,z.jsx)(`span`,{className:T(`ml-auto shrink-0 rounded-full border px-2 text-[14px]`,i.status===`done`?`border-ok text-ok`:i.status===`failed`?`border-err text-err`:`text-muted-foreground`),children:dse[i.status]()})]}),t.kind===`commit`&&(0,z.jsx)(`ul`,{className:`ml-6 font-mono text-[14px] text-muted-foreground`,children:t.paths.map(e=>(0,z.jsx)(`li`,{children:e},e))}),t.kind===`open_pr`&&t.body&&(0,z.jsx)(`p`,{className:`ml-6 text-[14px] whitespace-pre-wrap text-muted-foreground`,children:t.body}),n&&i?.message&&(0,z.jsx)(`p`,{className:`ml-6 text-[14px] text-err [overflow-wrap:anywhere]`,children:i.message}),n&&i?.url&&(0,z.jsx)(`a`,{className:`ml-6 text-[14px] underline`,href:i.url,target:`_blank`,rel:`noreferrer`,children:i.created?gr():hr()})]},r)})})}function W5({proposal:e}){let t=H_({mutationFn:t=>t===`apply`?n1.apply(e.id):n1.discard(e.id),onSettled:()=>d1(),onError:e=>iv.error(e.message)}),n=[...new Set(e.rows.map(e=>e.table))],r=e.git?e.git.steps.length:e.table?1:e.rows.length;return(0,z.jsxs)(`section`,{"aria-label":ea({title:e.title}),className:`overflow-hidden rounded-lg border`,children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-2 border-b bg-panel px-3 py-2.5`,children:[(0,z.jsx)(`h3`,{className:`text-[16px] font-semibold`,children:e.title}),(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:e.git?Pr({count:r}):e.table?oa({name:e.table.name}):ha({tables:n.join(`, `),count:r})})]}),(0,z.jsx)(`div`,{className:`max-h-[360px] overflow-auto px-3`,children:e.git?(0,z.jsx)(pse,{git:e.git,ran:e.status!==`pending`}):e.table?(0,z.jsx)(`p`,{className:`py-2.5 text-[14px]`,children:(e.table.mode===`list`?xa:va)({name:e.table.name,key:e.table.key})}):e.rows.map(e=>(0,z.jsx)(use,{row:e},`${e.table}/${e.key}`))}),e.warnings.length>0&&(0,z.jsx)(`ul`,{className:`border-t bg-warn-soft px-3 py-2 text-[14px] text-warn`,children:e.warnings.map(e=>(0,z.jsxs)(`li`,{children:[`⚠ `,e]},e))}),e.sql&&(0,z.jsxs)(`details`,{className:`border-t px-3 py-2 text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer`,children:`SQL`}),(0,z.jsx)(`pre`,{className:`mt-1.5 font-mono text-[14px] whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:e.sql})]}),(0,z.jsx)(`footer`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2.5`,children:e.status===`pending`?(0,z.jsxs)(z.Fragment,{children:[e.git&&t.isPending&&(0,z.jsx)(`p`,{role:`status`,className:`mr-auto text-[14px] text-muted-foreground`,children:kr()}),(0,z.jsx)(V,{variant:`outline`,disabled:t.isPending,onClick:()=>t.mutate(`discard`),children:Yi()}),(0,z.jsx)(V,{disabled:t.isPending,onClick:()=>t.mutate(`apply`),children:e.git?Or({count:r}):Ui({count:r})})]}):(0,z.jsxs)(`p`,{className:T(`text-[14px]`,e.status===`applied`?`text-ok`:e.status===`discarded`?`text-muted-foreground`:`text-err`),children:[ose[e.status](),e.stale&&`: ${e.stale.join(`, `)}`,e.error&&`: ${e.error}`]})})]})}var mse=`max-w-none min-w-0 [overflow-wrap:anywhere] [&_a]:underline [&_code]:font-mono [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:my-1.5 [&_pre]:overflow-auto [&_table]:text-[14px] [&_ul]:list-disc [&_ul]:pl-5`,hse={schema:Ge,query:We,get_records:Ve,propose_changes:He,propose_sql:He,propose_table:Ue,check:ze,web_search:Ke,code_execution:Be},G5=e=>hse[e]?.()??e;function gse({busy:e,last:t}){let n=t?.kind===`tool`&&t.status===`in_progress`?G5(t.title):null;return(0,z.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 text-[14px] text-muted-foreground`,children:e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-1`,children:[0,1,2].map(e=>(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground motion-safe:animate-pulse`,style:{animationDelay:`${e*200}ms`}},e))}),n?Ae({tool:n}):Re()]})})}function _se({item:e}){let t=G5(e.title),n=e.input,r=n?.sql??(e.title===`web_search`?n?.query:void 0);return(0,z.jsxs)(`details`,{className:`min-w-0 rounded-md border bg-panel px-2.5 py-1.5 text-[14px] text-muted-foreground`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer`,children:[t,e.status===`in_progress`&&` …`]}),e.input!==void 0&&(0,z.jsx)(`pre`,{className:`mt-1.5 font-mono text-[14px] whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:r??JSON.stringify(e.input,null,2)}),e.sources&&(0,z.jsx)(K5,{sources:e.sources})]})}var vse=e=>URL.parse(e)?.hostname||e;function K5({sources:e}){return(0,z.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:e.map(e=>(0,z.jsx)(`li`,{className:`min-w-0 truncate`,children:(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:e.url,children:e.title||vse(e.url)})},e.url))})}function yse({sources:e}){return(0,z.jsxs)(`details`,{className:`mt-2 text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer`,children:Ie({count:e.length})}),(0,z.jsx)(K5,{sources:e})]})}var q5=()=>s1.reset().catch(()=>{});function bse({current:e,onPick:t}){let[n,r]=(0,B.useState)(!1),{conversations:i,loading:a}=u1(n);return(0,z.jsxs)(S5,{open:n,onOpenChange:r,children:[(0,z.jsx)(C5,{asChild:!0,children:(0,z.jsxs)(V,{variant:`ghost`,className:`text-[14px]`,children:[(0,z.jsx)(ak,{className:`size-4`}),ue()]})}),(0,z.jsx)(w5,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)]`,children:i.length===0?(0,z.jsx)(T5,{disabled:!0,className:`text-[14px]`,children:a?bt():ve()}):i.map(n=>(0,z.jsxs)(T5,{"aria-current":n.id===e?`true`:void 0,className:`flex cursor-pointer flex-col items-stretch gap-0.5 py-2 aria-[current]:bg-panel-2`,onSelect:()=>t(n),children:[(0,z.jsx)(`span`,{className:`truncate text-[15px]`,children:n.title||qe()}),(0,z.jsxs)(`span`,{className:`flex gap-2 text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:qoe(n.updatedAt)}),(0,z.jsx)(`span`,{children:n.model})]})]},n.id))})]})}function J5({url:e}){return e?(0,z.jsx)(`a`,{href:e,className:`underline`,children:be()}):null}function xse(e){return e instanceof Sv&&e.body.code===`no_key`?me():e instanceof Error?e.message:String(e)}function Sse(){let e=G$(),t=K$(),n=t?.viewerKeys??!0,r=c1(),[i,a]=(0,B.useState)(()=>e?Y$(e,{viewerKeys:n}):null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),g=(0,B.useRef)(!1),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=l1(),b=new Set(r.items.flatMap(e=>e.kind===`proposal`?[e.proposal.id]:[])),x=y.filter(e=>!b.has(e.id));if((0,B.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented||e.isComposing||e.keyCode===229||document.querySelector(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], aside[data-record-drawer]`))return;let t=e.target instanceof HTMLElement?e.target:null;t&&t!==v.current&&t.closest(`input, textarea, select, [contenteditable]`)||v.current?.value.trim()||h1.close()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,B.useEffect)(()=>{_.current?.scrollTo?.({top:_.current.scrollHeight})},[r.items,r.busy]),!e)return null;let S=r.items.at(-1),C=n&&S?.kind===`error`&&S.code===`auth`,w=!n&&e.length===0,T=!w&&(o||i===null||C),E=async()=>{let e=u.trim();if(!(e===``||r.busy||g.current)){if(!i)s(!0);else{g.current=!0,h(!0),p(null);try{(!s1.id||r.closed)&&(await s1.reset(),await s1.start(i)),await s1.send(e),d(``)}catch(e){p(xse(e)),e instanceof Sv&&e.body.code===`no_key`&&s(!0)}finally{g.current=!1,h(!1)}}}};return(0,z.jsxs)($X,{layout:`docked`,widthKey:`yamlite-agent-width`,defaultWidth:420,resizeLabel:De(),"aria-label":fi(),children:[(0,z.jsxs)(eZ,{onClose:h1.close,className:`justify-between`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[!w&&(0,z.jsxs)(V,{variant:`ghost`,className:`min-w-0 shrink text-[14px]`,"aria-label":Ne(),"aria-expanded":T,onClick:()=>s(e=>!e),children:[(0,z.jsx)(pk,{className:`size-4`}),(0,z.jsx)(`span`,{className:`truncate`,children:i?`${e.find(e=>e.id===i.provider)?.name??i.provider} · ${i.model}`:Ne()})]}),(0,z.jsx)(bse,{current:s1.id,onPick:e=>{p(null),s1.open(e.id)}}),(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":Qe(),title:Qe(),onClick:()=>l(!0),children:(0,z.jsx)(lk,{className:`size-4`})}),c&&(0,z.jsx)(N5,{open:!0,onOpenChange:l})]}),(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,z.jsx)(V,{variant:`ghost`,className:`text-[14px]`,onClick:()=>{p(null),q5()},children:_e()})})]}),w&&(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-2 border-b p-3.5 text-[15px]`,children:[(0,z.jsx)(`p`,{children:t?.unavailable?ie():ye()}),(0,z.jsx)(J5,{url:t?.settingsUrl})]}),T&&(0,z.jsx)(Xoe,{viewerKeys:n,providers:e,initial:i,onSave:(e,t)=>{X$(e,t),a(e),s(!1),p(null),q5()}}),(0,z.jsxs)(`div`,{ref:_,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-3.5 text-[15px] leading-relaxed [&>*]:shrink-0`,children:[x.length>0&&(0,z.jsxs)(`section`,{"aria-label":xe(),className:`flex flex-col gap-3 border-b pb-3`,children:[(0,z.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:xe()}),(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:Se()}),x.map(e=>(0,z.jsx)(W5,{proposal:e},e.id))]}),r.items.length===0&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:L()}),r.items.map((e,r)=>e.kind===`user`?(0,z.jsx)(`p`,{className:`max-w-[85%] self-end rounded-xl rounded-br-sm bg-panel-2 px-3 py-2 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.text},r):e.kind===`agent`?(0,z.jsxs)(`div`,{className:mse,children:[(0,z.jsx)(j8,{remarkPlugins:[x5],disallowedElements:[`img`],unwrapDisallowed:!0,components:{a:({node:e,...t})=>(0,z.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer noopener`})},children:e.text}),e.sources&&(0,z.jsx)(yse,{sources:e.sources})]},r):e.kind===`tool`?(0,z.jsx)(_se,{item:e},e.id):e.kind===`proposal`?(0,z.jsx)(W5,{proposal:e.proposal},e.proposal.id):!n&&e.code===`auth`?(0,z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 rounded-md border border-err px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-err`,children:fe()}),(0,z.jsx)(J5,{url:t?.settingsUrl})]},r):(0,z.jsx)(`p`,{role:`alert`,className:`rounded-md border border-err px-3 py-2 text-err`,children:e.message},r)),(0,z.jsx)(gse,{busy:r.busy,last:r.items.at(-1)}),r.closed&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:le()}),f&&(0,z.jsx)(`div`,{role:`alert`,className:`rounded-md border border-err px-3 py-2 text-err`,children:(0,z.jsx)(`p`,{children:f})})]}),(0,z.jsx)(tZ,{children:(0,z.jsxs)(`form`,{className:`flex-1`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,z.jsx)(`textarea`,{ref:v,"aria-label":pe(),disabled:w,rows:3,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),E())},placeholder:Ce(),className:`w-full resize-none rounded-lg border bg-panel px-3 py-2.5 text-[16px] outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60`}),(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:Te()}),r.busy?(0,z.jsxs)(V,{type:`button`,variant:`outline`,onClick:()=>void s1.stop(),children:[(0,z.jsx)(_k,{className:`size-4`}),` `,Le()]}):(0,z.jsx)(V,{type:`submit`,disabled:w||m||u.trim()===``,children:Me()})]})]})})]})}var Cse={added:Ds,modified:ks,deleted:Os},wse={added:`text-ok`,modified:`text-warn`,deleted:`text-err`};function Y5({branch:e,open:t,onOpenChange:n}){let r=Sg(),{data:i,error:a}=V_({queryKey:[...O5,`default`],queryFn:k5.defaultChanges,enabled:t}),[o,s]=(0,B.useState)(new Set),[c,l]=(0,B.useState)(null),u=(i??[]).filter(e=>o.has(e.path)),d=u.some(e=>e.unsent),f=JSON.stringify(u.map(e=>e.path)),p=c===f,m=e=>{n(e),e||(h.reset(),s(new Set),l(null))},h=H_({mutationFn:()=>k5.restoreDefault(u.map(e=>e.path)),onSuccess:t=>{iv.success(_o({count:t.files.length,branch:e})),m(!1)},onSettled:()=>{l(null),r.invalidateQueries({queryKey:O5})}}),g=e=>s(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),_=h.error??a;return(0,z.jsx)(qk,{open:t,onOpenChange:m,children:(0,z.jsxs)(Qk,{className:`sm:max-w-2xl`,children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{className:`text-[18px]`,children:Ao({branch:e})}),(0,z.jsx)(rA,{className:`text-[14px]`,children:mo({branch:e})})]}),i?i.length===0?(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:bo({branch:e})}):(0,z.jsxs)(`fieldset`,{className:`flex max-h-[45vh] flex-col gap-2 overflow-auto rounded-md border p-3 text-[14px]`,children:[(0,z.jsx)(`legend`,{className:`px-1 text-[13px] text-muted-foreground`,children:Xo({count:u.length})}),j5(i).map(e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`div`,{className:`text-[12.5px] font-semibold text-muted-foreground`,children:e.table??as()}),e.changes.map(e=>(0,z.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md px-1 py-1`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":es({file:e.path}),checked:o.has(e.path),disabled:h.isPending,onChange:()=>g(e.path)}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[13.5px]`,children:e.path}),e.unsent&&(0,z.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-warn`,children:Po()}),(0,z.jsx)(`span`,{className:T(`ml-auto shrink-0 text-[12.5px]`,wse[e.status]),children:Cse[e.status]()})]},e.path))]},e.table??``))]}):!a&&(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:ts()}),_&&(0,z.jsx)(`p`,{role:`alert`,className:`text-[13px] text-err`,children:_.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>m(!1),children:gt()}),(0,z.jsxs)(V,{variant:p?`destructive`:`default`,disabled:u.length===0||h.isPending,onClick:()=>d&&!p?l(f):h.mutate(),children:[(0,z.jsx)(ak,{className:`size-4`}),h.isPending?xo():p?Do({count:u.length}):wo({count:u.length})]})]})]})})}var Tse={added:Ds,modified:ks,deleted:Os},Ese={added:`text-ok`,modified:`text-warn`,deleted:`text-err`},Dse=e=>e.records===null?{records:[],files:e.status===`added`?[]:[e.path]}:{records:e.table===null?[]:e.records.filter(e=>e.kind===`deleted`||e.fields.length>0).map(t=>({table:e.table,key:t.key})),files:[]},Ose=e=>e==null?`—`:typeof e==`string`?e:JSON.stringify(e);function kse({path:e,many:t}){let{data:n,error:r}=V_({queryKey:[`gitdiff`,e],queryFn:()=>k5.diff(e)});return r?(0,z.jsx)(`p`,{className:`text-[13px] text-err`,children:r.message}):n?(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.records.map(e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t&&(0,z.jsx)(`div`,{className:`font-mono text-[13px] font-semibold`,children:e.key}),e.fields.length===0?(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:Zo()}):(0,z.jsx)(WZ,{labels:[Bo(),rs()],format:Ose,rows:e.fields.map(e=>({field:e.field,a:e.from,b:e.to}))})]},e.key))}):(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:ts()})}function X5({table:e,record:t,busy:n,onRevert:r}){return t.kind===`added`?(0,z.jsx)(Z5,{label:Go({record:t.key}),confirm:Ho(),remove:!0,busy:n,onConfirm:()=>r({records:[{table:e,key:t.key,delete:!0}],files:[]})}):(0,z.jsx)(`button`,{type:`button`,"aria-label":ds({record:t.key}),title:ds({record:t.key}),disabled:n||t.kind===`modified`&&t.fields.length===0,className:`rounded p-1 text-muted-foreground hover:bg-panel-2 hover:text-foreground disabled:opacity-30`,onClick:()=>r({records:[{table:e,key:t.key}],files:[]}),children:(0,z.jsx)(Nk,{className:`size-4`})})}function Ase({change:e,busy:t,onRevert:n}){let r=e.status===`added`;return(0,z.jsx)(Z5,{label:r?Go({record:e.path}):ds({record:e.path}),confirm:r?Ho():cs(),remove:r,busy:t,onConfirm:()=>n({records:[],files:[e.path]})})}function Z5({label:e,confirm:t,remove:n=!1,busy:r,onConfirm:i}){let[a,o]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{r||o(!1)},[r]),a?(0,z.jsx)(V,{size:`sm`,variant:`destructive`,className:`h-6 px-2 text-[12.5px]`,autoFocus:!0,disabled:r,onBlur:()=>o(!1),onClick:i,children:t}):(0,z.jsx)(`button`,{type:`button`,"aria-label":e,title:e,disabled:r,className:T(`rounded p-1 text-muted-foreground hover:bg-panel-2 disabled:opacity-50`,n?`hover:text-err`:`hover:text-foreground`),onClick:()=>o(!0),children:n?(0,z.jsx)(Dk,{className:`size-4`}):(0,z.jsx)(Nk,{className:`size-4`})})}function Q5({label:e,kind:t,fields:n,action:r}){return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[13.5px]`,children:e}),n&&n.length>0&&(0,z.jsx)(`span`,{className:`min-w-0 truncate text-[12.5px] text-muted-foreground`,children:n.join(`, `)}),(0,z.jsx)(`span`,{className:T(`ml-auto shrink-0 text-[12.5px]`,Ese[t]),children:Tse[t]()}),(0,z.jsx)(`span`,{className:`flex min-w-7 shrink-0 justify-end`,children:r})]})}function jse({change:e,list:t,checked:n,busy:r,onToggle:i,onRevert:a}){let[o,s]=(0,B.useState)(!1),{table:c,records:l}=e,u=!t&&c!==null&&l?.length===1?l[0]:null;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-1 py-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":es({file:e.path}),checked:n,onChange:i}),l&&l.length>0?(0,z.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-label":Es({file:e.path}),className:`rounded p-0.5 text-muted-foreground hover:bg-panel-2`,onClick:()=>s(!o),children:(0,z.jsx)(hO,{className:T(`size-4 transition-transform`,o&&`rotate-90`)})}):(0,z.jsx)(`span`,{className:`w-5 shrink-0`}),u&&c?(0,z.jsx)(Q5,{label:u.key,kind:u.kind,fields:u.fields,action:(0,z.jsx)(X5,{table:c,record:u,busy:r,onRevert:a})}):(0,z.jsx)(Q5,{label:e.path,kind:e.status,action:l===null&&(0,z.jsx)(Ase,{change:e,busy:r,onRevert:a})})]}),!u&&c&&l&&l.length>0&&(0,z.jsx)(`div`,{className:`ml-12 flex flex-col gap-1`,children:l.map(e=>(0,z.jsx)(Q5,{label:e.key,kind:e.kind,fields:e.fields,action:(0,z.jsx)(X5,{table:c,record:e,busy:r,onRevert:a})},e.key))}),o&&(0,z.jsx)(`div`,{className:`mt-1 ml-12 border-t pt-2`,children:(0,z.jsx)(kse,{path:e.path,many:!u})})]})}function $5({git:e,open:t,onOpenChange:n}){let r=Sg(),{data:i}=ry(),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(new Set),[h,g]=(0,B.useState)(null),_=e.changes.map(e=>e.path).filter(e=>!p.has(e)),v=e.branch===e.defaultBranch,y=()=>void r.invalidateQueries({queryKey:O5}),b=V_({queryKey:[...O5,`pr`,e.branch],queryFn:k5.openPr,enabled:t&&!v,staleTime:3e4}),x=v?null:b.data??null,S=v||b.isSuccess||b.isError,C=(0,B.useRef)(0),w=G$(),T=K$(),D=w?Y$(w,{viewerKeys:T?.viewerKeys??!0}):null,O=H_({mutationFn:async e=>({...await k5.draft({paths:_,mode:x?`commit`:`pr`,locale:E(),...D}),at:e}),onSuccess:e=>{e.at===C.current&&(o(e.title),e.body!==void 0&&c(e.body))}}),k=H_({mutationFn:()=>k5.review({title:a.trim(),body:x?``:s,paths:_,...v&&l.trim()?{branch:l.trim()}:{}}),onSettled:y}),A=e=>void Yoe(e).then(y).catch(e=>iv.error(e instanceof Error?e.message:String(e))),j=H_({mutationFn:e=>k5.revert(e),onSuccess:({reverted:e,files:t})=>iv.success(bs({count:e.length+t.length}),t.length>0?{}:{action:{label:js(),onClick:()=>A(e)}}),onSettled:()=>{g(null),y()}}),M=k.isPending||j.isPending||O.isPending,N=e.changes.filter(e=>!p.has(e.path)).map(Dse),P={records:N.flatMap(e=>e.records),files:N.flatMap(e=>e.files)},F=P.records.length+P.files.length,ee=JSON.stringify(P),I=h===ee,te=e=>{m(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},ne=e=>{n(e),e||(k.reset(),j.reset(),O.reset(),C.current++,o(``),c(``),u(``),m(new Set),g(null))},re=e.changes.length===0;(0,B.useEffect)(()=>{re&&!k.data&&n(!1)},[re,k.data,n]);let ie=new Set(i?.tables.filter(e=>e.mode===`list`).map(e=>e.name)),ae=k.data,oe=k.error??j.error??O.error,se=oe instanceof Error?oe.message:ae?.error??null;return(0,z.jsx)(qk,{open:t,onOpenChange:ne,children:(0,z.jsxs)(Qk,{className:`sm:max-w-2xl`,onInteractOutside:e=>{e.target instanceof Element&&e.target.closest(`[data-sonner-toaster]`)&&e.preventDefault()},children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{className:`text-[18px]`,children:As()}),(0,z.jsx)(rA,{className:`text-[14px]`,children:v?ns():b.isPending?Fo():x?Io():Lo()}),x&&!ae&&(0,z.jsxs)(`a`,{href:x,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-[14px] font-semibold text-tomato hover:underline`,children:[is(),(0,z.jsx)(TO,{className:`size-4`})]})]}),ae?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 text-[15px]`,children:[!ae.error&&(0,z.jsx)(`p`,{children:Cs()}),ae.url&&(0,z.jsxs)(`a`,{href:ae.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 font-semibold text-tomato hover:underline`,children:[ae.created?is():Vo(),(0,z.jsx)(TO,{className:`size-4`})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`fieldset`,{className:`flex max-h-[45vh] flex-col gap-2 overflow-auto rounded-md border p-3 text-[14px]`,children:[(0,z.jsx)(`legend`,{className:`px-1 text-[13px] text-muted-foreground`,children:Xo({count:_.length})}),j5(e.changes).map(e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`div`,{className:`text-[12.5px] font-semibold text-muted-foreground`,children:e.table??as()}),e.changes.map(e=>(0,z.jsx)(jse,{change:e,list:e.table!==null&&ie.has(e.table),checked:!p.has(e.path),busy:M,onToggle:()=>te(e.path),onRevert:e=>j.mutate(e)},e.path))]},e.table??``))]}),v&&e.namesBranch&&(0,z.jsx)(Ik,{"aria-label":Ro(),placeholder:Ro(),value:l,onChange:e=>u(e.target.value),className:`font-mono text-[15px]`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(Ik,{"aria-label":x?zo():ss(),placeholder:x?zo():ss(),value:a,onChange:e=>o(e.target.value),className:`text-[15px]`}),D&&(0,z.jsxs)(V,{variant:`outline`,disabled:_.length===0||M||!v&&b.isPending,onClick:()=>O.mutate(C.current),children:[(0,z.jsx)(hk,{className:`size-4`}),O.isPending?Ko():R()]})]}),D&&(0,z.jsx)(`button`,{type:`button`,className:`self-end text-[13.5px] text-muted-foreground underline-offset-2 hover:underline`,onClick:()=>f(!0),children:qo()}),d&&(0,z.jsx)(N5,{open:!0,onOpenChange:f}),S&&!x&&(0,z.jsx)(uJ,{"aria-label":os(),placeholder:os(),value:s,onChange:e=>c(e.target.value),className:`min-h-20 text-[15px]`})]}),se&&(0,z.jsx)(`p`,{role:`alert`,className:`text-[13px] text-err`,children:se}),(0,z.jsx)(tA,{children:ae?(0,z.jsx)(V,{onClick:()=>ne(!1),children:_t()}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{variant:I?`destructive`:`outline`,className:`sm:mr-auto`,disabled:F===0||M,onClick:()=>P.files.length>0&&!I?g(ee):j.mutate(P),children:[(0,z.jsx)(Nk,{className:`size-4`}),I?_s({count:F}):ms({count:F})]}),(0,z.jsx)(V,{variant:`outline`,onClick:()=>ne(!1),children:gt()}),(0,z.jsx)(V,{disabled:a.trim()===``||_.length===0||M||!S,onClick:()=>k.mutate(),children:k.isPending?Ss():xs()})]})})]})})}function Mse(){let e=A5(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1),a=e?.restoresDefault===!0&&e.defaultBranch!==null;return Yv()||!e||e.changes.length===0&&!t&&!a?null:(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2.5`,children:[a&&(0,z.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 rounded-md border bg-background px-3 py-1.5 text-[13px] text-muted-foreground hover:text-foreground`,onClick:()=>i(!0),children:[(0,z.jsx)(ak,{className:`size-3.5`}),Tr({branch:e.defaultBranch??``})]}),e.changes.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:Qn({count:e.changes.length})}),(0,z.jsxs)(`button`,{type:`button`,disabled:e.branch===null,className:`flex items-center gap-1.5 rounded-md bg-tomato px-3 py-1.5 text-[13px] font-semibold text-[var(--y-on-accent)] hover:opacity-90 disabled:opacity-60`,onClick:()=>n(!0),children:[(0,z.jsx)(aO,{className:`size-3.5`}),Ar()]})]}),t&&(0,z.jsx)($5,{git:e,open:t,onOpenChange:n}),r&&e.defaultBranch&&(0,z.jsx)(Y5,{branch:e.defaultBranch,open:r,onOpenChange:i})]})}function Nse(){let e=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let t=JJ();if(t&&e.current)return e.current.append(t),()=>t.remove()},[]),(0,z.jsxs)(`footer`,{className:`app-footer flex min-h-[48px] flex-wrap items-center gap-x-3 gap-y-2 border-t bg-panel px-3 py-2 max-md:pb-[calc(8px+env(safe-area-inset-bottom))]`,children:[(0,z.jsx)(`div`,{ref:e,className:`app-footer-host min-w-0 flex-1`}),(0,z.jsx)(Mse,{})]})}function Pse({className:e,...t}){return(0,z.jsx)(zQ,{"data-slot":`command`,className:T(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function Fse({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,filter:a,value:o,onValueChange:s,...c}){return(0,z.jsxs)(qk,{...c,children:[(0,z.jsxs)($k,{className:`sr-only`,children:[(0,z.jsx)(nA,{children:e}),(0,z.jsx)(rA,{children:t})]}),(0,z.jsx)(Qk,{className:T(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,z.jsx)(Pse,{filter:a,value:o,onValueChange:s,className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function Ise({className:e,...t}){return(0,z.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,z.jsx)(dk,{className:`size-4 shrink-0 opacity-50`}),(0,z.jsx)(zQ.Input,{"data-slot":`command-input`,className:T(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function Lse({className:e,...t}){return(0,z.jsx)(zQ.List,{"data-slot":`command-list`,className:T(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function Rse({...e}){return(0,z.jsx)(zQ.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function e7({className:e,...t}){return(0,z.jsx)(zQ.Group,{"data-slot":`command-group`,className:T(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function t7({className:e,...t}){return(0,z.jsx)(zQ.Item,{"data-slot":`command-item`,className:T(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}var n7=!1,r7=new Set;function i7(e){n7=typeof e==`function`?e(n7):e;for(let e of r7)e()}var a7=()=>i7(!0),zse=e=>(r7.add(e),()=>{r7.delete(e)}),Bse=()=>(0,B.useSyncExternalStore)(zse,()=>n7),o7=`\0`,Vse=(e,t,n)=>e.startsWith(o7)?1:wQ(e,t,n),Hse=10,Use=10;function Wse(){let e=Bse(),t=Nh(),{data:n}=ry(),r=G$(),[i,a]=(0,B.useState)(``);(0,B.useEffect)(()=>{e||a(``)},[e]);let o=D$(i.trim(),200),s=g$(o),{data:c,isFetching:l}=C$(o,5),u=s&&c?x$(c.hits,o).slice(0,Hse):[],d=s&&c?[...new Map(c.hits.map(e=>[e.table,e.total])).values()].reduce((e,t)=>e+t,0):0,f=s&&(u.length>0||l),p=e=>`${o7}${e.table}${o7}${e.key}`,[m,h]=(0,B.useState)(``),g=u[0]?p(u[0]):null;(0,B.useEffect)(()=>{g&&h(g)},[g]);let _=()=>v(()=>t({to:`/search`,search:{q:o}}));(0,B.useEffect)(()=>{let e=e=>{e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),i7(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let v=e=>{i7(!1),e()};return(0,z.jsxs)(Fse,{open:e,onOpenChange:i7,filter:Vse,value:m,onValueChange:h,className:`sm:max-w-2xl`,children:[(0,z.jsx)(Ise,{placeholder:ft(),className:`max-md:pr-10`,value:i,onValueChange:a,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&u.length>0&&(e.preventDefault(),_())}}),(0,z.jsxs)(Lse,{className:`max-h-[min(480px,60vh)] max-md:max-h-none`,children:[!f&&(0,z.jsx)(Rse,{children:ct()}),f&&(0,z.jsxs)(e7,{heading:(0,z.jsxs)(`span`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:pt()}),d>0&&(0,z.jsx)(`span`,{children:Sl({count:d})})]}),forceMount:!0,children:[u.map(e=>(0,z.jsxs)(t7,{value:p(e),className:`gap-3`,onSelect:()=>v(()=>t({to:`/t/$table`,params:{table:e.table},search:{key:e.key}})),children:[(0,z.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border bg-panel text-muted-foreground`,children:(0,z.jsx)(xk,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-base font-semibold`,children:(0,z.jsx)(E$,{text:e.label??e.key,needle:o})}),e.label!==null&&(0,z.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:(0,z.jsx)(E$,{text:e.key,needle:o})}),(0,z.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:e.table})]}),e.value!==e.key&&e.value!==e.label&&(0,z.jsxs)(`span`,{className:`truncate text-sm text-muted-foreground`,children:[`${e.column}: `,(0,z.jsx)(T$,{value:e.value,needle:o,around:Use})]})]})]},`${e.table}${o7}${e.key}`)),u.length===0&&(0,z.jsx)(t7,{value:`${o7}searching`,disabled:!0,children:mt()}),u.length>0&&(0,z.jsxs)(t7,{value:`${o7}all`,className:`font-semibold text-tomato`,onSelect:_,children:[st({count:d}),(0,z.jsx)(tO,{className:`ml-auto size-4`,"aria-hidden":!0})]})]}),(0,z.jsx)(e7,{heading:Pi(),children:n?.tables.map(e=>(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/t/$table`,params:{table:e.name}})),children:e.name},e.name))}),n&&n.views.length>0&&(0,z.jsx)(e7,{heading:ht(),children:n.views.map(e=>(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/t/$table`,params:{table:e.name}})),children:e.name},e.name))}),n&&n.pages.length>0&&(0,z.jsx)(e7,{heading:_i(),children:n.pages.map(e=>(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/p/$page`,params:{page:e.name}})),children:e.title},e.name))}),(0,z.jsxs)(e7,{heading:Fi(),children:[(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/sql`})),children:ki()}),(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/erd`})),children:pi()}),!Yv()&&(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/sync`})),children:Ai()}),r!==null&&(0,z.jsx)(t7,{onSelect:()=>v(h1.open),children:fi()})]})]}),(0,z.jsx)(`div`,{className:`flex gap-4 border-t px-3.5 py-2 text-xs text-muted-foreground max-md:hidden`,children:[[`↑↓`,ut()],[`↵`,dt()],[`⌘↵`,lt()]].map(([e,t])=>(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`kbd`,{className:`mr-1 rounded border px-1 font-mono`,children:e}),t]},e))})]})}function s7(){return(0,B.useSyncExternalStore)(Tv.subscribe,Tv.expired)?(0,z.jsx)(`div`,{role:`alert`,className:`bg-err-soft px-4 py-2 text-[12px] text-err`,children:zl()}):null}function c7(){let e=iy(),t=Nh(),n=KJ();return(0,B.useEffect)(()=>e.listen(e=>{e.type===`conflict`&&iv.warning(Dt({table:e.table,key:e.key}),{description:e.winner===`file`?wt():Ct(),action:n?void 0:{label:Ot(),onClick:()=>void t({to:`/sync`})},duration:15e3})}),[e,t,n]),null}var Gse=[`TEXT`,`INTEGER`,`REAL`,`BOOLEAN`,`JSON`];function l7({open:e,onOpenChange:t,adopt:n}){let r=Sg(),i=Nh(),{connected:a}=ay(),{data:o}=ry(),s=(0,B.useId)(),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(n??``),[f,p]=(0,B.useState)(`files`),[m,h]=(0,B.useState)(`id`),[g,_]=(0,B.useState)([]),v=H_({mutationFn:()=>Uv.createTable({name:u,mode:f,key:m,columns:Object.fromEntries(g.filter(e=>e.name!==``).map(e=>[e.name,e.type])),group:c.trim()===``?void 0:c.trim()}),onSuccess:async()=>{t(!1),await r.invalidateQueries({queryKey:[`meta`]}),i({to:`/t/$table`,params:{table:u}})}}),y=lA(v.error),b=e=>y?.field===e?(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:y.message}):null;return(0,z.jsx)(qk,{open:e,onOpenChange:t,children:(0,z.jsxs)(Qk,{children:[(0,z.jsx)($k,{children:(0,z.jsx)(nA,{children:n?Ft({table:n}):cn()})}),(0,z.jsxs)(`label`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:[on(),(0,z.jsx)(Ik,{"aria-label":gn(),value:u,disabled:n!==void 0,onChange:e=>d(e.target.value),className:`mt-1 font-mono`})]}),b(`name`),(0,z.jsxs)(`fieldset`,{className:`flex gap-4 text-[12px]`,children:[(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`input`,{type:`radio`,checked:f===`files`,onChange:()=>p(`files`)}),` `,tn({name:u||`name`})]}),(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`input`,{type:`radio`,checked:f===`list`,onChange:()=>p(`list`)}),` `,an({name:u||`name`})]})]}),(0,z.jsxs)(`label`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:[Kt(),(0,z.jsx)(Ik,{"aria-label":Gt(),value:m,onChange:e=>h(e.target.value),className:`mt-1 font-mono`})]}),b(`key`),(0,z.jsxs)(`label`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:[Wt(),(0,z.jsx)(Ik,{"aria-label":ud(),list:s,value:c,onChange:e=>l(e.target.value),className:`mt-1`})]}),(0,z.jsx)(`datalist`,{id:s,children:Vk(o?.tables??[]).map(e=>(0,z.jsx)(`option`,{value:e},e))}),b(`group`),!n&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:Ht()}),g.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,z.jsx)(Ik,{"aria-label":Rt({n:t+1}),value:e.name,onChange:e=>_(g.map((n,r)=>r===t?{...n,name:e.target.value}:n)),className:`font-mono max-md:basis-full`}),(0,z.jsx)(`select`,{"aria-label":Vt({n:t+1}),className:`rounded border bg-background px-2 max-md:h-9 max-md:flex-1`,value:e.type,onChange:e=>_(g.map((n,r)=>r===t?{...n,type:e.target.value}:n)),children:Gse.map(e=>(0,z.jsx)(`option`,{children:e},e))}),(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":dn({n:t+1}),onClick:()=>_(g.filter((e,n)=>n!==t)),children:(0,z.jsx)(Fk,{className:`size-4`})})]},t)),(0,z.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>_([...g,{name:``,type:`TEXT`}]),children:kt()}),b(`columns`)]}),y&&y.field===null&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:y.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>t(!1),children:gt()}),(0,z.jsx)(V,{disabled:u===``||v.isPending||!a,title:a?void 0:yt(),onClick:()=>v.mutate(),children:Ut()})]})]})})}var Kse=_x,qse={left:`inset-y-0 left-0 h-dvh w-[82%] max-w-[320px] border-r animate-[y-slide-right_160ms_ease-out]`,bottom:`inset-x-0 bottom-0 max-h-dvh border-t animate-[y-slide-up_160ms_ease-out]`};function Jse({side:e,title:t,className:n,children:r,...i}){return(0,z.jsxs)(xx,{children:[(0,z.jsx)(Cx,{className:`fixed inset-0 z-50 bg-black/40`}),(0,z.jsxs)(Dx,{"aria-describedby":void 0,className:T(`fixed z-50 flex flex-col bg-panel shadow-xl outline-none`,qse[e],n),...i,children:[(0,z.jsx)(jx,{className:`sr-only`,children:t}),r]})]})}function Yse(e,t){let[,n,r]=e.split(`/`),i=r?decodeURIComponent(r):``;return n===`t`&&i?i:n===`p`&&i?t.find(e=>e.name===i)?.title??i:n===`sql`?ki():n===`sync`?Ai():n===`erd`?pi():`yamlite`}var Xse={toDb:{symbol:`M`,tone:`warn`,detail:()=>`file → DB`},toFile:{symbol:`M`,tone:`warn`,detail:()=>`DB → file`},deleteDb:{symbol:`−`,tone:`err`,detail:te},deleteFile:{symbol:`−`,tone:`err`,detail:ne}};function Zse(e){let t=[];for(let n of e)if(n.type===`sync`){n.ok||t.push({at:n.at,symbol:`✗`,tone:`err`,text:n.table,detail:n.error??re()});for(let e of n.changes){let{detail:r,...i}=Xse[e.op];t.push({at:n.at,...i,detail:r(),text:`${n.table} / ${e.key}`})}}else n.type===`conflict`?t.push({at:n.at,symbol:`⚠`,tone:`err`,text:`${n.table} / ${n.key}`,detail:I({winner:n.winner})}):n.type===`error`?t.push({at:n.at,symbol:`✗`,tone:`err`,text:n.table??`yamlite`,detail:n.message}):t.push({at:n.at,symbol:`↻`,tone:`muted`,text:`yamlite.yaml`,detail:P()});return t.reverse()}function u7(e,t=new Set){return Object.entries(e).flatMap(([e,n])=>n.map(n=>{let r=n.indexOf(`: `),i=r>0?n.slice(0,r):``;if(i===``||i.includes(` `))return{table:e,key:null,view:null,text:n};let a=n.slice(r+2);return t.has(i)?{table:e,key:null,view:i,text:a}:{table:e,key:i,view:null,text:a}}))}function Qse(e){let t=new Map;for(let n of e)n.key!==null&&t.set(n.key,[...t.get(n.key)??[],n.text]);return t}function $se(e,t){let n=new Map;for(let r of u7(e,t)){let e=r.view??r.table;n.set(e,(n.get(e)??0)+1)}return n}var ece=!1,d7=()=>ece;function f7(e,t){return t.value===null?{col:e.column,op:`null`}:{col:e.column,op:e.json?`has`:`eq`,value:t.value}}function tce(e,t,n){if(e.length!==1)return!1;let[r]=e,i=f7(t,n);return r.col===i.col&&r.op===i.op&&r.value===i.value}var nce=(e,t)=>(e.captures??[]).some(e=>e.column===t);function rce(e,t){if(Object.hasOwn(e.columns,t))return[t];let[n,...r]=t.split(`.`);return!n||r.length===0||r.some(e=>e===``)?null:Object.hasOwn(e.columns,n)&&e.columns[n]===`JSON`?[n,...r]:null}var ice=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function p7(e,t,n){let[r,...i]=t;return i.length===0?{...e,[r]:n}:{...e,[r]:p7(ice(e[r])?e[r]:{},i,n)}}function ace(e,t){let n={};for(let r of t){if(r.col===e.key||nce(e,r.col))continue;let t=rce(e,r.col);t!==null&&(r.op===`eq`?n=p7(n,t,r.value):r.op===`has`&&(n=p7(n,t,t.length>1?r.value:[r.value])))}return n}function oce(e,t){let n=[...e.captures??[]].sort((e,t)=>e.segment-t.segment),r=``;for(let[e,i]of n.entries()){if(i.segment!==e)break;let n=t.find(e=>e.col===i.column&&e.op===`eq`);if(!n)break;r+=`${String(n.value)}/`}return r}function sce({className:e}){return(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 64 64`,"aria-hidden":`true`,className:e,children:[(0,z.jsx)(`rect`,{width:`64`,height:`64`,rx:`15`,fill:`#e5484d`}),(0,z.jsx)(`path`,{d:`M15 19L27 38M39 19L22 50`,stroke:`#fff7ed`,strokeWidth:`7`,strokeLinecap:`round`,fill:`none`}),(0,z.jsx)(`circle`,{cx:`48`,cy:`29`,r:`4.5`,fill:`#1c1b29`}),(0,z.jsx)(`circle`,{cx:`48`,cy:`44`,r:`4.5`,fill:`#fff7ed`})]})}var m7=`flex items-center gap-2 rounded-md px-2.5 py-1.5 mx-1.5 text-[13px] hover:bg-panel-2 max-md:py-2.5 max-md:text-[15px]`,h7={className:T(m7,`bg-tomato text-[var(--y-on-accent)] font-semibold hover:bg-tomato [&>[data-count]]:text-current [&>[data-count]]:opacity-80`)};function g7({count:e,fallback:t}){return e===0?t:(0,z.jsxs)(`span`,{role:`img`,"aria-label":Ri({count:e}),title:Ri({count:e}),className:`flex shrink-0 items-center gap-0.5 rounded-full bg-warn-soft px-1 text-[10.5px] font-semibold text-warn`,children:[(0,z.jsx)(kk,{className:`size-3`}),e]})}function _7({onNewTable:e,onSearch:t}){let{data:n}=ry(),r=G$(),{warnings:i,connected:a}=ay(),o=Yv(),{data:s}=V_({queryKey:[`conflicts`],queryFn:Uv.conflicts,enabled:!o}),c=s?.conflicts.length??0,l=new Set(n?.views.map(e=>e.name)),[u,d]=Wk(),[f,p]=Gk(),m=bg({select:e=>e.matches.find(e=>e.routeId===`/t/$table`)}),h=m?.params?.table,g=m?.search?.filter??[],_=n?.views.find(e=>e.name===h),v=e=>{let t=e.split;return t!==null&&h===e.name?t.items.find(e=>tce(g,t,e)):void 0},y=_?.table??n?.tables.find(e=>v(e)!==void 0)?.name??null,[b,x]=(0,B.useState)(null);b!==null&&b!==y&&x(null);let S=e=>{let t=u7({[e.name]:i[e.name]??[]},l),r=e=>t.filter(t=>t.view===e).length,a=e.split,o=n?.views.filter(t=>t.table===e.name)??[],s=v(e),c=a!==null&&a.items.length>0||o.length>0,u=c&&(f.has(e.name)||y===e.name&&b!==e.name);return(0,z.jsxs)(B.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center`,children:[(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.name},className:T(m7,`min-w-0 flex-1`),activeProps:s?{}:{className:T(h7.className,`min-w-0 flex-1`)},children:[(0,z.jsx)(g7,{count:r(null),fallback:(0,z.jsx)(xk,{className:`size-3.5 opacity-70`})}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`span`,{"data-count":!0,className:`ml-auto text-[11px] text-muted-foreground tabular-nums max-md:text-[12.5px]`,children:e.count})]}),c&&(0,z.jsx)(`button`,{type:`button`,"aria-label":Ni({table:e.name}),"aria-expanded":u,className:`mr-1.5 rounded-md p-1 text-muted-foreground hover:bg-panel-2 max-md:p-2`,onClick:()=>{y===e.name?u?(f.has(e.name)&&p(e.name),x(e.name)):x(null):p(e.name)},children:(0,z.jsx)(hO,{className:T(`size-3.5 transition-transform`,u&&`rotate-90`)})})]}),u&&a?.items.map(t=>(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.name},search:{filter:[f7(a,t)]},className:T(t===s?h7.className:m7,`min-w-0`),activeProps:{},style:{paddingLeft:`24px`},children:[(0,z.jsx)(LO,{className:`size-3.5 shrink-0 opacity-70`}),(0,z.jsx)(`span`,{className:`truncate`,children:t.value===null?Oi():String(t.value)}),(0,z.jsx)(`span`,{"data-count":!0,className:`ml-auto text-[11px] text-muted-foreground tabular-nums max-md:text-[12.5px]`,children:t.count})]},JSON.stringify(t.value))),u&&o.map(e=>(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.name},className:m7,activeProps:h7,style:{paddingLeft:`${10+e.depth*14}px`},children:[(0,z.jsx)(g7,{count:r(e.name),fallback:(0,z.jsx)(NO,{className:`size-3.5 shrink-0 opacity-70`})}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`span`,{"data-count":!0,className:`ml-auto text-[11px] text-muted-foreground tabular-nums max-md:text-[12.5px]`,children:e.count})]},e.name))]},e.name)};return(0,z.jsxs)(`aside`,{className:`flex h-full min-h-0 flex-col border-r bg-panel`,"aria-label":Ei(),children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2 px-3.5 pt-3.5 pb-2.5 text-base font-bold tracking-tight`,children:!d7()&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(sce,{className:`size-6`}),`YAMLite`,(0,z.jsx)(cce,{})]})}),(0,z.jsxs)(`div`,{className:`mx-2.5 mb-2 flex gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 justify-between rounded-md border bg-background px-2 py-1.5 text-[12px] text-muted-foreground max-md:py-2.5 max-md:text-[14px]`,onClick:()=>{t?.(),a7()},children:[(0,z.jsx)(`span`,{children:Ti()}),(0,z.jsx)(`kbd`,{className:`rounded border px-1 font-mono text-[10px] max-md:hidden`,children:`⌘K`})]}),r!==null&&(0,z.jsx)(`button`,{type:`button`,"aria-label":fi(),title:fi(),className:`grid place-items-center rounded-md border bg-background px-2 hover:bg-panel-2 max-md:px-3`,onClick:()=>{if(!t)return h1.toggle();t(),h1.open()},children:(0,z.jsx)(hk,{className:`size-4`})})]}),(0,z.jsx)(`div`,{className:`px-3.5 pt-2.5 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase max-md:text-[12px]`,children:Pi()}),(0,z.jsxs)(`nav`,{className:`flex flex-col gap-px overflow-auto`,children:[n&&Bk(n.tables).map(({group:e,tables:t})=>{if(e===null)return(0,z.jsx)(B.Fragment,{children:t.map(S)},``);let n=!u.has(e);return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e,className:`flex flex-col gap-px`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`mx-1.5 mt-1.5 flex items-center gap-1 rounded-md px-1.5 py-1 text-[11.5px] font-semibold text-muted-foreground hover:bg-panel-2 max-md:py-2 max-md:text-[13px]`,onClick:()=>d(e),children:[(0,z.jsx)(hO,{className:T(`size-3 transition-transform`,n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`truncate`,children:e})]}),n&&t.map(S)]},`g:${e}`)}),!o&&(0,z.jsxs)(`button`,{type:`button`,disabled:!a,title:a?void 0:yt(),className:T(m7,`text-muted-foreground disabled:opacity-50`),onClick:e,children:[(0,z.jsx)(rk,{className:`size-3.5`}),` `,gi()]})]}),n&&n.pages.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3.5 pt-2.5 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase max-md:text-[12px]`,children:_i()}),(0,z.jsx)(`nav`,{className:`flex flex-col gap-px`,children:n.pages.map(e=>(0,z.jsxs)(Yh,{to:`/p/$page`,params:{page:e.name},className:m7,activeProps:h7,children:[(0,z.jsx)(FO,{className:`size-3.5 opacity-70`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.title})]},e.name))})]}),(0,z.jsx)(`div`,{className:`px-3.5 pt-2.5 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase max-md:text-[12px]`,children:Fi()}),(0,z.jsxs)(`nav`,{className:`flex flex-col gap-px`,children:[(0,z.jsxs)(Yh,{to:`/sql`,className:m7,activeProps:h7,children:[(0,z.jsx)(Tk,{className:`size-3.5 opacity-70`}),` `,ki()]}),(0,z.jsxs)(Yh,{to:`/erd`,className:m7,activeProps:h7,children:[(0,z.jsx)(qO,{className:`size-3.5 opacity-70`}),` `,pi()]}),!o&&(0,z.jsxs)(Yh,{to:`/sync`,className:m7,activeProps:h7,children:[(0,z.jsx)(ZD,{className:`size-3.5 opacity-70`}),` `,Ai(),c>0&&(0,z.jsx)(`span`,{className:`ml-auto rounded-full bg-err-soft px-1.5 text-[10.5px] font-semibold text-err`,children:c})]})]}),!o&&(0,z.jsx)(lce,{})]})}function cce(){let{data:e}=ry(),t=e?.root??``,n=t.split(/[\\/]/).filter(Boolean).at(-1)??t;return(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":Ci(),className:`ml-auto flex min-w-0 items-center gap-0.5 rounded px-1 font-mono text-[11px] font-normal text-muted-foreground hover:bg-panel-2 max-md:text-[12.5px]`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:n}),(0,z.jsx)(dO,{className:`size-3 shrink-0`})]})}),(0,z.jsxs)(zk,{align:`end`,className:`w-72 text-[13px]`,children:[(0,z.jsx)(`div`,{className:`font-mono text-[12px] break-all text-muted-foreground`,children:t}),(0,z.jsxs)(`dl`,{className:`mt-2.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:bi()}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:e?.configFile}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:xi()}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:e?.db}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Pi()}),(0,z.jsx)(`dd`,{children:e?.tables.length??0}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Si()}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:location.host})]})]})]})}function lce(){let e=A5(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1);if(!e)return null;let a=e.changes.length;return(0,z.jsxs)(`div`,{className:`mt-auto border-t px-3.5 py-2.5 text-[12px] max-md:pb-[calc(0.625rem+env(safe-area-inset-bottom))] max-md:text-[13.5px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,z.jsx)(DO,{className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate font-mono`,children:e.branch??cr()}),(0,z.jsx)(`span`,{children:`·`}),a>0?(0,z.jsx)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:Qn({count:a})}):(0,z.jsx)(`span`,{className:`shrink-0`,children:dr()})]}),(0,z.jsxs)(`button`,{type:`button`,disabled:a===0||e.branch===null,className:T(`mt-2 flex w-full items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] max-md:py-2.5 max-md:text-[15px]`,a>0?`bg-tomato font-semibold text-[var(--y-on-accent)] hover:opacity-90`:`border bg-background text-muted-foreground disabled:opacity-60`),onClick:()=>n(!0),children:[(0,z.jsx)(aO,{className:`size-3.5`}),Ar()]}),e.restoresDefault&&e.defaultBranch&&(0,z.jsxs)(`button`,{type:`button`,className:`mt-1.5 flex w-full items-center justify-center gap-1.5 rounded-md border bg-background py-1.5 text-[13px] text-muted-foreground hover:text-foreground max-md:py-2.5 max-md:text-[15px]`,onClick:()=>i(!0),children:[(0,z.jsx)(ak,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`truncate`,children:Tr({branch:e.defaultBranch})})]}),t&&(0,z.jsx)($5,{git:e,open:t,onOpenChange:n}),r&&e.defaultBranch&&(0,z.jsx)(Y5,{branch:e.defaultBranch,open:r,onOpenChange:i})]})}var v7=`grid size-10 shrink-0 place-items-center rounded-md hover:bg-panel-2`;function uce({onNewTable:e}){let[t,n]=(0,B.useState)(!1),{data:r}=ry(),i=G$(),a=A5(),[o,s]=(0,B.useState)(!1),c=a?.branch?a.changes.length:0,l=bg({select:e=>e.location.pathname});return(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border-b bg-background px-2 pt-[env(safe-area-inset-top)]`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":mi(),className:v7,onClick:()=>n(!0),children:(0,z.jsx)(VO,{className:`size-5`})}),(0,z.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-[16px] font-semibold`,children:Yse(l,r?.pages??[])}),(0,z.jsx)(`button`,{type:`button`,"aria-label":wi(),className:v7,onClick:a7,children:(0,z.jsx)(dk,{className:`size-5`})}),i!==null&&(0,z.jsx)(`button`,{type:`button`,"aria-label":fi(),className:v7,onClick:h1.open,children:(0,z.jsx)(hk,{className:`size-5`})}),a&&c>0&&(0,z.jsxs)(`button`,{type:`button`,"aria-label":`${Ar()} (${Qn({count:c})})`,className:`${v7} relative`,onClick:()=>s(!0),children:[(0,z.jsx)(aO,{className:`size-5`}),(0,z.jsx)(`span`,{className:`absolute top-1 right-1 min-w-4 rounded-full bg-tomato px-1 text-[10.5px] leading-4 font-semibold text-[var(--y-on-accent)]`,children:c})]}),a&&o&&(0,z.jsx)($5,{git:a,open:o,onOpenChange:s}),(0,z.jsx)(Kse,{open:t,onOpenChange:n,children:(0,z.jsx)(Jse,{side:`left`,title:mi(),onClick:e=>e.target instanceof Element&&e.target.closest(`a`)&&n(!1),children:(0,z.jsx)(_7,{onSearch:()=>n(!1),onNewTable:()=>{n(!1),e()}})})})]})}function dce({...e}){return(0,z.jsx)(fE,{"data-slot":`select`,...e})}function fce({...e}){return(0,z.jsx)(gE,{"data-slot":`select-value`,...e})}function pce({className:e,size:t=`default`,children:n,...r}){return(0,z.jsxs)(mE,{"data-slot":`select-trigger`,"data-size":t,className:T(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,z.jsx)(_E,{asChild:!0,children:(0,z.jsx)(dO,{className:`size-4 opacity-50`})})]})}function mce({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,z.jsx)(bE,{children:(0,z.jsxs)(SE,{"data-slot":`select-content`,className:T(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,z.jsx)(gce,{}),(0,z.jsx)(PE,{className:T(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,z.jsx)(_ce,{})]})})}function hce({className:e,children:t,...n}){return(0,z.jsxs)(RE,{"data-slot":`select-item`,className:T(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,z.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(HE,{children:(0,z.jsx)(lO,{className:`size-4`})})}),(0,z.jsx)(BE,{children:t})]})}function gce({className:e,...t}){return(0,z.jsx)(WE,{"data-slot":`select-scroll-up-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(pO,{className:`size-4`})})}function _ce({className:e,...t}){return(0,z.jsx)(KE,{"data-slot":`select-scroll-down-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(dO,{className:`size-4`})})}var vce={en:`English`,ja:`日本語`};function yce(){let e=E();return(0,z.jsxs)(dce,{value:e,onValueChange:t=>t!==e&&i(t),children:[(0,z.jsxs)(pce,{size:`sm`,"aria-label":di(),className:`h-6 gap-1 border-0 px-1.5 text-[11px] shadow-none max-md:size-10 max-md:justify-center max-md:p-0 max-md:[&>[data-slot=select-value]]:hidden max-md:[&>svg:last-child]:hidden`,children:[(0,z.jsx)(jO,{className:`size-3.5 max-md:size-4.5`}),(0,z.jsx)(fce,{})]}),(0,z.jsx)(mce,{position:`popper`,align:`end`,children:o.map(e=>(0,z.jsx)(hce,{value:e,lang:e,children:vce[e]},e))})]})}var bce={light:Td,dark:wd,system:Ed};function xce(){let{connected:e,lastSyncAt:t,warnings:n}=ay(),{data:r}=ry(),i=qv(),{data:a}=V_({queryKey:[`conflicts`],queryFn:Uv.conflicts,enabled:i===null}),[o,s]=(0,B.useState)(Date.now()),[c,l]=(0,B.useState)(x);(0,B.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let u=Object.values(n).reduce((e,t)=>e+t.length,0),d=a?.conflicts.length??0,f=c===`system`?UO:c===`light`?yk:GO;return(0,z.jsxs)(`footer`,{className:`flex h-[30px] items-center gap-4 border-t bg-panel px-3 text-[11px] text-muted-foreground max-md:h-[calc(40px+env(safe-area-inset-bottom))] max-md:gap-3 max-md:pb-[env(safe-area-inset-bottom)] max-md:text-[12px]`,children:[i?(0,z.jsx)(`span`,{children:hu({at:i.generatedAt.slice(0,16).replace(`T`,` `)})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,"aria-live":`polite`,children:[(0,z.jsx)(`span`,{className:`size-[7px] rounded-full ${e?`bg-ok`:`bg-err`}`}),e?d7()?cu():(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`max-md:hidden`,children:wu({root:r?.root??``})}),(0,z.jsx)(`span`,{className:`md:hidden`,children:cu()})]}):lu()]}),(0,z.jsx)(`span`,{className:`max-md:hidden`,children:fu({ago:Joe(t,o)})}),!d7()&&(0,z.jsx)(`span`,{className:`max-md:hidden`,children:location.host})]}),(0,z.jsxs)(`span`,{className:`ml-auto flex items-center gap-3.5`,children:[u>0&&(i?(0,z.jsx)(`span`,{className:`text-warn`,children:xu({count:u})}):(0,z.jsx)(Yh,{to:`/sync`,className:`text-warn hover:underline`,children:xu({count:u})})),d>0&&(0,z.jsx)(`span`,{className:`text-err`,children:su({count:d})}),(0,z.jsx)(yce,{}),(0,z.jsx)(`button`,{type:`button`,"aria-label":vu({theme:bce[c]()}),className:`rounded p-1 hover:bg-panel-2 max-md:grid max-md:size-10 max-md:place-items-center`,onClick:()=>{let e=v(c);C(e),l(e)},children:(0,z.jsx)(f,{className:`size-3.5 max-md:size-4.5`})})]})]})}function Sce(){return WJ()?(0,z.jsx)(GJ.Provider,{value:!0,children:(0,z.jsx)(Cce,{})}):(0,z.jsx)(wce,{})}function y7(){let{configError:e}=ay();return e?(0,z.jsx)(`div`,{role:`alert`,className:`bg-warn-soft px-4 py-2 text-[12px] text-warn`,children:Nl({error:e})}):null}function Cce(){let e=OX();return(0,z.jsxs)(`div`,{className:`grid h-[var(--y-shell-h,100dvh)] grid-cols-1 grid-rows-[auto_1fr_auto]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(s7,{}),(0,z.jsx)(y7,{})]}),(0,z.jsx)(`main`,{className:`flex min-h-0 min-w-0`,children:(0,z.jsx)(dg,{})}),(0,z.jsx)(Nse,{}),(0,z.jsx)(B$,{position:e?`top-center`:`bottom-right`}),(0,z.jsx)(c7,{})]})}function wce(){let[e,t]=(0,B.useState)(!1),n=OX(),r=G$(),i=g1()&&r!==null,[a,o]=qX(`yamlite-sidebar-width`,220,WX);return(0,z.jsxs)(`div`,{className:`grid h-[var(--y-shell-h,100dvh)] grid-cols-1 grid-rows-[auto_1fr_auto]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(s7,{}),(0,z.jsx)(y7,{}),n&&(0,z.jsx)(uce,{onNewTable:()=>t(!0)})]}),(0,z.jsxs)(`div`,{className:`grid min-h-0 grid-cols-1`,style:n?void 0:{gridTemplateColumns:`${a}px 1fr`},children:[!n&&(0,z.jsxs)(`div`,{className:`relative min-h-0`,children:[(0,z.jsx)(_7,{onNewTable:()=>t(!0)}),(0,z.jsx)(ZX,{width:a,label:Di(),onResize:o,edge:`right`,bounds:WX})]}),(0,z.jsxs)(`main`,{className:`flex min-h-0 min-w-0`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:(0,z.jsx)(dg,{})}),i&&(0,z.jsx)(Sse,{})]})]}),(0,z.jsx)(xce,{}),(0,z.jsx)(Wse,{}),e&&(0,z.jsx)(l7,{open:!0,onOpenChange:t}),(0,z.jsx)(B$,{position:n?`top-center`:`bottom-right`}),(0,z.jsx)(c7,{})]})}var Tce=36,b7=1,x7=2,S7=3,C7=4,Ece=5,Dce=6,Oce=7,kce=8,Ace=9,jce=10,Mce=11,Nce=12,Pce=13,Fce=14,Ice=15,Lce=16,Rce=17,w7=18,zce=19,T7=20,E7=21,D7=22,Bce=23,Vce=24;function O7(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function Hce(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function k7(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function Uce(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue scan;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function Wce(e,t){let n=`[{<(`.indexOf(String.fromCharCode(t)),r=n<0?t:`]}>)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function A7(e,t){for(;e.next==95||O7(e.next);)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Gce(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),k7(e,t,!1)}else A7(e)}function j7(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function M7(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function N7(e){for(;!(e.next<0||e.next==10);)e.advance()}function P7(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var F7=` \r
|
|
124
|
-
`;function I7(e,t,n){let r=Object.create(null);r.true=r.false=Ece,r.null=r.unknown=Dce;for(let t of e.split(` `))t&&(r[t]=T7);for(let e of t.split(` `))e&&(r[e]=E7);for(let e of(n||``).split(` `))e&&(r[e]=Vce);return r}var L7={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:`*+-%<>!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:I7(`absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone `,`array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying `)};function Kce(e,t,n,r){let i={};for(let t in L7)i[t]=(e.hasOwnProperty(t)?e:L7)[t];return t&&(i.words=I7(t,n||``,r)),i}function R7(e){return new ZA(t=>{let{next:n}=t;if(t.advance(),P7(n,F7)){for(;P7(t.next,F7);)t.advance();t.acceptToken(Tce)}else if(n==36&&e.doubleDollarQuotedStrings){let e=A7(t,``);t.next==36&&(t.advance(),Uce(t,e),t.acceptToken(S7))}else if(n==39||n==34&&e.doubleQuotedStrings)k7(t,n,e.backslashEscapes),t.acceptToken(S7);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)N7(t),t.acceptToken(b7);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))N7(t),t.acceptToken(b7);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(x7)}else if((n==101||n==69)&&t.next==39)t.advance(),k7(t,39,!0),t.acceptToken(S7);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),k7(t,39,e.backslashEscapes),t.acceptToken(S7);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),k7(t,39,e.backslashEscapes),t.acceptToken(S7);break}if(!O7(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!P7(t.peek(1),F7)){let e=t.peek(1);t.advance(2),Wce(t,e),t.acceptToken(S7)}else if(P7(n,e.identifierQuotes))k7(t,n==91?93:n,!1),t.acceptToken(zce);else if(n==40)t.acceptToken(Oce);else if(n==41)t.acceptToken(kce);else if(n==123)t.acceptToken(Ace);else if(n==125)t.acceptToken(jce);else if(n==91)t.acceptToken(Mce);else if(n==93)t.acceptToken(Nce);else if(n==59)t.acceptToken(Pce);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),j7(t),t.acceptToken(D7);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(k7(t,n,e.backslashEscapes),t.acceptToken(Bce)):(j7(t,n),t.acceptToken(D7))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();Hce(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(C7)}else if(n==46&&t.next>=48&&t.next<=57)M7(t,!0),t.acceptToken(C7);else if(n==46)t.acceptToken(Fce);else if(n>=48&&n<=57)M7(t,!1),t.acceptToken(C7);else if(P7(n,e.operatorChars)){for(;P7(t.next,e.operatorChars);)t.advance();t.acceptToken(Ice)}else if(P7(n,e.specialVar))t.next==n&&t.advance(),Gce(t),t.acceptToken(Rce);else if(n==58||n==44)t.acceptToken(Lce);else if(O7(n)){let r=A7(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?w7:e.words[r.toLowerCase()]??w7)}})}var z7=R7(L7),qce=oj.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,z7],topRules:{Script:[0,25]},tokenPrec:0});function B7(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function V7(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function H7(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Jce(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)H7(r)&&n.push(V7(e,r));return n}return[V7(e,t)]}function U7(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=B7(t);if(!H7(r))return n;n.unshift(V7(e,r)),t=B7(r)}}function Yce(e,t){let n=WB(e).resolveInner(t,-1),r=Zce(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:U7(e.doc,B7(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:U7(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Xce=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Zce(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&H7(t.nextSibling))o=V7(e,t.nextSibling);else if(n&&Xce.has(n))break;else a&&H7(t)&&(o=V7(e,t));o&&(r||=Object.create(null),r[o]=Jce(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Qce(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var $ce=/^\w*$/,ele=/^[`'"\[]?\w*[`'"\]]?$/;function W7(e){return e.self&&typeof e.self.label==`string`}var tle=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(G7(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?G7(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):W7(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;W7(n)&&(r=n.self,n=n.children);for(let e=0;e<i.length;e++)r&&e==i.length-1&&a.addCompletion(r),a=a.child(i[e].replace(/\\\./g,`.`));a.addNamespace(n)}}};function G7(e,t,n,r){return RegExp(`^[a-z_][a-z_\\d]*$`,r?`i`:``).test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+K7(n)}}function K7(e){return e===`[`?`]`:e}function nle(e,t,n,r,i,a){let o=new tle(a?.spec.identifierQuotes?.[0]||`"`,!!a?.spec.caseInsensitiveIdentifiers),s=i?o.child(i):null;return o.addNamespace(e),t&&(s||o).addCompletions(t),n&&o.addCompletions(n),s&&o.addCompletions(s.list),r&&o.addCompletions((s||o).child(r).list),e=>{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=Yce(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=K7(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Qce(t,r,u),validFor:ele}}return{from:n,options:u,validFor:$ce}}}function rle(e){return e==E7?`type`:e==T7?`keyword`:`variable`}function ile(e,t,n){return cG([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],sG(Object.keys(e).map(r=>n(t?r.toUpperCase():r,rle(e[r])))))}var ale=qce.configure({props:[iV.add({Statement:cV()}),uV.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),dj({Keyword:W.keyword,Type:W.typeName,Builtin:W.standard(W.name),Bits:W.number,Bytes:W.string,Bool:W.bool,Null:W.null,Number:W.number,String:W.string,Identifier:W.name,QuotedIdentifier:W.special(W.string),SpecialVar:W.special(W.name),LineComment:W.lineComment,BlockComment:W.blockComment,Operator:W.operator,"Semi Punctuation":W.punctuation,"( )":W.paren,"{ }":W.brace,"[ ]":W.squareBracket})]}),ole=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=Kce(t,t.keywords,t.types,t.builtin),r=UB.define({name:`sql`,parser:ale.configure({tokenizers:[{from:z7,to:R7(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}});return new e(n,r,t)}};function sle(e,t){return{label:e,type:t,boost:-1}}function cle(e,t=!1,n){return ile(e.dialect.words,t,n||sle)}function lle(e){return e.schema?nle(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||q7):()=>null}function ule(e){return e.schema?(e.dialect||q7).language.data.of({autocomplete:lle(e)}):[]}function dle(e={}){let t=e.dialect||q7;return new QB(t.language,[ule(e),t.language.data.of({autocomplete:cle(t,e.upperCaseKeywords,e.keywordCompletion)})])}var q7=ole.define({}),J7=`yamlite-sql-history`,fle=50;function Y7(){try{let e=JSON.parse(localStorage.getItem(J7)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function ple(e){let t=[e,...Y7().filter(t=>t!==e)].slice(0,fle);try{localStorage.setItem(J7,JSON.stringify(t))}catch{}return t}function X7(e,t=!0,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i],o=e[i+1];if(a===`-`&&o===`-`){let t=e.indexOf(`
|
|
125
|
-
`,i);i=t<0?e.length:t,r+=` `}else if(a===`/`&&o===`*`){let t=e.indexOf(`*/`,i+2);i=t<0?e.length:t+2,r+=` `}else if(a===`'`||a===`"`||a==="`"||a===`[`){let o=a===`[`?`]`:a,s=i+1;for(;s<e.length;s++)if(e[s]===o){if(o!==`]`&&e[s+1]===o)s++;else break}r+=a===`'`&&!n||!t?`''`:e.slice(i,s+1),i=s+1}else r+=a,i++}return r}var mle=e=>X7(e,!1).split(`;`).filter(e=>e.trim()!==``).length,Z7=e=>/^\s*([A-Za-z]+)/.exec(X7(e))?.[1]?.toUpperCase()??``,hle=new Set([`SELECT`,`EXPLAIN`,`VALUES`]),gle=/\b(?:INSERT|UPDATE|DELETE|REPLACE(?!\s*\())\b/i;function _le(e){let t=Z7(e);return hle.has(t)||t===`WITH`&&!gle.test(X7(e,!1))}function vle(e){let t=Z7(e);return t===`DROP`?Wl():(t===`DELETE`||t===`UPDATE`)&&!/\bWHERE\b/i.test(X7(e))?Gl():null}function yle(e){return typeof e==`object`?e.key:e}function ble(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function Q7(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function $7(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var e9=(e,t)=>Math.abs(e-t)<1.01,xle=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};function Sle({offset:e,isScrolling:t,elementMax:n,holdOffset:r,scrollOffset:i,pendingWrite:a,clampedMaxAtWrite:o}){return t&&a===null&&e===i?`spurious`:a!==null&&Math.abs(e-a.target)<1.5?`readBack`:a!==null&&!a.smooth&&n!==null&&a.target>n+r+.5&&Math.abs(e-(n+r))<1.5||a!==null&&!a.smooth&&a.lowMaxes?.some(t=>Math.abs(e-t)<1.5)?`clampedReadBack`:o!==null&&Math.abs(e-o)<1.5?`clampedEcho`:`external`}var Cle=e=>e===`smooth`||e===`smoothFinishing`;function wle({kind:e,offset:t,command:n,target:r}){return e!==`spurious`&&e!==`readBack`&&e!==`clampedReadBack`&&n?.index!=null&&n.phase!==`queued`&&!Cle(n.phase)&&!e9(t,n.lastTargetOffset)&&!e9(t,r())&&e!==`clampedEcho`}var t9=40;function Tle(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<t9;)n--;if(n<0)return!1;let r=e[n],i=n-1;for(;i>=0&&r.t-e[i].t<t9;)i--;if(i<0)return!1;let a=e[i],o=(t.offset-r.offset)/(t.t-r.t),s=(r.offset-a.offset)/(r.t-a.t);return o*s>=0&&Math.abs(o)>=2*Math.abs(s)&&Math.abs(o)-Math.abs(s)>=.8}function Ele(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<t9;)n--;if(n<0)return!1;let r=e[n];return Math.abs(t.offset-r.offset)/(t.t-r.t)>=.05}var n9,r9=()=>{if(n9!==void 0)return n9;if(typeof navigator>`u`)return n9=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return n9=!0;let e=navigator.maxTouchPoints;return n9=navigator.platform===`MacIntel`&&e!==void 0&&e>0},i9,Dle=()=>i9===void 0?i9=r9()&&typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`overflow-anchor: auto`):i9,a9={capture:!0,passive:!0},Ole=class{constructor(e){this.host=e,this._touch=null,this.inMotion=()=>this._touch!==null&&this._touch.phase!==`lateFling`,this.dragging=()=>this._touch?.phase===`down`&&this._touch.moved,this.tail=()=>this._touch?.phase===`tail`?this._touch.moved?`fling`:`tap`:null,this.onScroll=({isScrolling:e,ownReadBack:t,moved:n,external:r})=>(e&&this._touch?.phase===`tail`?this._openTail(this._touch.moved||!t,!1):this._touch?.phase===`lateFling`&&(this.host.now()>this._touch.until?this._touch=null:r&&e&&n&&this._openTail(!0,!1)),!t&&e&&n&&this._touch?.phase===`down`?(this._touch.moved=!0,!0):!1),this.touchStart=()=>{this.end(),this._touch={phase:`down`,moved:!1}},this.touchEnd=()=>{let e=this._touch?.phase===`down`&&this._touch.moved;this.end(),this._openTail(e,e)},this.end=()=>{let e=this.host.getWindow();this._touch?.phase===`tail`&&e!=null&&e.clearTimeout(this._touch.timerId),this._touch=null},this.listen=e=>{let t=()=>this.touchStart(),n=()=>this.touchEnd();return e.addEventListener(`touchstart`,t,a9),e.addEventListener(`touchend`,n,a9),e.addEventListener(`touchcancel`,n,a9),()=>{e.removeEventListener(`touchstart`,t,a9),e.removeEventListener(`touchend`,n,a9),e.removeEventListener(`touchcancel`,n,a9),this.end()}},this._openTail=(e,t)=>{let n=this.host.getWindow();if(!r9()||n==null)return;this.end();let r={phase:`tail`,moved:e,awaitingFling:t,timerId:n.setTimeout(()=>{this.host.tailStillMoving()?this._openTail(r.moved,r.awaitingFling):(this._touch=r.awaitingFling?{phase:`lateFling`,until:this.host.now()+1e3}:null,this.host.onTailClosed())},150)};this._touch=r}}get touch(){return this._touch}},o9=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},s9=e=>{let t=new Set;return{schedule:n=>{let r=e.requestAnimationFrame(()=>{t.delete(r),n()});t.add(r)},cancel:()=>{t.forEach(t=>e.cancelAnimationFrame(t)),t.clear()}}},kle=e=>e,Ale=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},jle=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(o9(n)),!r.ResizeObserver)return()=>{};let a=s9(r),o=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(o9(n))};e.options.useAnimationFrameWithResizeObserver?a.schedule(r):r()});return o.observe(n,{box:`border-box`}),()=>{o.unobserve(n),a.cancel()}},c9={passive:!0},Mle=typeof window>`u`||`onscrollend`in window,Nle=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Mle,o=0,s=a?null:xle(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,c9),a&&r.addEventListener(`scrollend`,u,c9),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Ple=(e,t)=>Nle(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Fle=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Ile=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},l9=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,u9=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`;function Lle(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var Rle=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new Ole({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{let e=this.scrollState;if(e?.phase!==`queued`||this.pendingWrite!==null)return!1;let t=this._readElementOffset();return t===null||this._lastElementOffset===null||Math.abs(t-this._lastElementOffset)<1?!1:(this._lastElementOffset=t,e.samples=[...e.samples??[],{t:this.now(),offset:t}],!0)},onTailClosed:()=>{let e=this.scrollState;e?.phase===`queued`&&Ele(e.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=null,n=()=>{if(e)return e;let n=this.targetWindow;if(!n||!n.ResizeObserver)return null;let i=t=s9(n);return e=new n.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(r)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?i.schedule(t):t()})},r=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t?.cancel(),e=null,t=null},observe:e=>n()?.observe(e,{box:`border-box`}),unobserve:e=>n()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:kle,rangeExtractor:Ale,onChange:()=>{},measureElement:Fle,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>yle(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Lle(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=null;if(r&&this.scrollOffset!==null&&!this._awaitingCommandReadBack()){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:s}=this.options,c=0;for(;c<a&&s(c)!==e;)c++;if(c<a){let e=n[c];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(o=n-this.scrollOffset,this.scrollOffset=n)}}}i?this.pendingScrollAnchor={kind:`follow`,behavior:i}:o!==null&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:`anchor`,delta:o}:(this._holdOffset+=o,this._followOffsetTarget(o)))},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Q7(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var e;this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,(e=this._momentumStop)==null||e.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{let n=t?this._elementMaxScrollOffset():null,r=this._reportedOverscroll;this._reportedOverscroll=e<0||n!==null&&e>n+1;let i=e;this._lastElementOffset=i,e=this._toLayoutOffset(e);let a=this._classifyScrollEvent(e,t,n);if(a===`spurious`)return;a===`readBack`?e=this.pendingWrite.target:a===`clampedReadBack`&&this.scrollState?.index!=null&&e<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=e:wle({kind:a,offset:e,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);let o=this.getScrollOffset(),s=this.scrollDirection;this.scrollDirection=t?o===e?this.scrollDirection:o<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t;let c=this.scrollState;if(c?.phase===`queued`&&a===`external`&&t){if(r||this._reportedOverscroll)c.samples=[];else{let e=this.now();c.samples=[...(c.samples??[]).filter(t=>e-t.t<=200),{t:e,offset:i}],(s!==null&&this.scrollDirection!==s||Tle(c.samples))&&(this.scrollState=null)}}this._iosGesture.onScroll({isScrolling:t,ownReadBack:a===`readBack`,moved:e!==o,external:a===`external`&&this.scrollState?.phase!==`smooth`&&this.scrollState?.phase!==`smoothFinishing`})&&this.scrollState?.phase===`queued`&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();let t=this.pendingScrollAnchor;this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled&&(t.kind===`anchor`?this._canWriteScroll()?u9(this.scrollState)&&!e9(this.getScrollOffset()-t.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(t.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=t.delta,this._followOffsetTarget(t.delta),this.notify(!1)):this.scrollToEnd({behavior:t.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(e,t,n)=>Sle({offset:e,isScrolling:t,elementMax:n,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:this._clampedAdjustment?.maxAtWrite??null}),this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e))},this._writeAwaitingCommand=()=>{let e=this.scrollState;if(e===null||e.phase!==`queued`)return;let{behavior:t}=e;this.getMeasurements();let n=this.getScrollStateTarget(e);e.lastTargetOffset=n,this._clampedAdjustment=null,e.phase=l9(t,e.index!=null&&e9(n,this.getScrollOffset())),this._scrollToOffset(n,{behavior:t}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{let e=this.scrollElement;if(e==null)return null;let{horizontal:t,isRtl:n}=this.options;return typeof e.scrollTop==`number`?t?e.scrollLeft*(n&&-1||1):e.scrollTop:typeof e.scrollY==`number`?t?e.scrollX:e.scrollY:null},this._canWriteScroll=()=>!(r9()&&this._iosGesture.inMotion())&&!this._reportedOverscroll,this._flushHoldIfReady=e=>{if(this._holdOffset===0||!this.scrollElement||!this.options.enabled||!this._canWriteScroll()||this.scrollState?.phase===`smooth`)return;this._holdOffset=0,this.scrollOffset!==null&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(e);let t=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(t),this._scrollToOffset(t)},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Q7(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Q7(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=ble(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Q7(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Ble(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Q7(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!u9(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!u9(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this._getLayoutTotalSize():0,u=this.getScrollOffset(),d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!u9(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=!1;if(this._awaitingCommandReadBack()||(o?p=this.applyScrollAdjustment(this._getLayoutTotalSize()-l):f&&(p=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=p);return}this.notify(p),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=Q7(()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset],(e,t,n)=>{let r=[];for(let i=0,a=e.length;i<a;i++){let a=t[e[i]];r.push(n===0?a:{...a,start:a.start-n,end:a.end-n})}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return $7(t[d9(0,t.length-1,r?e=>n[e*2]:e=>$7(t[e]).start,e)])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;let e=this._elementMaxScrollOffset();if(e===null)return;let t=this.pendingWrite,n=Math.max(e,0)+this._holdOffset;if(n>=t.target)return;let r=t.lowMaxes??=[];r[r.length-1]!==n&&r.push(n)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=e=>{let t=e+this._holdOffset;return this.pendingScrollAnchor?.kind===`anchor`&&(t+=this.pendingScrollAnchor.delta),t},this._elementMaxScrollOffset=()=>{let e=this.scrollElement;if(e===null)return null;if(`scrollHeight`in e)return this.options.horizontal?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;if(`document`in e){let t=e.document.documentElement;return this.options.horizontal?t.scrollWidth-e.innerWidth:t.scrollHeight-e.innerHeight}return null},this._momentumStop=null,this._stopMomentum=e=>{let t=this.scrollElement,n=this.targetWindow;if(t===null||n===null)return;let r=`document`in t?t.document.scrollingElement:t;if(!r?.style)return;if(this._momentumStop){this._momentumStop.done=e;return}let{style:i}=r,a=this.options.horizontal?`overflow-x`:`overflow-y`,o=i.getPropertyValue(a),s=i.getPropertyPriority(a);i.setProperty(a,`hidden`,`important`);let c={restore:()=>i.getPropertyValue(a)!==`hidden`||i.getPropertyPriority(a)!==`important`?!1:(i.setProperty(a,o,s),!0),done:e};this._momentumStop=c,n.requestAnimationFrame(()=>n.requestAnimationFrame(()=>{this._momentumStop===c&&(this._momentumStop=null,c.restore()&&c.done())}))},this._clampedBy=e=>{let t=this._elementMaxScrollOffset();if(t===null)return null;let n=t+this._holdOffset;return e>n+.5?{target:e,maxAtWrite:n}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._startScroll({index:null,align:t},this.getOffsetForAlignment(e,t),n,`absolute`)},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r;this._startScroll({index:e,align:a},i,n,`absolute`)},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+e,`start`);this._startScroll({index:null,align:`start`},n,t,`relative`)},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this._startScroll({index:this.options.count-1,align:`end`,toEnd:!0},Math.max(this.getMaxScrollOffset(),0),e,`absolute`):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n}={})=>{let r={target:e+(t??0),smooth:n===`smooth`};return this.pendingWrite=r,this.options.scrollToFn(e-this._holdOffset,{behavior:n,adjustments:t},this),r},this.getCommandWrittenOffset=()=>this.scrollState!==null&&this.pendingWrite!==null&&!this.pendingWrite.smooth?this.pendingWrite.target:null,this._awaitingCommandReadBack=()=>{let e=this.getCommandWrittenOffset();return!(r9()&&this._iosGesture.dragging())&&e!==null&&!e9(e,this.getScrollOffset())},this._followOffsetTarget=e=>{this.scrollState!==null&&this.scrollState.index==null&&(this.scrollState.lastTargetOffset+=e)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}get scrollAdjustments(){return 0}applyScrollAdjustment(e,t){if(e===0)return!1;if(this._followOffsetTarget(e),this._canWriteScroll()){let n=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(n+e);let r=this._scrollToOffset(n,{adjustments:e,behavior:t});return this.scrollOffset!==null&&(this.pendingWrite===r&&(this.scrollOffset+=e),this.scrollOffset<0&&(this.scrollOffset=0)),!0}return this._holdOffset+=e,this.scrollOffset!==null&&(this.scrollOffset+=e),!0}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}if(this.scrollState.phase===`queued`){this.scheduleScrollReconcile();return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&e9(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=u9(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}_startScroll(e,t,n,r){let i=this._iosGesture.tail();if(r===`absolute`&&i!==null){if(i===`fling`&&Dle()){this._stopMomentum(()=>{this.scrollState?.phase!==`queued`||this._iosGesture.tail()!==`fling`||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())}),this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:`queued`,behavior:n,samples:[]},this.scheduleScrollReconcile();return}this._iosGesture.end()}this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,behavior:n,phase:l9(n,e.index!=null&&e9(t,this.getScrollOffset()))},this._scrollToOffset(t,{behavior:n}),this.scheduleScrollReconcile()}},d9=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function zle(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Ble(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=zle(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=d9(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var f9=typeof document<`u`?B.useLayoutEffect:B.useEffect;function Vle({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=B.useReducer(e=>e+1,0)[1],a=B.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=B.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,W_.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=B.useState(()=>{let e=new Rle(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),f9(()=>d._didMount(),[]),f9(()=>(s(d),d._willUpdate())),f9(()=>{l(d)}),d}function Hle(e){return Vle({observeElementRect:jle,observeElementOffset:Ple,scrollToFn:Ile,...e})}var p9=(0,B.createContext)(``);function Ule(e,t){if(t===``)return[{text:e,match:!1}];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(let t=n.indexOf(r);t>=0;t=n.indexOf(r,a))t>a&&i.push({text:e.slice(a,t),match:!1}),i.push({text:e.slice(t,t+r.length),match:!0}),a=t+r.length;return a<e.length&&i.push({text:e.slice(a),match:!1}),i}function m9({text:e}){let t=Ule(e,(0,B.useContext)(p9));return t.length===1&&!t[0]?.match?e:t.map((e,t)=>e.match?(0,z.jsx)(`mark`,{className:`rounded-[2px] bg-warn-soft text-foreground`,children:e.text},t):e.text)}function h9({value:e}){return typeof e==`string`?(0,z.jsx)(`span`,{className:`text-syn-str`,children:JSON.stringify(e)}):typeof e==`number`?(0,z.jsx)(`span`,{className:`text-syn-num`,children:e}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:String(e)})}function g9({value:e}){if(SJ(e))return(0,z.jsx)(h9,{value:e});let t=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e);return(0,z.jsx)(`div`,{className:`font-mono text-[12px] leading-[1.7]`,children:t.map(([t,n])=>(0,z.jsxs)(`div`,{children:[!Array.isArray(e)&&(0,z.jsx)(`span`,{className:`text-syn-key`,children:t}),!Array.isArray(e)&&`: `,SJ(n)?(0,z.jsx)(h9,{value:n}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:Array.isArray(n)?`[${n.length}]`:`{${Object.keys(n).length}}`}),(0,z.jsx)(`div`,{className:`ml-[3px] border-l pl-3.5`,children:(0,z.jsx)(g9,{value:n})})]})]},t))})}function _9({title:e,value:t,children:n}){return(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:n}),(0,z.jsxs)(zk,{className:`w-[min(20rem,calc(100vw-2rem))]`,align:`start`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`mb-1 flex justify-between text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>void navigator.clipboard?.writeText(JSON.stringify(t,null,2)),children:ui()})]}),(0,z.jsx)(g9,{value:t})]})]})}var v9=`inline-block rounded-full bg-chip px-[7px] text-[11.5px] text-chip-foreground mr-[3px]`;function Wle({value:e,type:t,format:n,column:r,rowKey:i}){let a=AJ(e,t,n);switch(a.kind){case`null`:return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});case`bool`:return(0,z.jsx)(`span`,{role:`img`,"aria-label":a.value?`true`:`false`,className:`inline-flex size-3.5 items-center justify-center rounded-[3px] border-[1.5px] ${a.value?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground`}`,children:a.value&&(0,z.jsx)(lO,{className:`size-2.5`,strokeWidth:4})});case`number`:return(0,z.jsx)(`span`,{className:`font-mono tabular-nums`,children:(0,z.jsx)(m9,{text:a.text})});case`text`:return(0,z.jsx)(`span`,{children:(0,z.jsx)(m9,{text:a.text})});case`chips`:return(0,z.jsxs)(`span`,{children:[a.items.map((e,t)=>(0,z.jsx)(`span`,{className:v9,children:(0,z.jsx)(m9,{text:e})},`${t}-${e}`)),a.more>0&&(0,z.jsxs)(`span`,{className:`inline-block rounded-full bg-chip px-[7px] text-[11.5px] text-chip-foreground mr-[3px]`,children:[`+`,a.more]})]});case`map`:return(0,z.jsx)(_9,{title:`${r} · ${i}`,value:e,children:(0,z.jsxs)(`button`,{type:`button`,className:`text-left max-md:min-h-8`,onClick:e=>e.stopPropagation(),children:[a.entries.map(([e,t])=>(0,z.jsxs)(`span`,{className:`mr-1.5`,children:[(0,z.jsx)(`span`,{className:`mr-0.5 text-[11px] text-muted-foreground`,children:e}),(0,z.jsx)(m9,{text:t})]},e)),a.more>0&&(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`+`,a.more]})]})});case`nested`:return(0,z.jsx)(_9,{title:`${r} · ${i}`,value:e,children:(0,z.jsxs)(`button`,{type:`button`,className:`text-left max-md:min-h-8`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`span`,{className:`mr-1.5 rounded border px-1 font-mono text-[10px] text-muted-foreground`,children:a.label}),(0,z.jsx)(`span`,{className:`border-b border-dotted border-muted-foreground`,children:a.preview})]})})}}function y9({label:e,hint:t,className:n,children:r}){return(0,z.jsx)(`span`,{className:`contents`,onClick:e=>{e.stopPropagation(),e.preventDefault()},children:(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,"aria-label":e,title:typeof t==`string`?t:void 0,className:T(`shrink-0`,n),children:r})}),(0,z.jsx)(zk,{className:`w-auto max-w-[min(20rem,calc(100vw-2rem))] text-[13px] whitespace-pre-line`,children:t})]})})}function b9({column:e,row:t,rowKey:n}){let r=t[e.name],i=AJ(r,e.type,e.format),{reference:a}=e;return a&&(i.kind===`text`||i.kind===`number`)?(0,z.jsx)(UJ,{reference:a,value:String(r),children:(0,z.jsx)(m9,{text:String(r)})}):a&&i.kind===`chips`?(0,z.jsxs)(`span`,{children:[i.items.map((e,t)=>(0,z.jsx)(UJ,{reference:a,value:e,className:`${v9} hover:underline`,children:(0,z.jsx)(m9,{text:e})},`${t}-${e}`)),i.more>0&&(0,z.jsxs)(`span`,{className:`inline-block rounded-full bg-chip px-[7px] text-[11.5px] text-chip-foreground mr-[3px]`,children:[`+`,i.more]})]}):(0,z.jsx)(Wle,{value:r,type:e.type,format:e.format,column:e.name,rowKey:n})}var Gle=34,Kle=44,x9=`sticky left-0 z-[1] bg-background shadow-[1px_0_0_var(--border)]`,qle=16;function Jle({column:e,width:t,onResize:n}){let r=e=>t??e.parentElement?.getBoundingClientRect().width??0;return(0,z.jsx)(`div`,{role:`separator`,"aria-label":Ur({column:e}),"aria-orientation":`vertical`,"aria-valuenow":t,tabIndex:0,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget;i.setPointerCapture?.(t.pointerId),document.body.setAttribute(`data-resizing`,``);let a=t.clientX,o=r(i),s=t=>n(e,o+t.clientX-a),c=()=>{document.removeEventListener(`pointermove`,s),document.removeEventListener(`pointerup`,c),document.removeEventListener(`pointercancel`,c),i.removeEventListener(`lostpointercapture`,c),document.body.removeAttribute(`data-resizing`)};document.addEventListener(`pointermove`,s),document.addEventListener(`pointerup`,c),document.addEventListener(`pointercancel`,c),i.addEventListener(`lostpointercapture`,c)},onDoubleClick:()=>n(e,null),onKeyDown:t=>{let i=t.key===`ArrowRight`?qle:t.key===`ArrowLeft`?-16:0;i!==0&&(t.preventDefault(),n(e,r(t.currentTarget)+i))},className:`absolute inset-y-0 -right-[3px] z-[2] w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/40 focus-visible:bg-primary/40`})}function S9({columns:e,rows:t,keyCol:n,stickyCol:r=n,rowId:i,selectedKey:a,onSelect:o,onEndReached:s,flagged:c,sort:l,onSort:u,widths:d,onResize:f,pinned:p=!0,onTogglePin:m,preview:h}){let g=(0,B.useRef)(null),_=OX(),v=_?Kle:Gle,y=Hle({count:t.length,getScrollElement:()=>g.current,estimateSize:()=>v,overscan:10});(0,B.useEffect)(()=>y.measure(),[v,y]);let b=y.getVirtualItems(),x=b.at(-1)?.index??0;(0,B.useEffect)(()=>{t.length>0&&x>=t.length-20&&s?.()},[x,t.length,s]);let[S,C]=_?[`minmax(120px, 160px)`,`minmax(96px, 1fr)`]:[`minmax(160px, 220px)`,`minmax(110px, 1fr)`],w=e.map(e=>{let t=d?.[e.name];return t===void 0?e.name===n?S:C:`${t}px`}).join(` `),E=p?r:void 0,[D,O]=(l??``).split(`:`);return(0,z.jsx)(`div`,{ref:g,role:`grid`,"aria-rowcount":t.length,className:`min-h-0 flex-1 overflow-auto text-[12.5px] max-md:text-[14px]`,children:(0,z.jsxs)(`div`,{className:`w-max min-w-full`,children:[(0,z.jsx)(`div`,{role:`row`,className:`sticky top-0 z-10 grid border-b bg-background`,style:{gridTemplateColumns:w},children:e.map(e=>(0,z.jsxs)(`div`,{role:`columnheader`,className:T(`group/header relative flex min-w-0 items-center`,e.name===E&&x9),children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1 px-3 py-[7px] text-left text-[11.5px] font-semibold whitespace-nowrap text-muted-foreground max-md:text-[12.5px]`,onClick:()=>u?.(e.name),children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-panel-2 px-1 font-mono text-[9.5px] font-medium max-md:text-[11px]`,children:e.name===n?Rr():e.note??e.type}),D===e.name&&(O===`desc`?(0,z.jsx)(YD,{className:`size-3 shrink-0`}):(0,z.jsx)(aO,{className:`size-3 shrink-0`}))]}),e.name===r&&m&&(0,z.jsx)(`button`,{type:`button`,"aria-label":p?Wr():zr(),"aria-pressed":p,title:p?Gr():Br(),className:T(`mr-1 grid size-6 shrink-0 place-items-center rounded text-muted-foreground hover:bg-panel-2 hover:text-foreground focus-visible:opacity-100 max-md:size-8`,p&&`opacity-0 group-hover/header:opacity-100 max-md:opacity-100`),onClick:m,children:p?(0,z.jsx)($O,{className:`size-3.5`}):(0,z.jsx)(ZO,{className:`size-3.5`})}),f&&!_&&(0,z.jsx)(Jle,{column:e.name,width:d?.[e.name],onResize:f})]},e.name))}),(0,z.jsx)(`div`,{style:{height:y.getTotalSize(),position:`relative`},children:b.map(r=>{let s=t[r.index],l=i?i(s):String(s[n]),u=l===a,d=h?.get(l);return(0,z.jsx)(`div`,{role:`row`,"aria-selected":u,"data-key":l,"data-preview":d?.op,className:T(`group absolute inset-x-0 grid cursor-pointer border-b md:hover:bg-panel`,u&&`bg-tomato-soft md:hover:bg-tomato-soft`,d&&`bg-warn-soft md:hover:bg-warn-soft`,d?.op===`delete`&&`line-through opacity-60`,d?.op===`insert`&&`cursor-default`),style:{gridTemplateColumns:w,height:v,transform:`translateY(${r.start}px)`},onClick:()=>d?.op!==`insert`&&o?.(l,s),children:e.map(e=>(0,z.jsxs)(`div`,{role:`gridcell`,className:T(`flex items-center overflow-hidden px-3 whitespace-nowrap`,e.name===n&&`font-mono text-[12px] max-md:text-[13px]`,e.name===E&&x9,e.name===E&&d&&`bg-warn-soft`,e.name===E&&!d&&(u?`bg-tomato-soft`:`md:group-hover:bg-panel`)),children:[e.name===n&&(c?.has(l)?(0,z.jsx)(y9,{label:`has warnings`,hint:c.get(l)?.join(`
|
|
126
|
-
`),className:`mr-1.5 grid min-h-6 min-w-[1em] place-items-center text-warn max-md:-my-2 max-md:-ml-2 max-md:mr-0 max-md:min-h-8 max-md:min-w-8`,children:`⚠`}):(0,z.jsx)(`span`,{"aria-hidden":!0,className:`mr-1.5 w-[1em] shrink-0`})),d?.op===`update`&&d.changed.includes(e.name)?(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 truncate`,children:[(0,z.jsx)(`span`,{"data-testid":`preview-old`,className:`text-muted-foreground line-through`,children:(0,z.jsx)(b9,{column:e,row:d.before??s,rowKey:l})}),`→`,(0,z.jsx)(`span`,{className:`font-semibold text-ok`,children:(0,z.jsx)(b9,{column:e,row:d.after??s,rowKey:l})})]}):(0,z.jsx)(`span`,{className:`truncate`,children:(0,z.jsx)(b9,{column:e,row:s,rowKey:l})})]},e.name))},l)})})]})})}var Yle={toFile:`M`,deleteFile:`−`,toDb:`M`,deleteDb:`−`};function Xle(){let e=h(),t=OX(),{data:n}=ry(),r=iy(),[i,a]=(0,B.useState)(Y7),[o,s]=(0,B.useState)(()=>i[0]??`select * from `),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)([]),[f,p]=(0,B.useState)(null),m=(0,B.useRef)(()=>{}),g=()=>{m.current(),d([]);let e=r.listen(e=>{if(e.type!==`sync`)return;let t=e.changes.filter(e=>e.op===`toFile`||e.op===`deleteFile`);t.length>0&&d(n=>[...n,...t.map(t=>({table:e.table,key:t.key,op:t.op}))])}),t=setTimeout(e,1e4);m.current=()=>{clearTimeout(t),e()}};(0,B.useEffect)(()=>()=>m.current(),[]);let _=H_({mutationFn:e=>Uv.sql(e),onMutate:g,onSuccess:(e,t)=>{a(ple(t)),`columns`in e&&(m.current(),d([]))},onError:()=>{m.current(),d([])}}),v=(0,B.useRef)(()=>{});v.current=()=>{if(_.isPending)return;let e=Yv()?null:vle(o);e?l(e):_.mutate(o)};let y=(0,B.useMemo)(()=>[dle({schema:Object.fromEntries((n?.tables??[]).map(e=>[e.name,Object.keys(e.columns)]))}),CM.highest(qR.of([{key:`Mod-Enter`,run:()=>(v.current(),!0)}])),X.lineWrapping],[n]),b=Qv(n),x=_.data;return(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b px-[18px] py-3 max-md:px-3`,children:[(0,z.jsx)(`h1`,{className:`max-md:sr-only text-lg font-semibold tracking-tight`,children:ki()}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(S5,{children:[(0,z.jsx)(C5,{asChild:!0,children:(0,z.jsxs)(V,{variant:`outline`,size:`sm`,disabled:i.length===0,children:[(0,z.jsx)(ak,{className:`size-3.5`}),` `,Jl()]})}),(0,z.jsx)(w5,{className:`max-w-[min(480px,calc(100vw-2rem))]`,children:i.map(e=>(0,z.jsx)(T5,{className:`truncate font-mono text-[12px]`,onSelect:()=>s(e),children:e},e))})]}),!t&&(0,z.jsxs)(V,{size:`sm`,onClick:()=>v.current(),disabled:_.isPending,children:[(0,z.jsx)(tk,{className:`size-3.5`}),` `,$l()]})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2.5 px-[18px] py-3.5 max-md:px-3`,children:[(0,z.jsx)($q,{"aria-label":`SQL`,value:o,onChange:s,extensions:y,theme:e,minHeight:`110px`,className:`overflow-hidden rounded-lg border text-[12.5px]`}),t&&(0,z.jsxs)(V,{size:`lg`,className:`w-full`,onClick:()=>v.current(),disabled:_.isPending,children:[(0,z.jsx)(tk,{className:`size-4`}),` `,Ql()]}),_.isError&&(0,z.jsx)(`div`,{role:`alert`,className:`rounded-md bg-err-soft px-3 py-2 font-mono text-[12px] text-err`,children:_.error.message}),x&&`columns`in x&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`text-[11.5px] text-muted-foreground`,children:[Zl({count:x.rows.length}),x.truncated?tu():``,` · `,x.ms,` ms`]}),(0,z.jsx)(S9,{columns:x.columns.map(e=>({name:e,type:`TEXT`})),rows:x.rows.map((e,t)=>({...e,__row:t})),keyCol:`__row`,stickyCol:x.columns[0]})]}),x&&!(`columns`in x)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-[11.5px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`text-ok`,children:Ul({count:x.changes})}),(0,z.jsxs)(`span`,{children:[x.ms,` ms`]})]}),!Yv()&&x.unmanaged&&(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md bg-warn-soft px-3 py-2 text-[12px] text-warn`,children:[iu({table:x.unmanaged}),(0,z.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>p(x.unmanaged??null),children:Bl()})]}),u.length>0&&(0,z.jsxs)(`div`,{className:`rounded-lg border px-3 py-2 font-mono text-[12px] leading-[1.8]`,children:[(0,z.jsx)(`div`,{className:`font-sans text-[11px] text-muted-foreground`,children:eu()}),u.map((e,t)=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mr-1.5 font-bold text-warn`,children:Yle[e.op]}),b(e.table,e.key)]},`${t}-${e.table}-${e.key}`))]})]})]}),c&&(0,z.jsx)(qk,{open:!0,onOpenChange:e=>!e&&l(null),children:(0,z.jsxs)(Qk,{children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{children:Kl()}),(0,z.jsx)(rA,{children:c})]}),(0,z.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded bg-panel p-2 font-mono text-[12px]`,children:o}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>l(null),children:gt()}),(0,z.jsx)(V,{variant:`destructive`,onClick:()=>{l(null),_.mutate(o)},children:ql()})]})]})}),f&&(0,z.jsx)(l7,{open:!0,adopt:f,onOpenChange:e=>!e&&p(null)})]})}function Zle(e,t,n){let r=e??{},i=t??{},a=new Set(LJ(r,i));return[...new Set([...Object.keys(r),...Object.keys(i)])].filter(e=>e!==n).map(e=>({field:e,winner:r[e],saved:i[e],same:!a.has(e)}))}function C9(e){return e===`file`?jo():e===`db`?Mo():No()}var Qle={ok:`text-ok`,warn:`text-warn`,err:`text-err`,muted:`text-muted-foreground`},$le=e=>e===void 0?`—`:JSON.stringify(e);function w9({entry:e,detail:t,keyCol:n}){return(0,z.jsx)(WZ,{className:`md:text-[11.5px]`,labels:[(0,z.jsx)(`span`,{className:`text-ok`,children:Nu({winner:e.winner??``})}),Eu()],note:t.deleted?Ou():void 0,format:$le,rows:Zle(t.current,t.saved,n).map(e=>({field:e.field,a:e.winner,b:e.saved,dim:e.same}))})}function eue({entry:e}){let[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1),a=Sg(),{connected:o}=ay(),s=OX(),{data:c}=ry(),l=c?.tables.find(t=>t.name===e.table)?.key,u=V_({queryKey:[`conflict`,e.id],queryFn:()=>Uv.conflict(e.id),enabled:t||r}),d=e=>{a.invalidateQueries({queryKey:[`conflicts`]}),iv.success(e)},f=H_({mutationFn:t=>Uv.restore(e.id,t),onSuccess:()=>{i(!1),d(Yu({table:e.table,key:e.key??``}))},onError:t=>{iv.error(t.message),t instanceof Sv&&t.status===409&&a.invalidateQueries({queryKey:[`conflict`,e.id]})}}),p=H_({mutationFn:()=>Uv.dismiss(e.id),onSuccess:()=>d(Au()),onError:e=>iv.error(e.message)}),m=o?e.restorable?void 0:Ku():yt();return(0,z.jsxs)(`div`,{className:`border-b px-3.5 py-2.5 text-[12px] last:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left max-md:basis-full max-md:flex-wrap`,onClick:()=>n(!t),children:[t?(0,z.jsx)(dO,{className:`size-3.5`}):(0,z.jsx)(hO,{className:`size-3.5`}),(0,z.jsxs)(`span`,{className:`font-semibold`,children:[e.table,` / `,e.key??e.file]}),(0,z.jsxs)(`span`,{className:`truncate text-[11.5px] text-muted-foreground max-md:basis-full max-md:pl-5 max-md:text-[12.5px] max-md:whitespace-normal`,children:[D5(e.at),` · `,e.winner?ed({winner:e.winner}):zu()]})]}),(0,z.jsx)(V,{size:s?`default`:`sm`,variant:`outline`,disabled:!o||!e.restorable||f.isPending,title:m,onClick:()=>i(!0),children:C9(e.restorable?e.winner:null)}),(0,z.jsx)(V,{size:s?`default`:`sm`,variant:`ghost`,disabled:!o||p.isPending,title:o?void 0:yt(),onClick:()=>p.mutate(),children:ku()})]}),s&&m&&(0,z.jsx)(`p`,{className:`mt-1 text-[12px] text-muted-foreground`,children:m}),t&&u.data&&(0,z.jsx)(`div`,{className:`mt-2`,children:(0,z.jsx)(w9,{entry:e,detail:u.data,keyCol:l})}),r&&(0,z.jsx)(qk,{open:!0,onOpenChange:e=>!e&&i(!1),children:(0,z.jsxs)(Qk,{children:[(0,z.jsx)($k,{children:(0,z.jsx)(nA,{children:Gu({table:e.table,key:e.key??``})})}),u.data?(0,z.jsx)(w9,{entry:e,detail:u.data,keyCol:l}):(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:u.error?u.error.message:bt()}),(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:Hu()}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>i(!1),children:gt()}),(0,z.jsx)(V,{disabled:!u.data||f.isPending,onClick:()=>u.data&&f.mutate(u.data.current),children:C9(e.winner)})]})]})})]})}function T9({title:e,count:t,tone:n,children:r}){return(0,z.jsxs)(`div`,{className:`mb-3.5 overflow-hidden rounded-[10px] border`,children:[(0,z.jsxs)(`h3`,{className:`flex items-center gap-2 border-b bg-panel px-3.5 py-2.5 text-[13px] font-semibold`,children:[t!==void 0&&t>0&&(0,z.jsx)(`span`,{className:`rounded-full px-1.5 text-[10.5px] ${n===`err`?`bg-err-soft text-err`:`bg-warn-soft text-warn`}`,children:t}),e]}),r]})}function tue(){let e=iy(),{activity:t,warnings:n,connected:r,lastSyncAt:i}=ay(),{data:a}=V_({queryKey:[`conflicts`],queryFn:Uv.conflicts});(0,B.useEffect)(()=>e.markConflictsSeen(),[e]);let o=a?.conflicts??[],{data:s}=ry(),c=u7(n,new Set(s?.views.map(e=>e.name))),l=Zse(t);return(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-b px-[18px] py-3 max-md:px-3`,children:[(0,z.jsx)(`h1`,{className:`max-md:sr-only text-lg font-semibold tracking-tight`,children:Ai()}),(0,z.jsxs)(`span`,{className:`text-[12px] text-muted-foreground`,children:[r?Zu():lu(),i&&Iu({at:D5(i)})]})]}),(0,z.jsxs)(`div`,{className:`overflow-auto px-[18px] py-3.5 max-md:px-3`,children:[(0,z.jsx)(T9,{title:Du(),count:o.length,tone:`err`,children:o.length===0?(0,z.jsx)(`p`,{className:`px-3.5 py-2.5 text-[12px] text-muted-foreground`,children:Ru()}):o.map(e=>(0,z.jsx)(eue,{entry:e},e.id))}),(0,z.jsx)(T9,{title:Xu(),count:c.length,tone:`warn`,children:c.length===0?(0,z.jsx)(`p`,{className:`px-3.5 py-2.5 text-[12px] text-muted-foreground`,children:Bu()}):c.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-3.5 py-2 text-[12px] last:border-b-0 max-md:text-[13px]`,children:[(0,z.jsxs)(`span`,{className:`font-semibold`,children:[e.table,e.key&&` / ${e.key}`,e.view&&` / ${e.view}`]}),(0,z.jsx)(`span`,{className:`flex-1 text-muted-foreground max-md:order-last max-md:basis-full`,children:e.text}),e.key&&(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.table},search:{key:e.key},className:`text-tomato max-md:py-1.5`,children:Vu()}),e.view&&(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.view},className:`text-tomato max-md:py-1.5`,children:Vu()})]},`${t}-${e.text}`))}),(0,z.jsx)(T9,{title:Tu(),children:l.length===0?(0,z.jsx)(`p`,{className:`px-3.5 py-2.5 text-[12px] text-muted-foreground`,children:Lu()}):l.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 border-b px-3.5 py-2 text-[12px] last:border-b-0 max-md:text-[13px]`,children:[(0,z.jsx)(`span`,{className:`w-3 font-mono font-bold ${Qle[e.tone]}`,children:e.symbol}),(0,z.jsx)(`span`,{className:`font-semibold`,children:e.text}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[D5(e.at),` · `,e.detail]})]},`${t}-${e.at}-${e.text}`))})]})]})}var E9=e=>`yamlite-grid:${e}`;function nue(e){try{let t=JSON.parse(localStorage.getItem(E9(e))??`{}`);return{widths:Object.fromEntries(Object.entries(t.widths??{}).filter(([,e])=>typeof e==`number`&&Number.isFinite(e))),unpinned:t.unpinned===!0}}catch{return{widths:{},unpinned:!1}}}function rue(e){let[t,n]=(0,B.useState)(()=>nue(e)),r=t=>{n(t);try{localStorage.setItem(E9(e),JSON.stringify(t))}catch{}};return{...t,setWidth:(e,n)=>{let{[e]:i,...a}=t.widths;r({...t,widths:n===null?a:{...a,[e]:Math.max(60,Math.round(n))}})},togglePin:()=>r({...t,unpinned:!t.unpinned})}}var D9=e=>()=>e,O9=[[`eq`,D9(`=`)],[`ne`,D9(`≠`)],[`lt`,D9(`<`)],[`lte`,D9(`≤`)],[`gt`,D9(`>`)],[`gte`,D9(`≥`)],[`contains`,bn],[`has`,xn],[`null`,Cn],[`notnull`,Sn]],k9=e=>`${e.col} ${O9.find(([t])=>t===e.op)?.[1]()??e.op}${e.value===void 0?``:` ${JSON.stringify(e.value)}`}`;function iue(e,t){return t===`BOOLEAN`?e===`true`:(t===`INTEGER`||t===`REAL`)&&e.trim()!==``&&!Number.isNaN(Number(e))?t===`INTEGER`&&!Number.isSafeInteger(Number(e))?e:Number(e):e}function aue({columns:e,filters:t,search:n,onChange:r}){let i=Object.keys(e),[a,o]=(0,B.useState)({col:i[0]??``,op:`eq`,text:``}),[s,c]=(0,B.useState)(n??``),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>c(n??``),[n]),(0,B.useEffect)(()=>{let e=setTimeout(()=>{(n??``)!==s&&r({filters:t,search:s||void 0})},300);return()=>clearTimeout(e)},[s,n,t,r]);let d=()=>{let i=a.op!==`null`&&a.op!==`notnull`,o=i?iue(a.text,(Object.hasOwn(e,a.col)?e[a.col]:void 0)??`TEXT`):void 0;r({filters:[...t,{col:a.col,op:a.op,...i?{value:o}:{}}],search:n}),u(!1)};return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b px-[18px] py-2 max-md:px-3`,children:[(0,z.jsxs)(`div`,{className:`relative w-full max-w-[280px] max-md:max-w-none max-md:basis-full`,children:[(0,z.jsx)(dk,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(Ik,{type:`search`,"aria-label":Tn(),placeholder:En(),className:`h-7 pl-7 text-[12px] max-md:h-9`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Escape`&&c(``)})]}),t.map((e,i)=>(0,z.jsxs)(`button`,{type:`button`,className:`rounded-full border border-tomato bg-tomato-soft px-2 py-0.5 text-[11.5px] text-tomato max-md:min-h-8 max-md:px-3 max-md:text-[13px]`,onClick:()=>r({filters:t.filter((e,t)=>t!==i),search:n}),children:[k9(e),` ×`]},`${i}-${k9(e)}`)),(0,z.jsxs)(Lk,{open:l,onOpenChange:u,children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded-full border border-dashed px-2 py-0.5 text-[11.5px] text-muted-foreground max-md:min-h-8 max-md:px-3 max-md:text-[13px]`,children:vn()})}),(0,z.jsxs)(zk,{className:`flex w-[min(20rem,calc(100vw-2rem))] flex-col gap-2`,children:[(0,z.jsx)(`select`,{"aria-label":yn(),className:`rounded border bg-background px-2 py-1 max-md:py-2`,value:a.col,onChange:e=>o({...a,col:e.target.value}),children:i.map(e=>(0,z.jsx)(`option`,{children:e},e))}),(0,z.jsx)(`select`,{"aria-label":wn(),className:`rounded border bg-background px-2 py-1 max-md:py-2`,value:a.op,onChange:e=>o({...a,op:e.target.value}),children:O9.map(([e,t])=>(0,z.jsx)(`option`,{value:e,children:t()},e))}),a.op!==`null`&&a.op!==`notnull`&&(0,z.jsx)(Ik,{"aria-label":Dn(),value:a.text,onChange:e=>o({...a,text:e.target.value}),onKeyDown:e=>e.key===`Enter`&&d()}),(0,z.jsx)(V,{size:`sm`,onClick:d,children:_n()})]})]})]})}var oue=O(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function sue({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?_:`span`;return(0,z.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:T(oue({variant:t}),e),...r})}function A9({title:e,heading:t,actions:n,flush:r=!1,children:i}){return(0,z.jsxs)(`section`,{"data-slot":`section-card`,className:`overflow-hidden rounded-lg border`,children:[(0,z.jsxs)(`header`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b bg-muted px-4 py-1.5`,children:[(0,z.jsx)(`h3`,{className:iA,children:e}),t,n&&(0,z.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),(0,z.jsx)(`div`,{className:T(!r&&`flex flex-col gap-2 px-4 py-3`),children:i})]})}function cue(e){return{required:[...e.required],values:{...e.values},formats:{...e.formats},min:{...e.min},max:{...e.max},references:Object.fromEntries(e.references.map(e=>[e.column,e.target?`${e.table}.${e.target}`:e.table]))}}var j9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function lue(e,t){return e!==void 0&&t!==void 0?`${e} – ${t}`:e===void 0?t===void 0?null:`≤ ${t}`:`≥ ${e}`}function uue(e,t){let n=[];e.required.includes(t)&&n.push(`required`);let r=j9(e.values,t);r&&n.push(`values ${r.length}`);let i=j9(e.formats,t);i&&n.push(i);let a=lue(j9(e.min,t),j9(e.max,t));a&&n.push(a);let o=j9(e.references,t);return o&&n.push(`→ ${o}`),n}var due=/^\w+__\w+: /;function fue(e,t,n){return t.filter(t=>{let r=t;if(n){let e=`${n}: `;if(!t.startsWith(e))return!1;r=t.slice(e.length)}else if(due.test(t))return!1;return r.startsWith(`${e} `)||r.startsWith(`references.${e}:`)})}var M9=(e,t)=>e===`INTEGER`||e===`REAL`?`number`:t===`date`||t===`datetime`?t:null,pue=e=>e.columns?{columns:[...e.columns],unique:e.unique}:{expr:e.expr??``,unique:e.unique},N9=e=>`${e.unique?`unique `:``}(${`columns`in e?e.columns.join(`, `):e.expr})`,P9=e=>JSON.stringify([`columns`in e?e.columns:null,`expr`in e?e.expr:null,e.unique]),mue=(e,t)=>F9(e.map(P9),t.map(P9)),F9=(e,t)=>{let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))},I9=(e,t)=>JSON.stringify([e.required.includes(t),j9(e.values,t)??null,j9(e.formats,t)??null,j9(e.min,t)??null,j9(e.max,t)??null,j9(e.references,t)??null]);function hue({indexes:e,known:t,columns:n,onChange:r}){let[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),f=new Map(t.map(e=>[e.definition,e.inDb])),p=n.filter(e=>!o.includes(e)),m=()=>{a(!1),s([]),l(``),d(!1)};return(0,z.jsxs)(A9,{title:Zc(),actions:!i&&(0,z.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(!0),children:`+ ${Ns()}`}),children:[e.length===0&&!i&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:el()}),e.length>0&&(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(t=>{let n=N9(t),i=f.get(n);return(0,z.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border px-3 py-1.5`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:n}),i!==void 0&&(0,z.jsx)(`span`,{className:`ml-auto text-[12px] ${i?`text-ok`:`text-warn`}`,children:i?Wc():tl()}),(0,z.jsx)(`button`,{type:`button`,"aria-label":_c({index:n}),className:`px-1 text-[15px] text-muted-foreground hover:text-foreground ${i===void 0?`ml-auto`:``}`,onClick:()=>r(e.filter(e=>N9(e)!==n)),children:`×`})]},n)})}),i&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border px-3 py-2`,children:[o.length>0&&(0,z.jsx)(`ol`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,z.jsxs)(`li`,{className:`inline-flex items-center rounded-full bg-chip py-0.5 pr-1 pl-2.5 text-[13px] text-chip-foreground`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":mc({column:e}),className:`ml-1 px-1 opacity-60 hover:opacity-100`,onClick:()=>s(o.filter(t=>t!==e)),children:`×`})]},e))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`select`,{"aria-label":$s(),className:`h-9 rounded-md border bg-background px-2 text-base md:text-sm w-56 max-md:w-full font-mono`,value:c,onChange:e=>l(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`—`}),p.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsx)(V,{type:`button`,variant:`outline`,disabled:c===``,onClick:()=>{s([...o,c]),l(``)},children:Ms()}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":Ic(),className:`size-4`,checked:u,onChange:e=>d(e.target.checked)}),(0,z.jsx)(`span`,{children:Ic()})]})]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(V,{type:`button`,variant:`ghost`,onClick:m,children:Us()}),(0,z.jsx)(V,{type:`button`,disabled:o.length===0,onClick:()=>{let t={columns:o,unique:u},n=N9(t);e.some(e=>N9(e)===n)||r([...e,t]),m()},children:Ns()})]})]})]})}var gue={TEXT:[`date`,`datetime`,`markdown`],JSON:[`list`,`map`]},L9=[`markdown`,`list`,`map`],R9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function z9(e,t){let n=t.trim();if(n!==``){if(e===`INTEGER`||e===`REAL`){let e=Number(n);return Number.isFinite(e)?e:void 0}return e===`BOOLEAN`?n===`true`||n!==`false`&&void 0:n}}function B9({title:e,children:t,hints:n=[]}){return(0,z.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`h4`,{className:aA,children:e}),t,(0,z.jsx)(V9,{hints:n})]})}function V9({hints:e}){return e.length===0?null:(0,z.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-[12.5px] text-warn`,children:e.map(e=>(0,z.jsx)(`li`,{children:e},e))})}function _ue(e,t){return t.includes(`references.${e}: `)||/ not found in \S+ \(/.test(t)?`references`:t.includes(`${e} missing (`)?`required`:t.includes(` not in values (`)?`values`:`other`}function vue({column:e,type:t,draft:n,tables:r,hints:i,set:a,toggleRequired:o,onBack:s}){let c=R9(n.formats,e),l=R9(n.values,e)??[],u=M9(t,c),d=R9(n.references,e)??``,f=d.indexOf(`.`),p=f<0?d:d.slice(0,f),m=f<0?``:d.slice(f+1),h=t=>i.filter(n=>_ue(e,n)===t),g=!L9.includes(c),_=gue[t],v=n=>{let r=[...new Set(n.map(e=>l.find(t=>String(t)===e)??z9(t,e)))];a(`values`,e,r.length===0?void 0:r)},y=n=>{a(`formats`,e,n),L9.includes(n)&&a(`values`,e,void 0),M9(t,n)!==u&&(a(`min`,e,void 0),a(`max`,e,void 0))},b=(t,n)=>{let r=n===``?void 0:u===`number`?Number(n):n;a(t,e,r!==void 0&&typeof r==`number`&&!Number.isFinite(r)?void 0:r)},x=(t,n)=>a(`references`,e,t===``?void 0:n.trim()===``?t:`${t}.${n.trim()}`);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-5 text-[13px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,z.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-2`,onClick:s,children:`‹ ${Rs()}`}),(0,z.jsx)(`h3`,{className:`font-mono text-[15px] font-semibold`,children:e})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:Fc({type:t})})]}),(0,z.jsx)(B9,{title:Ac(),hints:h(`required`),children:(0,z.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":Ac(),className:`size-4`,checked:n.required.includes(e),onChange:t=>o(e,t.target.checked)}),(0,z.jsx)(`span`,{children:jc()})]})}),g&&(0,z.jsx)(B9,{title:Lc(),hints:h(`values`),children:(0,z.jsx)(VJ,{label:Lc(),value:l.map(String),onChange:v,placeholder:Rc(),removeLabel:e=>bc({value:e}),accept:e=>z9(t,e)!==void 0,unique:!0})}),_&&(0,z.jsx)(B9,{title:Ys(),children:(0,z.jsxs)(`select`,{"aria-label":Ys(),className:`h-9 rounded-md border bg-background px-2 text-base md:text-sm w-56 max-md:w-full`,value:c??``,onChange:e=>y(e.target.value===``?void 0:e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:cc()}),_.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})}),u&&(0,z.jsx)(`div`,{className:`flex flex-wrap gap-3 max-md:flex-col`,children:[`min`,`max`].map(t=>(0,z.jsx)(B9,{title:t===`min`?ac():ic(),children:(0,z.jsx)(Ik,{"aria-label":t===`min`?ac():ic(),type:u===`number`?`number`:u===`date`?`date`:`text`,className:`w-56 max-md:w-full`,value:String(R9(n[t],e)??``),onChange:e=>b(t,e.target.value)})},t))}),(0,z.jsx)(V9,{hints:g?h(`other`):[...h(`values`),...h(`other`)]}),(0,z.jsx)(B9,{title:lc(),hints:h(`references`),children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`select`,{"aria-label":lc(),className:`${oA} ${sA}`,value:p,onChange:e=>x(e.target.value,``),children:[(0,z.jsx)(`option`,{value:``,children:cc()}),r.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsx)(Ik,{"aria-label":uc(),placeholder:dc(),className:`${sA} font-mono`,disabled:p===``,value:m,onChange:e=>x(p,e.target.value)})]})})]})}function yue({fields:e,names:t,json:n,onChange:r}){let i=n.filter(t=>!e.includes(t)),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),l=i.includes(s)?s:``,u=e=>Object.hasOwn(t,e)?t[e]:e,d=()=>{o(!1),c(``)},f=n=>{(!Object.hasOwn(t,n)||window.confirm(Ec({view:u(n)})))&&r(e.filter(e=>e!==n))};return(0,z.jsxs)(A9,{title:Yc(),actions:i.length>0&&!a&&(0,z.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!0),children:`+ ${Ps()}`}),children:[e.length>0&&(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border px-3 py-1.5`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:u(e)}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Cc({view:u(e)}),className:`px-1 text-[15px] text-muted-foreground hover:text-foreground ml-auto`,onClick:()=>f(e),children:`×`})]},e))}),i.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:sc()}):a?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border px-3 py-2`,children:[(0,z.jsxs)(`select`,{"aria-label":zc(),className:`${oA} ${sA} font-mono`,value:l,onChange:e=>c(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`—`}),i.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,z.jsx)(V,{type:`button`,variant:`ghost`,onClick:d,children:Us()}),(0,z.jsx)(V,{type:`button`,disabled:l===``,onClick:()=>{r([...e,l]),d()},children:Ps()})]})]}):e.length===0&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:el()})]})}var H9=e=>e instanceof Sv&&e.status===409&&`current`in e.body,U9=e=>e instanceof Error?e.message:String(e);function bue(e){let t=Sg(),{data:n}=ry(),r=OX(),i=Object.keys(e.columns),[a,o]=(0,B.useState)(()=>r?null:i.find(t=>!e.fixed.includes(t))??null),[s]=(0,B.useState)(e.base),c=e.views.filter(t=>t.path.length===e.target.path.length+1),[l]=(0,B.useState)(()=>({rules:e.initial,indexes:(e.indexes??[]).map(pue),views:c.map(e=>e.path.at(-1))})),[u,d]=(0,B.useState)(l),f=u.rules,p=e=>d(t=>({...t,rules:e(t.rules)})),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(!1),S=D$(u,300),C=t=>({...e.indexes!==void 0&&!mue(t.indexes,l.indexes)?{indexes:t.indexes}:{},...F9(t.views,l.views)?{}:{views:t.views}}),w=JSON.stringify(u.rules)!==JSON.stringify(l.rules)||Object.keys(C(u)).length>0,T=e=>{(!w||window.confirm(Ks()))&&e()},E=t=>T(()=>e.onOpenView(t)),D=e.views.filter(t=>u.views.includes(t.path[e.target.path.length]));(0,B.useEffect)(()=>{let t=!0;return Uv.previewRules(e.target,S.rules,s,C(S)).then(e=>{t&&(h(e),_(S),y(null))},e=>{t&&(H9(e)?x(!0):y(U9(e)))}),()=>{t=!1}},[S,s,e.target]);let O=()=>{t.invalidateQueries({queryKey:[`schema`]}),t.invalidateQueries({queryKey:[`meta`]}),t.invalidateQueries({queryKey:[`git`]}),t.invalidateQueries({queryKey:[`gitdiff`]})},k=H_({mutationFn:()=>Uv.saveRules(e.target,u.rules,s,C(u)),onSuccess:()=>{O(),e.onDone()},onError:e=>H9(e)?x(!0):y(U9(e))}),A=(e,t,n)=>p(r=>{let i={...r[e]};return n===void 0?delete i[t]:i[t]=n,{...r,[e]:i}}),j=(e,t)=>p(n=>({...n,required:t?[...n.required.filter(t=>t!==e),e]:n.required.filter(t=>t!==e)})),M=()=>{window.confirm(Ks())&&(O(),e.onDone())},N=m?.added??[],P=m?.removed??[],F=[...(m?.indexes?.added??[]).map(e=>Qs({index:e})),...(m?.indexes?.removed??[]).map(e=>nc({index:e}))],ee=a===null?void 0:e.columns[a],I=(0,z.jsxs)(`nav`,{className:`flex flex-col gap-1`,children:[i.map(t=>{let n=e.fixed.includes(t),r=uue(f,t),i=!n&&I9(f,t)!==I9(l.rules,t),s=a===t;return(0,z.jsxs)(`button`,{type:`button`,disabled:n,"aria-current":s||void 0,onClick:()=>o(t),className:`flex flex-col items-start gap-0.5 rounded-md px-3 py-2 text-left disabled:cursor-default ${s?`bg-accent`:`hover:bg-background disabled:hover:bg-transparent`}`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[13px] ${s?`font-semibold`:``}`,children:t}),(n||r.length>0||i)&&(0,z.jsxs)(`span`,{className:`text-[12px] text-muted-foreground`,children:[n?Js():r.join(` · `),i&&(0,z.jsx)(`span`,{className:`text-tomato`,children:`${r.length>0?` · `:``}${Ws()}`})]})]},t)}),D.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>E(e.name),className:`rounded-md px-3 py-2 text-left font-mono text-[13px] hover:bg-background`,children:`${e.name} ▸`},e.name))]}),te=a!==null&&ee!==void 0&&(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,z.jsx)(vue,{column:a,type:ee,draft:f,tables:(n?.tables??[]).map(e=>e.name),hints:fue(a,N,e.viewName),set:A,toggleRequired:j,onBack:r?()=>o(null):void 0},a)}),ne=(0,z.jsxs)(`footer`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-[13px] ${e.footer===void 0?`border-t pt-3`:Zk}`,children:[b&&(0,z.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-3 text-warn`,children:[(0,z.jsx)(`span`,{children:Gs()}),(0,z.jsx)(V,{type:`button`,variant:`outline`,onClick:M,children:rc()})]}),m&&(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N.length>0&&(0,z.jsx)(`p`,{className:`text-warn`,children:Ls({count:N.length})}),P.length>0&&(0,z.jsx)(`p`,{className:`text-ok`,children:kc({count:P.length})}),F.map(e=>(0,z.jsx)(`p`,{className:`font-mono`,children:e},e)),!m.changed&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:oc()}),N.length>0&&(0,z.jsx)(`ul`,{className:`max-h-24 list-disc overflow-y-auto pl-5 text-[12.5px] text-muted-foreground`,children:N.slice(0,5).map(e=>(0,z.jsx)(`li`,{children:e},e))})]}),v!==null&&(0,z.jsx)(`p`,{className:`w-full text-err`,children:v}),(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 justify-end gap-2`,children:[(0,z.jsx)(V,{type:`button`,variant:`outline`,onClick:e.onDone,children:Us()}),(0,z.jsx)(V,{type:`button`,disabled:!m?.changed||g!==u||v!==null||b||k.isPending,onClick:()=>k.mutate(),children:Mc()})]})]}),re=e.trail&&e.trail.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground`,children:`·`}),(0,z.jsxs)(`nav`,{"aria-label":Hs(),className:`flex flex-wrap items-center gap-x-1 gap-y-1 font-mono`,children:[e.trail.map(e=>(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":Vs({name:e.label}),className:`rounded-md px-1.5 py-0.5 text-muted-foreground underline-offset-2 hover:bg-background hover:text-foreground hover:underline`,onClick:()=>T(e.onOpen),children:e.label}),(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground`,children:`›`})]},e.label)),(0,z.jsx)(`span`,{className:`px-1.5 font-semibold`,title:e.viewName,children:e.here})]})]}),ie=(0,z.jsx)(`div`,{className:`bg-muted p-2`,children:I}),ae=te&&(0,z.jsx)(`div`,{className:`px-4 py-4`,children:te});return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[13px]`,children:[(0,z.jsx)(A9,{title:Uc(),heading:re,flush:!0,children:r?ae||ie:(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,14rem)_minmax(0,1fr)]`,children:[(0,z.jsx)(`div`,{className:`border-r bg-muted p-2`,children:I}),ae||(0,z.jsx)(`div`,{})]})}),e.indexes!==void 0&&(0,z.jsx)(hue,{indexes:u.indexes,known:e.indexes,columns:i,onChange:e=>d(t=>({...t,indexes:e}))}),(0,z.jsx)(yue,{fields:u.views,names:Object.fromEntries(c.map(e=>[e.path.at(-1),e.name])),json:i.filter(t=>e.columns[t]===`JSON`),onChange:e=>d(t=>({...t,views:e}))}),e.footer===void 0?ne:e.footer&&(0,W_.createPortal)(ne,e.footer)]})}var W9=(e,t)=>e!==void 0&&t!==void 0?`${e} – ${t}`:e===void 0?t===void 0?null:`≤ ${t}`:`≥ ${e}`,G9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,K9=`border-b px-2 py-1.5 text-left align-top`,q9=`w-full [&_tr:last-child>td]:border-b-0`,J9=()=>(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:el()}),Y9=e=>({target:{table:e.table,path:e.path},viewName:e.name});function xue({editing:e,meta:t,schema:n,onEdit:r,onDone:i,footer:a}){let o=e.viewName===void 0?void 0:t.views.find(t=>t.name===e.viewName),s=t.tables.find(t=>t.name===e.target.table),c=o??s;if(!c||n.base===void 0)return null;let l=e.target.path.length,u=[{label:e.target.table,onOpen:()=>r({target:{table:e.target.table,path:[]}})},...e.target.path.slice(0,-1).flatMap((n,i)=>{let a=t.views.find(t=>t.table===e.target.table&&t.path.length===i+1&&t.path.every((t,n)=>e.target.path[n]===t));return a?[{label:n,onOpen:()=>r(Y9(a))}]:[]})],d=t.views.filter(t=>t.table===e.target.table&&t.path.length>l&&e.target.path.every((e,n)=>t.path[n]===e));return(0,z.jsx)(bue,{target:e.target,viewName:e.viewName,columns:o?o.columns:n.columns,fixed:o?o.identity:[n.key],initial:cue(c),base:n.base,indexes:o?void 0:n.indexes,views:d.map(e=>({name:e.name,path:e.path})),trail:l>0?u:void 0,here:e.target.path.at(-1),onOpenView:e=>{let n=t.views.find(t=>t.name===e);n&&r(Y9(n))},onDone:i,footer:a},`${e.target.table}/${e.target.path.join(`.`)}`)}function Sue({view:e,editor:t}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[12.5px]`,children:[(0,z.jsx)(A9,{title:hl(),children:(0,z.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:il()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:e.parent}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Xc()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:e.identity.length>0?e.identity.join(`, `):`—`}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Gc()}),(0,z.jsx)(`dd`,{children:e.inDb?_l():rl()})]})}),t??(0,z.jsx)(A9,{title:Uc(),children:(0,z.jsx)(`div`,{className:`-mx-2 overflow-x-auto`,children:(0,z.jsx)(`table`,{className:q9,children:(0,z.jsx)(`tbody`,{children:Object.entries(e.columns).map(([t,n])=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${K9} font-mono`,children:t}),(0,z.jsx)(`td`,{className:`${K9} font-mono text-muted-foreground`,children:n}),(0,z.jsx)(`td`,{className:`${K9} text-muted-foreground`,children:e.identity.includes(t)?Xc():[Object.hasOwn(e.declared,t)?Kc():Qc(),...e.required.includes(t)?[sl()]:[],...G9(e.formats,t)?[G9(e.formats,t)]:[],...(()=>{let n=W9(G9(e.min,t),G9(e.max,t));return n?[n]:[]})()].join(` · `)}),(0,z.jsx)(`td`,{className:`${K9} font-mono text-muted-foreground`,children:Object.hasOwn(e.values,t)?e.values[t]?.map(String).join(`, `):``})]},t))})})})})]})}function Cue({table:e,view:t,path:n,open:r,onOpenChange:i}){let[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),{data:l}=ry(),u=t?.table??e,{data:d,error:f}=V_({queryKey:[`schema`,u],queryFn:()=>Uv.schema(u),enabled:r&&(!t||a!==null)}),p=t!==void 0&&(a===null||a.viewName!==void 0),m=!Yv()&&l!==void 0&&!l.configError&&(t!==void 0||d!==void 0),h=a&&l&&d?(0,z.jsx)(xue,{editing:a,meta:l,schema:d,onEdit:o,onDone:()=>o(null),footer:s}):null;return(0,z.jsx)(qk,{open:r,onOpenChange:i,children:(0,z.jsxs)(Qk,{pinned:!0,className:a?`sm:max-w-4xl`:`sm:max-w-2xl`,children:[(0,z.jsxs)($k,{pinned:!0,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 max-sm:justify-center`,children:[(0,z.jsx)(nA,{children:pl({table:e})}),a&&(0,z.jsx)(sue,{variant:`outline`,className:`border-tomato text-[12px] text-tomato`,children:Jc()})]}),(0,z.jsx)(rA,{children:a?qc():t?gl():ll()}),n&&!(a&&!p)&&(0,z.jsx)(`p`,{className:`font-mono text-[12px] break-all text-muted-foreground md:hidden`,children:n}),m&&!a&&(0,z.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o(t?Y9(t):{target:{table:e,path:[]}}),children:qs()})]}),(0,z.jsx)(eA,{children:p?(0,z.jsx)(Sue,{view:t,editor:h??(a&&f?(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:f.message}):null)}):(0,z.jsxs)(z.Fragment,{children:[f&&(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:f.message}),d&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[12.5px]`,children:[(0,z.jsx)(A9,{title:cl(),children:(0,z.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:al()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:d.mode===`files`?d.files:d.path}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:$c()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:d.key}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Gc()}),(0,z.jsx)(`dd`,{children:d.inDb?ul():rl()})]})}),h??(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(A9,{title:Uc(),children:(0,z.jsx)(`div`,{className:`-mx-2 overflow-x-auto`,children:(0,z.jsx)(`table`,{className:q9,children:(0,z.jsx)(`tbody`,{children:Object.entries(d.columns).map(([e,t])=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${K9} font-mono`,children:e}),(0,z.jsx)(`td`,{className:`${K9} font-mono text-muted-foreground`,children:t}),(0,z.jsx)(`td`,{className:`${K9} text-muted-foreground`,children:e===d.key?$c():[e in d.declared?Kc():Qc(),...d.required.includes(e)?[sl()]:[],...G9(d.formats,e)?[G9(d.formats,e)]:[],...(()=>{let t=W9(G9(d.min,e),G9(d.max,e));return t?[t]:[]})()].join(` · `)}),(0,z.jsx)(`td`,{className:`${K9} font-mono text-muted-foreground`,children:Object.hasOwn(d.values,e)?d.values[e]?.map(String).join(`, `):``})]},e))})})})}),(0,z.jsx)(A9,{title:ol(),children:d.references.length===0?(0,z.jsx)(J9,{}):d.references.map(e=>(0,z.jsxs)(`div`,{className:`rounded-md border px-3 py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-mono`,children:[(0,z.jsx)(`span`,{children:e.column}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,z.jsx)(`span`,{children:`${e.table}.${e.target}`}),(0,z.jsx)(`span`,{className:`ml-auto font-sans text-[11px] ${e.problems.length>0?`text-warn`:`text-ok`}`,children:e.problems.length>0?Hc({count:e.problems.length}):`OK`})]}),e.problems.length>0&&(0,z.jsx)(`ul`,{className:`mt-1.5 list-disc pl-5 text-[11.5px] text-muted-foreground`,children:e.problems.map(e=>(0,z.jsx)(`li`,{children:e},e))})]},e.column))})]}),!h&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(A9,{title:Zc(),children:[d.indexes.length===0&&d.otherIndexes.length===0?(0,z.jsx)(J9,{}):(0,z.jsx)(`div`,{className:`-mx-2 overflow-x-auto`,children:(0,z.jsx)(`table`,{className:q9,children:(0,z.jsxs)(`tbody`,{children:[d.indexes.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${K9} font-mono`,children:e.definition}),(0,z.jsx)(`td`,{className:`${K9} font-mono text-[11px] text-muted-foreground`,children:e.name}),(0,z.jsx)(`td`,{className:`${K9} ${e.inDb?`text-ok`:`text-warn`}`,children:e.inDb?Wc():tl()})]},e.name)),d.otherIndexes.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${K9} font-mono`,children:e}),(0,z.jsx)(`td`,{className:`${K9} text-[11px] text-muted-foreground`,colSpan:2,children:ml()})]},e))]})})}),d.indexes.some(e=>!e.inDb)&&(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:nl()})]}),(0,z.jsx)(A9,{title:Yc(),children:d.views.length===0?(0,z.jsx)(J9,{}):d.views.map(e=>(0,z.jsxs)(`div`,{className:`rounded-md border px-3 py-2`,style:{marginLeft:`${(e.depth-1)*16}px`},children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-mono`,children:[(0,z.jsx)(`a`,{href:`#/t/${encodeURIComponent(e.name)}`,className:`underline-offset-2 hover:underline`,onClick:()=>i(!1),children:e.name}),(0,z.jsx)(`span`,{className:`ml-auto font-sans text-[11px] ${e.inDb?`text-ok`:`text-warn`}`,children:e.inDb?Wc():tl()})]}),e.inDb&&(0,z.jsx)(`p`,{className:`mt-1 font-mono text-[11.5px] text-muted-foreground`,children:Object.keys(e.columns).join(`, `)}),e.problems.length>0&&(0,z.jsx)(`ul`,{className:`mt-1.5 list-disc pl-5 text-[11.5px] text-muted-foreground`,children:e.problems.map(e=>(0,z.jsx)(`li`,{children:e},e))})]},e.name))})]})]})]})}),(0,z.jsx)(`div`,{ref:c,className:`shrink-0 empty:hidden`})]})})}function wue({items:e,onOpenRecord:t}){return e.length===0?null:(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsxs)(V,{variant:`outline`,size:`sm`,className:`text-warn`,children:[(0,z.jsx)(kk,{className:`size-3.5`}),` `,Cd({count:e.length})]})}),(0,z.jsx)(zk,{align:`end`,className:`max-h-80 w-[min(440px,calc(100vw-2rem))] overflow-auto p-0`,children:(0,z.jsx)(`ul`,{"aria-label":bd(),className:`text-[12px] max-md:text-[13px]`,children:e.map((e,n)=>(0,z.jsxs)(`li`,{className:`border-b px-3 py-2 last:border-b-0`,children:[e.key!==null&&(0,z.jsx)(`button`,{type:`button`,className:`font-mono font-semibold text-tomato hover:underline`,onClick:()=>t(e.key),children:e.key}),e.view!==null&&(0,z.jsx)(`a`,{href:`#/t/${encodeURIComponent(e.view)}`,className:`font-mono font-semibold text-tomato hover:underline`,children:e.view}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:e.text})]},`${n}-${e.text}`))})})]})}var X9=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Tue(e,t){return e.path.flatMap((n,r)=>{let i=t[e.identity[r+1]];return[n,typeof i==`number`?i:String(i)]})}function Z9(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&(typeof e==`number`||/^\d+$/.test(e)))n=n[Number(e)];else if(X9(n)&&typeof e==`string`&&Object.hasOwn(n,e))n=n[e];else return;return n}var Q9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function Eue({view:e,rowKey:t,row:n,onClose:r,onOpenRecord:i}){let a=Sg(),o=oy(),{connected:s}=ay(),c=OX(),l=n?String(n[e.identity[0]]):void 0,{data:u,error:d}=V_({queryKey:[`record`,e.table,l],queryFn:()=>Uv.record(e.table,l),enabled:l!==void 0}),f=n?Tue(e,n):[],p=u?Z9(u.row,f):void 0,m=p!==void 0&&!X9(p),h=Object.keys(e.columns).filter(t=>!e.identity.includes(t)),g=p===void 0?void 0:m?{value:p}:Object.fromEntries(h.map(e=>[e,Q9(p,e)??null])),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(new Set),[C,w]=(0,B.useState)(0),T=_!==null&&y!==null&&LJ(_,y).length>0,E=s&&!Yv()&&p!==void 0,D=g?JSON.stringify(g):void 0;(0,B.useEffect)(()=>{g&&!T&&(v(g),b(g),S(new Set),w(e=>e+1))},[D,T]);let O=H_({mutationFn:({detail:t,values:n})=>{let r=e.path[0],i=Z9(t.row,f),a=m?n.value:Object.fromEntries(Object.entries({...i,...n}).filter(([,e])=>e!=null)),o=zJ(t.row,f,a);return Uv.update(e.table,l,{[r]:o[r]},{[r]:t.row[r]})},onMutate:()=>o({type:`saved`,table:e.table,key:l,at:Date.now()}),onSuccess:()=>{v(y),a.invalidateQueries({queryKey:[`record`,e.table,l]})},onError:t=>{o({type:`cancelled`,table:e.table,key:l}),t instanceof Sv&&t.status===409&&a.invalidateQueries({queryKey:[`record`,e.table,l]})}}),k=()=>{if(!u||!_||!y||!T||x.size>0||!E||O.isPending)return;let e=Object.fromEntries(LJ(_,y).map(e=>[e,y[e]??null]));O.mutate({detail:u,values:e})};$Z(r,!T),(0,B.useEffect)(()=>{let e=e=>{e.key===`s`&&(e.metaKey||e.ctrlKey)&&!Yv()&&(e.preventDefault(),k())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)});let A=m?[`value`]:h,j=_&&y?LJ(_,y).length:0,M=n===void 0||u!==void 0&&p===void 0;return(0,z.jsxs)($X,{...ZZ,resizeLabel:$a(),"aria-label":jd(),children:[(0,z.jsxs)(eZ,{onClose:r,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono font-bold`,title:t,children:t}),(0,z.jsxs)(V,{variant:`ghost`,size:`sm`,disabled:!n,onClick:i,children:[(0,z.jsx)(rO,{className:`size-3.5`}),` `,Fd({table:e.table})]})]}),(0,z.jsx)(`div`,{className:`truncate px-4 pt-3 font-mono text-[13px] text-muted-foreground`,children:u?`${u.file} › ${f.join(`.`)}`:ad({parent:e.parent})}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:[d&&(0,z.jsx)(`p`,{className:`mb-2 text-[11.5px] text-err`,children:d.message}),M&&(0,z.jsx)(`p`,{className:`mb-2 text-[11.5px] text-err`,children:Md()}),!s&&(0,z.jsx)(`p`,{className:`mb-2 text-[11.5px] text-err`,children:Ia()}),n&&e.identity.length>0&&(0,z.jsx)(`dl`,{className:`mb-3.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[12px] max-md:text-[13px]`,children:e.identity.map(e=>(0,z.jsxs)(`div`,{className:`contents`,children:[(0,z.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:String(n[e]??``)})]},e))}),y&&(0,z.jsx)(`fieldset`,{disabled:!E,className:`m-0 min-w-0 border-0 p-0`,children:A.map(t=>{let n=e.references.find(e=>e.column===t),r=Q9(e.formats,t),i=Q9(e.columns,t),a=e.required.includes(t);return(0,z.jsx)(`div`,{className:`mb-3.5`,children:(0,z.jsx)(_Y,{readOnly:!E,path:[t],label:(0,z.jsxs)(`div`,{className:`flex flex-1 justify-between text-[12px] font-semibold text-muted-foreground max-md:text-[13px]`,children:[(0,z.jsxs)(`span`,{className:a&&y[t]==null?`text-warn`:void 0,children:[t,a&&(0,z.jsx)(`span`,{"aria-label":Qa(),children:` *`})]}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] font-medium max-md:text-[11.5px]`,children:n?`→ ${n.table}`:r??i})]}),value:y[t],type:i,format:r,allowed:Q9(e.values,t),min:Q9(e.min,t),max:Q9(e.max,t),reference:n,onChange:e=>b({...y,[t]:e}),onValidity:(e,t)=>S(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})},`${t}:${C}`)},t)})})]}),!Yv()&&(0,z.jsxs)(tZ,{className:`max-md:flex-wrap`,children:[(0,z.jsxs)(`span`,{className:`mr-auto flex min-w-0 flex-col text-[13px] text-muted-foreground max-md:basis-full`,children:[j>0?Da({count:j}):l===void 0?null:(0,z.jsx)(HX,{table:e.table,recordKey:l}),O.isError&&(0,z.jsx)(`span`,{className:`text-err`,children:O.error instanceof Sv&&O.error.status===409?Id():O.error.message})]}),(0,z.jsx)(V,{variant:`outline`,size:c?`lg`:`sm`,disabled:!T,onClick:()=>{_&&(b(_),S(new Set),w(e=>e+1))},children:Fa()}),(0,z.jsx)(V,{size:c?`lg`:`sm`,className:`max-md:flex-1`,disabled:!T||x.size>0||O.isPending||!E,title:s?void 0:yt(),onClick:k,children:c?St():ro()})]})]})}var Due=100;function Oue(e){try{return new Set(JSON.parse(localStorage.getItem(`yamlite-hidden:${e}`)??`[]`))}catch{return new Set}}function kue(e,t){try{localStorage.setItem(`yamlite-hidden:${e}`,JSON.stringify([...t]))}catch{}}function Aue({drawer:e,headerActions:t}){let{table:n}=k$.useParams(),r=k$.useSearch(),i=Nh({from:k$.fullPath}),a=Nh(),{data:o}=ry(),{warnings:s}=ay(),c=o?.tables.find(e=>e.name===n),l=c?void 0:o?.views.find(e=>e.name===n),u=r.filter??[],[d,f]=(0,B.useState)(()=>Oue(n)),[p,m]=(0,B.useState)(!1),h=rue(n),g=U_({queryKey:l?[`rows`,l.table,l.name,{sort:r.sort,filters:u,search:r.q}]:[`rows`,n,{sort:r.sort,filters:u,search:r.q}],queryFn:({pageParam:e})=>Uv.rows(n,{limit:Due,offset:e,sort:r.sort,filters:u,search:r.q}),initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.rows.length,0);return n<e.total?n:void 0},enabled:c!==void 0||l!==void 0}),_=(0,B.useMemo)(()=>g.data?.pages.flatMap(e=>e.rows)??[],[g.data]),v=l1(),y=c?.name,b=(0,B.useMemo)(()=>y?r1(v,y):void 0,[v,y]),x=(0,B.useMemo)(()=>{if(!b)return _;let e=[...b.values()].filter(e=>e.op===`insert`&&e.after).map(e=>e.after);return e.length>0?[...e,..._]:_},[b,_]),S=g.data?.pages[0]?.total??0,{hasNextPage:C,isFetchingNextPage:w,isFetchNextPageError:T,fetchNextPage:E}=g,D=(0,B.useCallback)(()=>{C&&!w&&!T&&E()},[C,w,T,E]),O=(0,B.useCallback)(e=>void i({search:t=>({...t,...e})}),[i]),k=(0,B.useCallback)(e=>O({filter:e.filters.length>0?e.filters:void 0,q:e.search}),[O]);if(!c&&!l)return null;let A=c?c.columns:l.columns,j=c?c.key:l?.identity[0]??``,M=c?[c.key]:l?.identity??[],N=Object.entries(A).filter(([e])=>M.includes(e)||!d.has(e)).sort(([e],[t])=>Number(t===j)-Number(e===j)).map(([e,t])=>{let n=c??l,r=n.references.find(t=>t.column===e);return{name:e,type:t,format:Object.hasOwn(n.formats,e)?n.formats[e]:void 0,note:r?`→ ${r.table}`:void 0,reference:r}}),P=l?e=>l.identity.map(t=>String(e[t])).join(`/`):void 0,F=e=>O({key:e}),ee=l&&r.key!==void 0?x.find(e=>P?.(e)===r.key):void 0,I=c?c.name:l.table,te=u7({[I]:s[I]??[]},new Set(o?.views.map(e=>e.name))),ne=te.filter(e=>e.view===(l?l.name:null)),re=e=>void a({to:`/t/$table`,params:{table:l?l.table:n},search:{key:e}}),ie=e=>{let[t,n]=(r.sort??``).split(`:`),i=t===e?n===`asc`?`${e}:desc`:void 0:`${e}:asc`;O({sort:i})},ae=c?c.mode===`files`?c.files:c.path:`from ${l?.parent}`;return(0,z.jsxs)(`div`,{className:`relative flex min-w-0 flex-1`,children:[(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2.5 border-b px-[18px] py-3 max-md:gap-2 max-md:px-3 max-md:py-2`,children:[(0,z.jsx)(`h1`,{title:n,className:`min-w-0 truncate text-lg font-semibold tracking-tight max-md:sr-only`,children:n}),c?(0,z.jsx)(`span`,{className:`min-w-0 shrink-[100] truncate rounded bg-panel px-1.5 font-mono text-[11px] text-muted-foreground max-md:hidden`,children:c.mode===`files`?c.files:c.path}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`min-w-0 shrink-[100] truncate rounded bg-panel px-1.5 font-mono text-[11px] text-muted-foreground max-md:hidden`,children:ad({parent:l?.parent??``})}),(0,z.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 text-[11px] whitespace-nowrap text-muted-foreground`,children:nd()})]}),(0,z.jsx)(`span`,{className:`shrink-0 text-[12px] whitespace-nowrap text-muted-foreground`,children:c?md({count:S}):_d({count:S})}),(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2.5 max-md:ml-0 max-md:w-full max-md:shrink max-md:overflow-x-auto max-md:pb-0.5`,children:[(0,z.jsx)(wue,{items:ne,onOpenRecord:re}),(0,z.jsxs)(V,{variant:`outline`,size:`sm`,onClick:()=>m(!0),children:[(0,z.jsx)(CO,{className:`size-3.5`}),` `,vd()]}),(0,z.jsxs)(S5,{children:[(0,z.jsx)(C5,{asChild:!0,children:(0,z.jsxs)(V,{variant:`outline`,size:`sm`,children:[(0,z.jsx)(xO,{className:`size-3.5`}),` `,td()]})}),(0,z.jsx)(w5,{children:Object.keys(A).filter(e=>!M.includes(e)).map(e=>(0,z.jsx)(Goe,{checked:!d.has(e),onCheckedChange:t=>{let r=new Set(d);t?r.delete(e):r.add(e),f(r),kue(n,r)},children:e},e))})]}),c&&t?.(c)]})]}),(0,z.jsx)(aue,{columns:A,filters:u,search:r.q,onChange:k}),g.isError&&(0,z.jsx)(`div`,{role:`alert`,className:`border-b px-[18px] py-2 text-err`,children:g.error.message}),(!g.isError||_.length>0)&&(0,z.jsx)(p9.Provider,{value:r.q?.trim()??``,children:(0,z.jsx)(S9,{columns:N,rows:x,preview:b,keyCol:j,rowId:P,selectedKey:r.key,onSelect:F,onEndReached:D,flagged:c?Qse(te):void 0,sort:r.sort,onSort:ie,widths:h.widths,onResize:h.setWidth,pinned:!h.unpinned,onTogglePin:h.togglePin})})]}),c&&r.key!==void 0&&e?.(c,r.key),l&&r.key!==void 0&&(0,z.jsx)(Eue,{view:l,rowKey:r.key,row:ee,onClose:()=>O({key:void 0}),onOpenRecord:()=>ee&&re(String(ee[j]))},r.key),p&&(0,z.jsx)(Cue,{table:n,view:l,path:ae,open:!0,onOpenChange:m})]})}function jue(){let{data:e}=ry(),t=e?.tables[0];return e?t?(0,z.jsx)(Ph,{to:`/t/$table`,params:{table:t.name}}):(0,z.jsx)(yY,{title:xt()}):null}function Mue({table:e}){let[t,n]=(0,B.useState)(!1),{connected:r}=ay(),i=OX(),{filter:a}=k$.useSearch(),o=ace(e,a??[]),s=oce(e,a??[]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{size:i?`lg`:`sm`,disabled:!r,title:r?void 0:yt(),className:i?`fixed right-4 bottom-[calc(56px+env(safe-area-inset-bottom))] z-30 rounded-full shadow-lg`:void 0,onClick:()=>n(!0),children:hi()}),(0,z.jsx)(vY,{table:e,open:t,onOpenChange:n,initial:o,initialKey:s},JSON.stringify([o,s]))]})}function Nue({table:e,recordKey:t}){let[n,r]=(0,B.useState)(!1),{connected:i}=ay();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":yi(),disabled:!i,className:`shrink-0 whitespace-nowrap text-[11px] text-muted-foreground hover:text-foreground disabled:opacity-50 max-md:px-2 max-md:py-2 max-md:text-[13px]`,onClick:()=>r(!0),children:vi()}),n&&(0,z.jsx)(tQ,{table:e,recordKey:t,open:!0,onOpenChange:r})]})}function Pue(){let{table:e}=k$.useParams();return(0,z.jsx)(Aue,{headerActions:Yv()?void 0:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Kk,{table:e}),(0,z.jsx)(Mue,{table:e})]}),drawer:(e,t)=>(0,z.jsx)(eQ,{table:e,recordKey:t,headerActions:Yv()?void 0:(0,z.jsx)(Nue,{table:e,recordKey:t})},`${e.name}:${t}`)},e)}var $9=ng(()=>nY(()=>import(`./PageView-BsEhcE48.js`),__vite__mapDeps([3,1,2,4]),import.meta.url),`PageView`);function Fue(){let{page:e}=N$.useParams();return(0,z.jsx)($9,{name:e},e)}function Iue(){let{page:e}=P$.useParams();return(0,z.jsx)($9,{name:e,app:!0},e)}O$.update({component:Sce}),k$.update({component:Pue}),A$.update({component:Xle}),F$.update({component:L$}),N$.update({component:Fue}),P$.update({component:Iue}),j$.update({component:()=>Yv()?(0,z.jsx)(Ph,{to:`/`}):(0,z.jsx)(tue,{})}),M$.update({component:ng(()=>nY(()=>import(`./ErdView-CWmAQgo6.js`),__vite__mapDeps([5,1,2,6]),import.meta.url),`ErdView`)});var Lue=Qh({getParentRoute:()=>O$,path:`/`,component:jue}),Rue=O$.addChildren([Lue,k$,A$,j$,M$,N$,P$,F$]);function zue(e){return gg({routeTree:Rue,history:e===void 0?Tp():Ep({initialEntries:[`/app/${encodeURIComponent(e)}`]}),context:{app:e}})}function Bue(e,t={}){let n=zue(t.app);document.documentElement.lang=E();let r=(0,Ld.createRoot)(e);return r.render((0,z.jsx)(B.StrictMode,{children:(0,z.jsx)(bee,{children:(0,z.jsx)(yg,{router:n})})})),()=>r.unmount()}async function Vue(){let e=document.getElementById(`root`);if(Gv())try{let{loadStatic:e}=await nY(async()=>{let{loadStatic:e}=await import(`./load-BsZuQtRZ.js`);return{loadStatic:e}},__vite__mapDeps([7,1,4]),import.meta.url),{api:t,snapshot:n}=await e();Hv(t),Kv(n)}catch(t){document.documentElement.lang=E(),(0,Ld.createRoot)(e).render((0,z.jsx)(Rd,{error:t}));return}Bue(e,{app:XJ(location.href,document.baseURI)})}Vue();export{tre as $,F_ as $t,CX as A,Wte as At,sG as B,ry as Bt,m$ as C,bA as Ct,OX as D,Hte as Dt,eQ as E,gA as Et,YJ as F,tO as Ft,VB as G,Lv as Gt,vK as H,Sv as Ht,TJ as I,H as It,KB as J,L_ as Jt,Kne as K,iv as Kt,lJ as L,V as Lt,yX as M,xk as Mt,yY as N,sk as Nt,xX as O,LA as Ot,nY as P,NO as Pt,oV as Q,I_ as Qt,$q as R,iy as Rt,i$ as S,XA as St,ZQ as T,_A as Tt,WV as U,Uv as Ut,cG as V,Yv as Vt,UB as W,Rv as Wt,cV as X,R_ as Xt,IV as Y,z_ as Yt,zB as Z,P_ as Zt,y0 as _,dj as _t,$se as a,Tg as an,RB as at,_1 as b,ZA as bt,J3 as c,Sg as cn,X as ct,S2 as d,Sh as dn,tN as dt,N_ as en,dV as et,C2 as f,Cd as fn,CM as ft,C0 as g,fne as gt,o2 as h,hne as ht,q7 as i,Zg as in,$B as it,wX as j,kk as jt,TX as k,xA as kt,O2 as l,Yh as ln,qR as lt,u2 as m,xt as mn,lj as mt,_le as n,h_ as nn,lV as nt,x5 as o,Fg as on,BB as ot,T2 as p,pi as pn,SN as pt,QB as q,V_ as qt,mle as r,t_ as rn,iV as rt,j8 as s,Ig as sn,WB as st,y9 as t,A_ as tn,uV as tt,$ as u,Nh as un,G as ut,E1 as v,W as vt,QQ as w,pA as wt,p$ as x,oj as xt,T1 as y,aj as yt,iG as z,ay as zt};
|
|
123
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return vae(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=t5.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function coe(){return{exit:{taskListCheckValueChecked:i5,taskListCheckValueUnchecked:i5,paragraph:uoe}}}function loe(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:doe}}}function i5(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function uoe(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function doe(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=t5.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function foe(){return[Bie(),sae(),dae(),toe(),coe()]}function poe(e){return{extensions:[Vie(),cae(e),fae(),soe(e),loe()]}}var moe={tokenize:boe,partial:!0},a5={tokenize:xoe,partial:!0},o5={tokenize:Soe,partial:!0},s5={tokenize:Coe,partial:!0},hoe={tokenize:woe,partial:!0},c5={name:`wwwAutolink`,tokenize:voe,previous:p5},l5={name:`protocolAutolink`,tokenize:yoe,previous:m5},u5={name:`emailAutolink`,tokenize:_oe,previous:h5},d5={};function goe(){return{text:d5}}for(var f5=48;f5<123;)d5[f5]=u5,f5++,f5===58?f5=65:f5===91&&(f5=97);d5[43]=u5,d5[45]=u5,d5[46]=u5,d5[95]=u5,d5[72]=[u5,l5],d5[104]=[u5,l5],d5[87]=[u5,c5],d5[119]=[u5,c5];function _oe(e,t,n){let r=this,i,a;return o;function o(t){return!g5(t)||!h5.call(r,r.previous)||_5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return g5(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(hoe,u,l)(t):t===45||t===95||_2(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&g2(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function voe(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!p5.call(r,r.previous)||_5(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(moe,e.attempt(a5,e.attempt(o5,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function yoe(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&m5.call(r,r.previous)&&!_5(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(g2(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||y2(t)||C2(t)||E2(t)||T2(t)?n(t):e.attempt(a5,e.attempt(o5,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function boe(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function xoe(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(s5,c,s)(t):t===null||C2(t)||E2(t)||t!==45&&T2(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Soe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(s5,t,a)(o):o===null||C2(o)||E2(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Coe(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||C2(o)||E2(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||C2(e)||E2(e)?t(e):r(e)}function a(e){return g2(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):g2(t)?(e.consume(t),o):n(t)}}function woe(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return _2(e)?n(e):t(e)}}function p5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||C2(e)}function m5(e){return!g2(e)}function h5(e){return!(e===47||g5(e))}function g5(e){return e===43||e===45||e===46||e===95||_2(e)}function _5(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Toe={tokenize:Noe,partial:!0};function Eoe(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Aoe,continuation:{tokenize:joe},exit:Moe}},text:{91:{name:`gfmFootnoteCall`,tokenize:koe},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Doe,resolveTo:Ooe}}}}function Doe(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=h2(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Ooe(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function koe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||C2(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(h2(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return C2(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Aoe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||C2(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=h2(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return C2(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),k2(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function joe(e,t,n){return e.check(q2,t,e.attempt(Toe,t,n))}function Moe(e){e.exit(`gfmFootnoteDefinition`)}function Noe(e,t,n){let r=this;return k2(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Poe(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&c2(o,o.length,0,B2(s,e.slice(r+1,n),t)),c2(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),c2(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=z2(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=z2(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Foe=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Ioe(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Ioe(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Loe(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Roe(){return{flow:{null:{name:`table`,tokenize:zoe,resolveAll:Boe}}}}function zoe(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124||(o=!0,a+=1),u(e)}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):w2(t)?k2(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||C2(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,w2(t)?k2(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return w2(t)?k2(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return w2(t)?k2(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):w2(n)?k2(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||C2(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Boe(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Foe;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(y5(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=v5(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=v5(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=v5(f,t,o,i,n,d)):(o[0]=o[1],d=v5(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&y5(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Loe(t.events,n))}return e}function v5(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},b5(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=b5(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=b5(t.events,n[2]),a=b5(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},b5(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function y5(e,t,n,r,i){let a=[],o=b5(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function b5(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Voe={name:`tasklistCheck`,tokenize:Uoe};function Hoe(){return{text:{91:Voe}}}function Uoe(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return C2(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):w2(r)?e.check({tokenize:Woe},t,n)(r):n(r)}}function Woe(e,t,n){return k2(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Goe(e){return d2([goe(),Eoe(),Poe(e),Roe(),Hoe()])}var Koe={};function x5(e){let t=this,n=e||Koe,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Goe(n)),a.push(foe()),o.push(poe(n))}function S5({...e}){return(0,z.jsx)(hT,{"data-slot":`dropdown-menu`,...e})}function C5({...e}){return(0,z.jsx)(_T,{"data-slot":`dropdown-menu-trigger`,...e})}function w5({className:e,sideOffset:t=4,...n}){return(0,z.jsx)(vT,{children:(0,z.jsx)(bT,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:T(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function T5({className:e,inset:t,variant:n=`default`,...r}){return(0,z.jsx)(xT,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:T(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function qoe({className:e,children:t,checked:n,...r}){return(0,z.jsxs)(ST,{"data-slot":`dropdown-menu-checkbox-item`,className:T(`relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...r,children:[(0,z.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(CT,{children:(0,z.jsx)(lO,{className:`size-4`})})}),t]})}var E5={hour:`2-digit`,minute:`2-digit`},Joe=e=>new Date(e).toLocaleTimeString(E(),E5),D5=e=>new Date(e).toLocaleTimeString(E());function Yoe(e,t=new Date){let n=new Date(e);return n.toDateString()===t.toDateString()?Joe(e):n.toLocaleString(E(),{month:`numeric`,day:`numeric`,...E5})}function Xoe(e,t){if(!e)return`—`;let n=Math.max(0,Math.round((t-Date.parse(e))/1e3)),r=new Intl.RelativeTimeFormat(E(),{numeric:`always`});return n<60?r.format(-n,`second`):r.format(-Math.round(n/60),`minute`)}var O5=[`git`],k5={state:()=>Ov(`GET`,`/api/git`).then(e=>e.git),review:e=>Ov(`POST`,`/api/git/review`,e),openPr:()=>Ov(`GET`,`/api/git/pr`).then(e=>e.url),draft:e=>Ov(`POST`,`/api/git/review/draft`,e),diff:e=>Ov(`GET`,`/api/git/diff?path=${encodeURIComponent(e)}`),revert:e=>Ov(`POST`,`/api/git/revert`,e),defaultChanges:()=>Ov(`GET`,`/api/git/default`).then(e=>e.files),restoreDefault:e=>Ov(`POST`,`/api/git/restore-default`,{files:e})};async function Zoe(e){for(let{table:t,key:n,before:r,after:i}of e)if(r===null)await Uv.remove(t,n);else if(i===null)await Uv.create(t,n,r);else{let e=Object.fromEntries(Object.keys(i).filter(e=>!(e in r)).map(e=>[e,null]));await Uv.update(t,n,{...e,...r},i)}}function A5(){let e=!Yv();return V_({queryKey:O5,queryFn:k5.state,enabled:e,refetchOnWindowFocus:!0}).data??null}function j5(e){let t=new Map;for(let n of e)t.set(n.table,[...t.get(n.table)??[],n]);return[...t.entries()].sort(([e],[t])=>e===null?1:t===null?-1:e.localeCompare(t)).map(([e,t])=>({table:e,changes:t}))}var M5=[`ai-instructions`];function N5({open:e,onOpenChange:t}){let n=Sg(),r=V_({queryKey:M5,queryFn:Q$.get,enabled:e,staleTime:1/0,refetchOnWindowFocus:!1}),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(!1);(0,B.useEffect)(()=>{r.data&&!c&&(a(r.data.instructions??``),s(r.data.pullRequests??``),l(!0))},[r.data,c]);let u=H_({mutationFn:()=>Q$.save({instructions:i,pullRequests:o,base:r.data?.base??``}),onSuccess:e=>{n.setQueryData(M5,e),n.invalidateQueries({queryKey:O5}),iv.success(tt()),t(!1)}}),d=e=>{t(e),e||(u.reset(),n.removeQueries({queryKey:M5}))},f=u.error instanceof Sv&&u.error.status===409?Xe():u.error instanceof Error?u.error.message:r.error instanceof Error?r.error.message:null;return(0,z.jsx)(qk,{open:e,onOpenChange:d,children:(0,z.jsxs)(Qk,{className:`sm:max-w-2xl`,children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{className:`text-[18px]`,children:nt()}),(0,z.jsx)(rA,{className:`text-[14px]`,children:Ze()})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:Je()}),(0,z.jsx)(lJ,{value:i,placeholder:Ye(),onChange:e=>a(e.target.value),disabled:!r.data,className:`min-h-28 text-[15px]`})]}),(0,z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:$e()}),(0,z.jsx)(lJ,{value:o,placeholder:et(),onChange:e=>s(e.target.value),disabled:!r.data,className:`min-h-20 text-[15px]`})]}),f&&(0,z.jsx)(`p`,{role:`alert`,className:`text-[13px] text-err`,children:f}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>d(!1),children:gt()}),(0,z.jsx)(V,{disabled:!r.data||u.isPending,onClick:()=>u.mutate(),children:St()})]})]})})}var P5=`w-full rounded-md border bg-panel px-2.5 py-1.5 text-[15px]`;function Qoe({viewerKeys:e,providers:t,initial:n,onSave:r}){let[i,a]=(0,B.useState)(n?.provider??t[0]?.id??``),o=t.find(e=>e.id===i)??t[0],[s,c]=(0,B.useState)(n?.provider===o.id?n.model:o.models[0]),l=t=>e?J$(t):``,u=t=>e&&Y$(t),[d,f]=(0,B.useState)(()=>n?.provider===o.id?n.apiKey:l(o.id)),[p,m]=(0,B.useState)(()=>u(o.id)),h=s.trim(),g=h!==``&&(!e||d.trim()!==``||o.hasKey);return(0,z.jsxs)(`form`,{"aria-label":Ne(),className:`flex flex-col gap-3 border-b p-3.5 text-[15px]`,onSubmit:t=>{t.preventDefault(),g&&r({provider:o.id,model:h,apiKey:e?d.trim():``},e&&p)},children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[we(),(0,z.jsx)(`select`,{className:P5,value:o.id,onChange:e=>{let n=t.find(t=>t.id===e.target.value);a(n.id),c(n.models[0]),f(l(n.id)),m(u(n.id))},children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),o.fixedModels?(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[he(),(0,z.jsx)(`select`,{className:P5,value:s,onChange:e=>c(e.target.value),children:o.models.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}):(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[he(),(0,z.jsx)(`input`,{className:P5,list:`ai-models-${o.id}`,autoComplete:`off`,spellCheck:!1,value:s,onChange:e=>c(e.target.value)}),(0,z.jsx)(`datalist`,{id:`ai-models-${o.id}`,children:o.models.map(e=>(0,z.jsx)(`option`,{value:e},e))}),h!==``&&!o.models.includes(h)&&(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:ge()})]}),e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[ae(),(0,z.jsx)(`input`,{className:P5,type:`password`,autoComplete:`off`,spellCheck:!1,value:d,placeholder:o.hasKey?se():``,onChange:e=>f(e.target.value)})]}),(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:oe()}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),Ee()]})]}),(0,z.jsx)(V,{type:`submit`,disabled:!g,className:`self-end`,children:je()})]})}var F5=e=>typeof e==`object`&&!!e&&!Array.isArray(e),I5=e=>typeof e!=`object`||!e,L5=e=>Array.isArray(e)?`[${e.map(L5).join(`,`)}]`:F5(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${L5(e[t])}`).join(`,`)}}`:JSON.stringify(e)??`null`,R5=(e,t)=>e===``?t:`${e} › ${t}`,z5=[`id`,`key`,`name`],$oe=/(^|_)(id|key|code|uuid|slug|name)$/i,ese=/^[\w.\-:/]{1,64}$/;function tse(e){return typeof e==`string`?e.length<=64&&!/\s/.test(e):typeof e==`number`||typeof e==`boolean`}function nse(e,t){let n=[...e,...t];if(n.length===0)return null;let r=r=>n.every(e=>Object.hasOwn(e,r)&&tse(e[r]))&&new Set(n.map(e=>typeof e[r])).size===1&&[e,t].every(e=>new Set(e.map(e=>e[r])).size===e.length),i=n=>{if(e.length===0||t.length===0)return 1;let r=new Set(t.map(e=>e[n]));return e.filter(e=>r.has(e[n])).length},a=z5.find(e=>r(e)&&i(e)>0);if(a)return a;let o=Math.ceil(Math.min(e.length,t.length)/2),s=Object.keys(n[0]).filter(e=>!z5.includes(e)&&r(e)&&i(e)>=Math.max(o,1)),c=e=>n.every(t=>typeof t[e]!=`string`||ese.test(t[e]));return s.find(e=>$oe.test(e))??s.find(e=>c(e)&&n.every(t=>typeof t[e]==`string`||Number.isInteger(t[e])))??null}function rse(e,t){let n=Array.from({length:e.length+1},()=>Array.from({length:t.length+1},()=>0));for(let r=e.length-1;r>=0;r--)for(let i=t.length-1;i>=0;i--)n[r][i]=e[r]===t[i]?n[r+1][i+1]+1:Math.max(n[r+1][i],n[r][i+1]);let r=[],i=0,a=0;for(;i<e.length&&a<t.length;)e[i]===t[a]?r.push([i++,a++]):n[i+1][a]>=n[i][a+1]?i++:a++;return r}function ise(e,t,n,r){if(e.every(F5)&&t.every(F5)){let i=nse(e,t);if(i!==null){let a=e=>new Map(e.map(e=>[String(e[i]),e])),o=a(e),s=a(t);for(let[e,t]of o){let i=s.get(e),a=R5(n,e);i===void 0?r.push({path:a,kind:`removed`,before:t}):B5(t,i,a,r)}for(let[e,t]of s)o.has(e)||r.push({path:R5(n,e),kind:`added`,after:t});return}}if(e.length===t.length){e.forEach((e,i)=>B5(e,t[i],R5(n,`[${i}]`),r));return}let i=e.map(L5),a=t.map(L5),o=0;for(;o<i.length&&o<a.length&&i[o]===a[o];)o++;let s=i.length,c=a.length;for(;s>o&&c>o&&i[s-1]===a[c-1];)s--,c--;if((s-o)*(c-o)>4e6){r.push({path:n,kind:`changed`,before:e,after:t});return}let l=rse(i.slice(o,s),a.slice(o,c)),u=new Set(l.map(([e])=>e+o)),d=new Set(l.map(([,e])=>e+o));for(let t=o;t<s;t++)u.has(t)||r.push({path:R5(n,`[${t}]`),kind:`removed`,before:e[t]});for(let e=o;e<c;e++)d.has(e)||r.push({path:R5(n,`[${e}]`),kind:`added`,after:t[e]})}function B5(e,t,n,r){if(F5(e)&&F5(t)){for(let i of Object.keys(e))Object.hasOwn(t,i)?B5(e[i],t[i],R5(n,i),r):r.push({path:R5(n,i),kind:`removed`,before:e[i]});for(let i of Object.keys(t))Object.hasOwn(e,i)||r.push({path:R5(n,i),kind:`added`,after:t[i]})}else Array.isArray(e)&&Array.isArray(t)&&!(e.every(I5)&&t.every(I5))?ise(e,t,n,r):L5(e)!==L5(t)&&r.push({path:n,kind:`changed`,before:e,after:t})}function ase(e,t){let n=[];return B5(e,t,``,n),n}var V5=e=>typeof e==`object`&&!!e,ose=e=>e==null?`—`:typeof e==`string`?e:JSON.stringify(e),sse={insert:ca,update:la,delete:sa},cse={applied:Bi,discarded:Xi,stale:fa,failed:Zi},lse={added:Gi,removed:qi,changed:Ki},use=200,H5=50;function U5({value:e}){let t=JSON.stringify(e)??`null`,[n,r]=(0,B.useState)(!1),i=t.length>use;return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:T(`font-mono text-[14px] [overflow-wrap:anywhere]`,i&&!n&&`line-clamp-6`),children:t}),i&&(0,z.jsx)(`button`,{type:`button`,className:`text-[14px] text-muted-foreground underline`,onClick:()=>r(!n),children:n?Ji():da()})]})}function dse({field:e,before:t,after:n}){let r=(0,B.useMemo)(()=>ase({[e]:t},{[e]:n}),[e,t,n]),i=r.slice(0,H5);return r.length===0?(0,z.jsxs)(`p`,{className:`text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e}),` `,(0,z.jsx)(`span`,{children:ua()})]}):(0,z.jsxs)(`ul`,{"aria-label":e,className:`flex flex-col gap-2`,children:[i.map(e=>(0,z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 rounded-md border bg-panel px-2.5 py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[14px]`,children:[(0,z.jsx)(`span`,{className:T(`shrink-0 rounded-full border px-2`,e.kind===`removed`?`border-err text-err`:e.kind===`added`?`border-ok text-ok`:`text-muted-foreground`),children:lse[e.kind]()}),(0,z.jsx)(`span`,{className:`font-mono [overflow-wrap:anywhere]`,children:e.path})]}),e.kind!==`added`&&(0,z.jsx)(U5,{value:e.before}),e.kind===`changed`&&(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:`→`}),e.kind!==`removed`&&(0,z.jsx)(U5,{value:e.after})]},`${e.kind}:${e.path}`)),r.length>H5&&(0,z.jsx)(`li`,{className:`text-[14px] text-muted-foreground`,children:ra({count:r.length-H5})})]})}function fse({row:e}){let t=e.op===`update`?e.changed:Object.keys(e.after??e.before??{}),n=t=>e.op===`update`&&V5(e.before?.[t])&&V5(e.after?.[t]),r=t.filter(e=>!n(e));return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-b border-dashed py-2.5 last:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[14px]`,children:[(0,z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:e.key}),(0,z.jsx)(`span`,{className:T(`rounded-full border px-2 text-[14px]`,e.op===`delete`?`border-err text-err`:`border-ok text-ok`),children:sse[e.op]()})]}),e.op!==`delete`&&r.length>0&&(0,z.jsx)(GZ,{labels:[Wi(),zi()],format:ose,rows:r.map(t=>({field:t,a:e.before?.[t],b:e.after?.[t]}))}),e.op!==`delete`&&t.filter(n).map(t=>(0,z.jsx)(dse,{field:t,before:e.before?.[t],after:e.after?.[t]},t))]})}var pse={done:lr,failed:ur,skipped:jr};function mse(e){switch(e.kind){case`create_branch`:return e.from?sr({name:e.name,from:e.from}):ir({name:e.name});case`switch`:return Lr({branch:e.branch});case`commit`:return tr({message:e.message});case`push`:return Sr({branch:e.branch});case`pull`:return yr({branch:e.branch});case`open_pr`:return mr({title:e.title})}}function hse({git:e,ran:t}){let n=t||e.results.some(e=>e.status!==`skipped`);return(0,z.jsx)(`ol`,{className:`flex flex-col gap-2 py-2.5`,children:e.steps.map((t,r)=>{let i=e.results[r];return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1 text-[15px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`${r+1}.`}),(0,z.jsx)(`span`,{children:mse(t)}),n&&i&&(0,z.jsx)(`span`,{className:T(`ml-auto shrink-0 rounded-full border px-2 text-[14px]`,i.status===`done`?`border-ok text-ok`:i.status===`failed`?`border-err text-err`:`text-muted-foreground`),children:pse[i.status]()})]}),t.kind===`commit`&&(0,z.jsx)(`ul`,{className:`ml-6 font-mono text-[14px] text-muted-foreground`,children:t.paths.map(e=>(0,z.jsx)(`li`,{children:e},e))}),t.kind===`open_pr`&&t.body&&(0,z.jsx)(`p`,{className:`ml-6 text-[14px] whitespace-pre-wrap text-muted-foreground`,children:t.body}),n&&i?.message&&(0,z.jsx)(`p`,{className:`ml-6 text-[14px] text-err [overflow-wrap:anywhere]`,children:i.message}),n&&i?.url&&(0,z.jsx)(`a`,{className:`ml-6 text-[14px] underline`,href:i.url,target:`_blank`,rel:`noreferrer`,children:i.created?gr():hr()})]},r)})})}function W5({proposal:e}){let t=H_({mutationFn:t=>t===`apply`?r1.apply(e.id):r1.discard(e.id),onSettled:()=>f1(),onError:e=>iv.error(e.message)}),n=[...new Set(e.rows.map(e=>e.table))],r=e.git?e.git.steps.length:e.table?1:e.rows.length;return(0,z.jsxs)(`section`,{"aria-label":ea({title:e.title}),className:`overflow-hidden rounded-lg border`,children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-2 border-b bg-panel px-3 py-2.5`,children:[(0,z.jsx)(`h3`,{className:`text-[16px] font-semibold`,children:e.title}),(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:e.git?Pr({count:r}):e.table?oa({name:e.table.name}):ha({tables:n.join(`, `),count:r})})]}),(0,z.jsx)(`div`,{className:`max-h-[360px] overflow-auto px-3`,children:e.git?(0,z.jsx)(hse,{git:e.git,ran:e.status!==`pending`}):e.table?(0,z.jsx)(`p`,{className:`py-2.5 text-[14px]`,children:(e.table.mode===`list`?xa:va)({name:e.table.name,key:e.table.key})}):e.rows.map(e=>(0,z.jsx)(fse,{row:e},`${e.table}/${e.key}`))}),e.warnings.length>0&&(0,z.jsx)(`ul`,{className:`border-t bg-warn-soft px-3 py-2 text-[14px] text-warn`,children:e.warnings.map(e=>(0,z.jsxs)(`li`,{children:[`⚠ `,e]},e))}),e.sql&&(0,z.jsxs)(`details`,{className:`border-t px-3 py-2 text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer`,children:`SQL`}),(0,z.jsx)(`pre`,{className:`mt-1.5 font-mono text-[14px] whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:e.sql})]}),(0,z.jsx)(`footer`,{className:`flex items-center justify-end gap-2 border-t px-3 py-2.5`,children:e.status===`pending`?(0,z.jsxs)(z.Fragment,{children:[e.git&&t.isPending&&(0,z.jsx)(`p`,{role:`status`,className:`mr-auto text-[14px] text-muted-foreground`,children:kr()}),(0,z.jsx)(V,{variant:`outline`,disabled:t.isPending,onClick:()=>t.mutate(`discard`),children:Yi()}),(0,z.jsx)(V,{disabled:t.isPending,onClick:()=>t.mutate(`apply`),children:e.git?Or({count:r}):Ui({count:r})})]}):(0,z.jsxs)(`p`,{className:T(`text-[14px]`,e.status===`applied`?`text-ok`:e.status===`discarded`?`text-muted-foreground`:`text-err`),children:[cse[e.status](),e.stale&&`: ${e.stale.join(`, `)}`,e.error&&`: ${e.error}`]})})]})}var gse=`max-w-none min-w-0 [overflow-wrap:anywhere] [&_a]:underline [&_code]:font-mono [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:my-1.5 [&_pre]:overflow-auto [&_table]:text-[14px] [&_ul]:list-disc [&_ul]:pl-5`,_se={schema:Ge,query:We,get_records:Ve,propose_changes:He,propose_sql:He,propose_table:Ue,check:ze,web_search:Ke,code_execution:Be},G5=e=>_se[e]?.()??e;function vse({busy:e,last:t}){let n=t?.kind===`tool`&&t.status===`in_progress`?G5(t.title):null;return(0,z.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-2 text-[14px] text-muted-foreground`,children:e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-1`,children:[0,1,2].map(e=>(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground motion-safe:animate-pulse`,style:{animationDelay:`${e*200}ms`}},e))}),n?Ae({tool:n}):Re()]})})}function yse({item:e}){let t=G5(e.title),n=e.input,r=n?.sql??(e.title===`web_search`?n?.query:void 0);return(0,z.jsxs)(`details`,{className:`min-w-0 rounded-md border bg-panel px-2.5 py-1.5 text-[14px] text-muted-foreground`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer`,children:[t,e.status===`in_progress`&&` …`]}),e.input!==void 0&&(0,z.jsx)(`pre`,{className:`mt-1.5 font-mono text-[14px] whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:r??JSON.stringify(e.input,null,2)}),e.sources&&(0,z.jsx)(K5,{sources:e.sources})]})}var bse=e=>URL.parse(e)?.hostname||e;function K5({sources:e}){return(0,z.jsx)(`ul`,{className:`mt-1.5 flex flex-col gap-1`,children:e.map(e=>(0,z.jsx)(`li`,{className:`min-w-0 truncate`,children:(0,z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,title:e.url,children:e.title||bse(e.url)})},e.url))})}function xse({sources:e}){return(0,z.jsxs)(`details`,{className:`mt-2 text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer`,children:Ie({count:e.length})}),(0,z.jsx)(K5,{sources:e})]})}var q5=()=>c1.reset().catch(()=>{});function Sse({current:e,onPick:t}){let[n,r]=(0,B.useState)(!1),{conversations:i,loading:a}=d1(n);return(0,z.jsxs)(S5,{open:n,onOpenChange:r,children:[(0,z.jsx)(C5,{asChild:!0,children:(0,z.jsxs)(V,{variant:`ghost`,className:`text-[14px]`,children:[(0,z.jsx)(ak,{className:`size-4`}),ue()]})}),(0,z.jsx)(w5,{align:`start`,className:`w-80 max-w-[calc(100vw-2rem)]`,children:i.length===0?(0,z.jsx)(T5,{disabled:!0,className:`text-[14px]`,children:a?bt():ve()}):i.map(n=>(0,z.jsxs)(T5,{"aria-current":n.id===e?`true`:void 0,className:`flex cursor-pointer flex-col items-stretch gap-0.5 py-2 aria-[current]:bg-panel-2`,onSelect:()=>t(n),children:[(0,z.jsx)(`span`,{className:`truncate text-[15px]`,children:n.title||qe()}),(0,z.jsxs)(`span`,{className:`flex gap-2 text-[14px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:Yoe(n.updatedAt)}),(0,z.jsx)(`span`,{children:n.model})]})]},n.id))})]})}function J5({url:e}){return e?(0,z.jsx)(`a`,{href:e,className:`underline`,children:be()}):null}function Cse(e){return e instanceof Sv&&e.body.code===`no_key`?me():e instanceof Error?e.message:String(e)}function wse(){let e=K$(),t=q$(),n=t?.viewerKeys??!0,r=l1(),[i,a]=(0,B.useState)(()=>e?X$(e,{viewerKeys:n}):null),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),g=(0,B.useRef)(!1),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=u1(),b=new Set(r.items.flatMap(e=>e.kind===`proposal`?[e.proposal.id]:[])),x=y.filter(e=>!b.has(e.id));if((0,B.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented||e.isComposing||e.keyCode===229||document.querySelector(`[role="dialog"], [role="alertdialog"], [data-radix-popper-content-wrapper], aside[data-record-drawer]`))return;let t=e.target instanceof HTMLElement?e.target:null;t&&t!==v.current&&t.closest(`input, textarea, select, [contenteditable]`)||v.current?.value.trim()||g1.close()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,B.useEffect)(()=>{_.current?.scrollTo?.({top:_.current.scrollHeight})},[r.items,r.busy]),!e)return null;let S=r.items.at(-1),C=n&&S?.kind===`error`&&S.code===`auth`,w=!n&&e.length===0,T=!w&&(o||i===null||C),E=async()=>{let e=u.trim();if(!(e===``||r.busy||g.current)){if(!i)s(!0);else{g.current=!0,h(!0),p(null);try{(!c1.id||r.closed)&&(await c1.reset(),await c1.start(i)),await c1.send(e),d(``)}catch(e){p(Cse(e)),e instanceof Sv&&e.body.code===`no_key`&&s(!0)}finally{g.current=!1,h(!1)}}}};return(0,z.jsxs)(eZ,{layout:`docked`,widthKey:`yamlite-agent-width`,defaultWidth:420,resizeLabel:De(),"aria-label":fi(),children:[(0,z.jsxs)(tZ,{onClose:g1.close,className:`justify-between`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[!w&&(0,z.jsxs)(V,{variant:`ghost`,className:`min-w-0 shrink text-[14px]`,"aria-label":Ne(),"aria-expanded":T,onClick:()=>s(e=>!e),children:[(0,z.jsx)(pk,{className:`size-4`}),(0,z.jsx)(`span`,{className:`truncate`,children:i?`${e.find(e=>e.id===i.provider)?.name??i.provider} · ${i.model}`:Ne()})]}),(0,z.jsx)(Sse,{current:c1.id,onPick:e=>{p(null),c1.open(e.id)}}),(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":Qe(),title:Qe(),onClick:()=>l(!0),children:(0,z.jsx)(lk,{className:`size-4`})}),c&&(0,z.jsx)(N5,{open:!0,onOpenChange:l})]}),(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,z.jsx)(V,{variant:`ghost`,className:`text-[14px]`,onClick:()=>{p(null),q5()},children:_e()})})]}),w&&(0,z.jsxs)(`div`,{className:`flex flex-col items-start gap-2 border-b p-3.5 text-[15px]`,children:[(0,z.jsx)(`p`,{children:t?.unavailable?ie():ye()}),(0,z.jsx)(J5,{url:t?.settingsUrl})]}),T&&(0,z.jsx)(Qoe,{viewerKeys:n,providers:e,initial:i,onSave:(e,t)=>{Z$(e,t),a(e),s(!1),p(null),q5()}}),(0,z.jsxs)(`div`,{ref:_,className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-3.5 text-[15px] leading-relaxed [&>*]:shrink-0`,children:[x.length>0&&(0,z.jsxs)(`section`,{"aria-label":xe(),className:`flex flex-col gap-3 border-b pb-3`,children:[(0,z.jsx)(`h2`,{className:`text-[15px] font-semibold`,children:xe()}),(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:Se()}),x.map(e=>(0,z.jsx)(W5,{proposal:e},e.id))]}),r.items.length===0&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:L()}),r.items.map((e,r)=>e.kind===`user`?(0,z.jsx)(`p`,{className:`max-w-[85%] self-end rounded-xl rounded-br-sm bg-panel-2 px-3 py-2 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.text},r):e.kind===`agent`?(0,z.jsxs)(`div`,{className:gse,children:[(0,z.jsx)(j8,{remarkPlugins:[x5],disallowedElements:[`img`],unwrapDisallowed:!0,components:{a:({node:e,...t})=>(0,z.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer noopener`})},children:e.text}),e.sources&&(0,z.jsx)(xse,{sources:e.sources})]},r):e.kind===`tool`?(0,z.jsx)(yse,{item:e},e.id):e.kind===`proposal`?(0,z.jsx)(W5,{proposal:e.proposal},e.proposal.id):!n&&e.code===`auth`?(0,z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 rounded-md border border-err px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-err`,children:fe()}),(0,z.jsx)(J5,{url:t?.settingsUrl})]},r):(0,z.jsx)(`p`,{role:`alert`,className:`rounded-md border border-err px-3 py-2 text-err`,children:e.message},r)),(0,z.jsx)(vse,{busy:r.busy,last:r.items.at(-1)}),r.closed&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:le()}),f&&(0,z.jsx)(`div`,{role:`alert`,className:`rounded-md border border-err px-3 py-2 text-err`,children:(0,z.jsx)(`p`,{children:f})})]}),(0,z.jsx)(nZ,{children:(0,z.jsxs)(`form`,{className:`flex-1`,onSubmit:e=>{e.preventDefault(),E()},children:[(0,z.jsx)(`textarea`,{ref:v,"aria-label":pe(),disabled:w,rows:3,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||e.keyCode===229||(e.preventDefault(),E())},placeholder:Ce(),className:`w-full resize-none rounded-lg border bg-panel px-3 py-2.5 text-[16px] outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60`}),(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[14px] text-muted-foreground`,children:Te()}),r.busy?(0,z.jsxs)(V,{type:`button`,variant:`outline`,onClick:()=>void c1.stop(),children:[(0,z.jsx)(_k,{className:`size-4`}),` `,Le()]}):(0,z.jsx)(V,{type:`submit`,disabled:w||m||u.trim()===``,children:Me()})]})]})})]})}var Tse={added:Ds,modified:ks,deleted:Os},Ese={added:`text-ok`,modified:`text-warn`,deleted:`text-err`};function Y5({branch:e,open:t,onOpenChange:n}){let r=Sg(),{data:i,error:a}=V_({queryKey:[...O5,`default`],queryFn:k5.defaultChanges,enabled:t}),[o,s]=(0,B.useState)(new Set),[c,l]=(0,B.useState)(null),u=(i??[]).filter(e=>o.has(e.path)),d=u.some(e=>e.unsent),f=JSON.stringify(u.map(e=>e.path)),p=c===f,m=e=>{n(e),e||(h.reset(),s(new Set),l(null))},h=H_({mutationFn:()=>k5.restoreDefault(u.map(e=>e.path)),onSuccess:t=>{iv.success(_o({count:t.files.length,branch:e})),m(!1)},onSettled:()=>{l(null),r.invalidateQueries({queryKey:O5})}}),g=e=>s(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),_=h.error??a;return(0,z.jsx)(qk,{open:t,onOpenChange:m,children:(0,z.jsxs)(Qk,{className:`sm:max-w-2xl`,children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{className:`text-[18px]`,children:Ao({branch:e})}),(0,z.jsx)(rA,{className:`text-[14px]`,children:mo({branch:e})})]}),i?i.length===0?(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:bo({branch:e})}):(0,z.jsxs)(`fieldset`,{className:`flex max-h-[45vh] flex-col gap-2 overflow-auto rounded-md border p-3 text-[14px]`,children:[(0,z.jsx)(`legend`,{className:`px-1 text-[13px] text-muted-foreground`,children:Xo({count:u.length})}),j5(i).map(e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`div`,{className:`text-[12.5px] font-semibold text-muted-foreground`,children:e.table??as()}),e.changes.map(e=>(0,z.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md px-1 py-1`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":es({file:e.path}),checked:o.has(e.path),disabled:h.isPending,onChange:()=>g(e.path)}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[13.5px]`,children:e.path}),e.unsent&&(0,z.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-warn`,children:Po()}),(0,z.jsx)(`span`,{className:T(`ml-auto shrink-0 text-[12.5px]`,Ese[e.status]),children:Tse[e.status]()})]},e.path))]},e.table??``))]}):!a&&(0,z.jsx)(`p`,{className:`text-[14px] text-muted-foreground`,children:ts()}),_&&(0,z.jsx)(`p`,{role:`alert`,className:`text-[13px] text-err`,children:_.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>m(!1),children:gt()}),(0,z.jsxs)(V,{variant:p?`destructive`:`default`,disabled:u.length===0||h.isPending,onClick:()=>d&&!p?l(f):h.mutate(),children:[(0,z.jsx)(ak,{className:`size-4`}),h.isPending?xo():p?Do({count:u.length}):wo({count:u.length})]})]})]})})}var Dse={added:Ds,modified:ks,deleted:Os},Ose={added:`text-ok`,modified:`text-warn`,deleted:`text-err`},kse=e=>e.records===null?{records:[],files:e.status===`added`?[]:[e.path]}:{records:e.table===null?[]:e.records.filter(e=>e.kind===`deleted`||e.fields.length>0).map(t=>({table:e.table,key:t.key})),files:[]},Ase=e=>e==null?`—`:typeof e==`string`?e:JSON.stringify(e);function jse({path:e,many:t}){let{data:n,error:r}=V_({queryKey:[`gitdiff`,e],queryFn:()=>k5.diff(e)});return r?(0,z.jsx)(`p`,{className:`text-[13px] text-err`,children:r.message}):n?(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.records.map(e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t&&(0,z.jsx)(`div`,{className:`font-mono text-[13px] font-semibold`,children:e.key}),e.fields.length===0?(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:Zo()}):(0,z.jsx)(GZ,{labels:[Bo(),rs()],format:Ase,rows:e.fields.map(e=>({field:e.field,a:e.from,b:e.to}))})]},e.key))}):(0,z.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:ts()})}function X5({table:e,record:t,busy:n,onRevert:r}){return t.kind===`added`?(0,z.jsx)(Z5,{label:Go({record:t.key}),confirm:Ho(),remove:!0,busy:n,onConfirm:()=>r({records:[{table:e,key:t.key,delete:!0}],files:[]})}):(0,z.jsx)(`button`,{type:`button`,"aria-label":ds({record:t.key}),title:ds({record:t.key}),disabled:n||t.kind===`modified`&&t.fields.length===0,className:`rounded p-1 text-muted-foreground hover:bg-panel-2 hover:text-foreground disabled:opacity-30`,onClick:()=>r({records:[{table:e,key:t.key}],files:[]}),children:(0,z.jsx)(Nk,{className:`size-4`})})}function Mse({change:e,busy:t,onRevert:n}){let r=e.status===`added`;return(0,z.jsx)(Z5,{label:r?Go({record:e.path}):ds({record:e.path}),confirm:r?Ho():cs(),remove:r,busy:t,onConfirm:()=>n({records:[],files:[e.path]})})}function Z5({label:e,confirm:t,remove:n=!1,busy:r,onConfirm:i}){let[a,o]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{r||o(!1)},[r]),a?(0,z.jsx)(V,{size:`sm`,variant:`destructive`,className:`h-6 px-2 text-[12.5px]`,autoFocus:!0,disabled:r,onBlur:()=>o(!1),onClick:i,children:t}):(0,z.jsx)(`button`,{type:`button`,"aria-label":e,title:e,disabled:r,className:T(`rounded p-1 text-muted-foreground hover:bg-panel-2 disabled:opacity-50`,n?`hover:text-err`:`hover:text-foreground`),onClick:()=>o(!0),children:n?(0,z.jsx)(Dk,{className:`size-4`}):(0,z.jsx)(Nk,{className:`size-4`})})}function Q5({label:e,kind:t,fields:n,action:r}){return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[13.5px]`,children:e}),n&&n.length>0&&(0,z.jsx)(`span`,{className:`min-w-0 truncate text-[12.5px] text-muted-foreground`,children:n.join(`, `)}),(0,z.jsx)(`span`,{className:T(`ml-auto shrink-0 text-[12.5px]`,Ose[t]),children:Dse[t]()}),(0,z.jsx)(`span`,{className:`flex min-w-7 shrink-0 justify-end`,children:r})]})}function Nse({change:e,list:t,checked:n,busy:r,onToggle:i,onRevert:a}){let[o,s]=(0,B.useState)(!1),{table:c,records:l}=e,u=!t&&c!==null&&l?.length===1?l[0]:null;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md px-1 py-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":es({file:e.path}),checked:n,onChange:i}),l&&l.length>0?(0,z.jsx)(`button`,{type:`button`,"aria-expanded":o,"aria-label":Es({file:e.path}),className:`rounded p-0.5 text-muted-foreground hover:bg-panel-2`,onClick:()=>s(!o),children:(0,z.jsx)(hO,{className:T(`size-4 transition-transform`,o&&`rotate-90`)})}):(0,z.jsx)(`span`,{className:`w-5 shrink-0`}),u&&c?(0,z.jsx)(Q5,{label:u.key,kind:u.kind,fields:u.fields,action:(0,z.jsx)(X5,{table:c,record:u,busy:r,onRevert:a})}):(0,z.jsx)(Q5,{label:e.path,kind:e.status,action:l===null&&(0,z.jsx)(Mse,{change:e,busy:r,onRevert:a})})]}),!u&&c&&l&&l.length>0&&(0,z.jsx)(`div`,{className:`ml-12 flex flex-col gap-1`,children:l.map(e=>(0,z.jsx)(Q5,{label:e.key,kind:e.kind,fields:e.fields,action:(0,z.jsx)(X5,{table:c,record:e,busy:r,onRevert:a})},e.key))}),o&&(0,z.jsx)(`div`,{className:`mt-1 ml-12 border-t pt-2`,children:(0,z.jsx)(jse,{path:e.path,many:!u})})]})}function $5({git:e,open:t,onOpenChange:n}){let r=Sg(),{data:i}=ry(),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(new Set),[h,g]=(0,B.useState)(null),_=e.changes.map(e=>e.path).filter(e=>!p.has(e)),v=e.branch===e.defaultBranch,y=()=>void r.invalidateQueries({queryKey:O5}),b=V_({queryKey:[...O5,`pr`,e.branch],queryFn:k5.openPr,enabled:t&&!v,staleTime:3e4}),x=v?null:b.data??null,S=v||b.isSuccess||b.isError,C=(0,B.useRef)(0),w=K$(),T=q$(),D=w?X$(w,{viewerKeys:T?.viewerKeys??!0}):null,O=H_({mutationFn:async e=>({...await k5.draft({paths:_,mode:x?`commit`:`pr`,locale:E(),...D}),at:e}),onSuccess:e=>{e.at===C.current&&(o(e.title),e.body!==void 0&&c(e.body))}}),k=H_({mutationFn:()=>k5.review({title:a.trim(),body:x?``:s,paths:_,...v&&l.trim()?{branch:l.trim()}:{}}),onSettled:y}),A=e=>void Zoe(e).then(y).catch(e=>iv.error(e instanceof Error?e.message:String(e))),j=H_({mutationFn:e=>k5.revert(e),onSuccess:({reverted:e,files:t})=>iv.success(bs({count:e.length+t.length}),t.length>0?{}:{action:{label:js(),onClick:()=>A(e)}}),onSettled:()=>{g(null),y()}}),M=k.isPending||j.isPending||O.isPending,N=e.changes.filter(e=>!p.has(e.path)).map(kse),P={records:N.flatMap(e=>e.records),files:N.flatMap(e=>e.files)},F=P.records.length+P.files.length,ee=JSON.stringify(P),I=h===ee,te=e=>{m(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},ne=e=>{n(e),e||(k.reset(),j.reset(),O.reset(),C.current++,o(``),c(``),u(``),m(new Set),g(null))},re=e.changes.length===0;(0,B.useEffect)(()=>{re&&!k.data&&n(!1)},[re,k.data,n]);let ie=new Set(i?.tables.filter(e=>e.mode===`list`).map(e=>e.name)),ae=k.data,oe=k.error??j.error??O.error,se=oe instanceof Error?oe.message:ae?.error??null;return(0,z.jsx)(qk,{open:t,onOpenChange:ne,children:(0,z.jsxs)(Qk,{className:`sm:max-w-2xl`,onInteractOutside:e=>{e.target instanceof Element&&e.target.closest(`[data-sonner-toaster]`)&&e.preventDefault()},children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{className:`text-[18px]`,children:As()}),(0,z.jsx)(rA,{className:`text-[14px]`,children:v?ns():b.isPending?Fo():x?Io():Lo()}),x&&!ae&&(0,z.jsxs)(`a`,{href:x,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-[14px] font-semibold text-tomato hover:underline`,children:[is(),(0,z.jsx)(TO,{className:`size-4`})]})]}),ae?(0,z.jsxs)(`div`,{className:`flex flex-col gap-3 text-[15px]`,children:[!ae.error&&(0,z.jsx)(`p`,{children:Cs()}),ae.url&&(0,z.jsxs)(`a`,{href:ae.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 font-semibold text-tomato hover:underline`,children:[ae.created?is():Vo(),(0,z.jsx)(TO,{className:`size-4`})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`fieldset`,{className:`flex max-h-[45vh] flex-col gap-2 overflow-auto rounded-md border p-3 text-[14px]`,children:[(0,z.jsx)(`legend`,{className:`px-1 text-[13px] text-muted-foreground`,children:Xo({count:_.length})}),j5(e.changes).map(e=>(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`div`,{className:`text-[12.5px] font-semibold text-muted-foreground`,children:e.table??as()}),e.changes.map(e=>(0,z.jsx)(Nse,{change:e,list:e.table!==null&&ie.has(e.table),checked:!p.has(e.path),busy:M,onToggle:()=>te(e.path),onRevert:e=>j.mutate(e)},e.path))]},e.table??``))]}),v&&e.namesBranch&&(0,z.jsx)(Ik,{"aria-label":Ro(),placeholder:Ro(),value:l,onChange:e=>u(e.target.value),className:`font-mono text-[15px]`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(Ik,{"aria-label":x?zo():ss(),placeholder:x?zo():ss(),value:a,onChange:e=>o(e.target.value),className:`text-[15px]`}),D&&(0,z.jsxs)(V,{variant:`outline`,disabled:_.length===0||M||!v&&b.isPending,onClick:()=>O.mutate(C.current),children:[(0,z.jsx)(hk,{className:`size-4`}),O.isPending?Ko():R()]})]}),D&&(0,z.jsx)(`button`,{type:`button`,className:`self-end text-[13.5px] text-muted-foreground underline-offset-2 hover:underline`,onClick:()=>f(!0),children:qo()}),d&&(0,z.jsx)(N5,{open:!0,onOpenChange:f}),S&&!x&&(0,z.jsx)(lJ,{"aria-label":os(),placeholder:os(),value:s,onChange:e=>c(e.target.value),className:`min-h-20 text-[15px]`})]}),se&&(0,z.jsx)(`p`,{role:`alert`,className:`text-[13px] text-err`,children:se}),(0,z.jsx)(tA,{children:ae?(0,z.jsx)(V,{onClick:()=>ne(!1),children:_t()}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(V,{variant:I?`destructive`:`outline`,className:`sm:mr-auto`,disabled:F===0||M,onClick:()=>P.files.length>0&&!I?g(ee):j.mutate(P),children:[(0,z.jsx)(Nk,{className:`size-4`}),I?_s({count:F}):ms({count:F})]}),(0,z.jsx)(V,{variant:`outline`,onClick:()=>ne(!1),children:gt()}),(0,z.jsx)(V,{disabled:a.trim()===``||_.length===0||M||!S,onClick:()=>k.mutate(),children:k.isPending?Ss():xs()})]})})]})})}function Pse(){let e=A5(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1),a=e?.restoresDefault===!0&&e.defaultBranch!==null;return Yv()||!e||e.changes.length===0&&!t&&!a?null:(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2.5`,children:[a&&(0,z.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 rounded-md border bg-background px-3 py-1.5 text-[13px] text-muted-foreground hover:text-foreground`,onClick:()=>i(!0),children:[(0,z.jsx)(ak,{className:`size-3.5`}),Tr({branch:e.defaultBranch??``})]}),e.changes.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-[13px] text-muted-foreground`,children:Qn({count:e.changes.length})}),(0,z.jsxs)(`button`,{type:`button`,disabled:e.branch===null,className:`flex items-center gap-1.5 rounded-md bg-tomato px-3 py-1.5 text-[13px] font-semibold text-[var(--y-on-accent)] hover:opacity-90 disabled:opacity-60`,onClick:()=>n(!0),children:[(0,z.jsx)(aO,{className:`size-3.5`}),Ar()]})]}),t&&(0,z.jsx)($5,{git:e,open:t,onOpenChange:n}),r&&e.defaultBranch&&(0,z.jsx)(Y5,{branch:e.defaultBranch,open:r,onOpenChange:i})]})}function Fse(){let e=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let t=YJ();if(t&&e.current)return e.current.append(t),()=>t.remove()},[]),(0,z.jsxs)(`footer`,{className:`app-footer flex min-h-[48px] flex-wrap items-center gap-x-3 gap-y-2 border-t bg-panel px-3 py-2 max-md:pb-[calc(8px+env(safe-area-inset-bottom))]`,children:[(0,z.jsx)(`div`,{ref:e,className:`app-footer-host min-w-0 flex-1`}),(0,z.jsx)(Pse,{})]})}function Ise({className:e,...t}){return(0,z.jsx)(BQ,{"data-slot":`command`,className:T(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function Lse({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,filter:a,value:o,onValueChange:s,...c}){return(0,z.jsxs)(qk,{...c,children:[(0,z.jsxs)($k,{className:`sr-only`,children:[(0,z.jsx)(nA,{children:e}),(0,z.jsx)(rA,{children:t})]}),(0,z.jsx)(Qk,{className:T(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,z.jsx)(Ise,{filter:a,value:o,onValueChange:s,className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function Rse({className:e,...t}){return(0,z.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,z.jsx)(dk,{className:`size-4 shrink-0 opacity-50`}),(0,z.jsx)(BQ.Input,{"data-slot":`command-input`,className:T(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function zse({className:e,...t}){return(0,z.jsx)(BQ.List,{"data-slot":`command-list`,className:T(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function Bse({...e}){return(0,z.jsx)(BQ.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function e7({className:e,...t}){return(0,z.jsx)(BQ.Group,{"data-slot":`command-group`,className:T(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function t7({className:e,...t}){return(0,z.jsx)(BQ.Item,{"data-slot":`command-item`,className:T(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}var n7=!1,r7=new Set;function i7(e){n7=typeof e==`function`?e(n7):e;for(let e of r7)e()}var a7=()=>i7(!0),Vse=e=>(r7.add(e),()=>{r7.delete(e)}),Hse=()=>(0,B.useSyncExternalStore)(Vse,()=>n7),o7=`\0`,Use=(e,t,n)=>e.startsWith(o7)?1:TQ(e,t,n),Wse=10,Gse=10;function Kse(){let e=Hse(),t=Nh(),{data:n}=ry(),r=K$(),[i,a]=(0,B.useState)(``);(0,B.useEffect)(()=>{e||a(``)},[e]);let o=O$(i.trim(),200),s=_$(o),{data:c,isFetching:l}=w$(o,5),u=s&&c?S$(c.hits,o).slice(0,Wse):[],d=s&&c?[...new Map(c.hits.map(e=>[e.table,e.total])).values()].reduce((e,t)=>e+t,0):0,f=s&&(u.length>0||l),p=e=>`${o7}${e.table}${o7}${e.key}`,[m,h]=(0,B.useState)(``),g=u[0]?p(u[0]):null;(0,B.useEffect)(()=>{g&&h(g)},[g]);let _=()=>v(()=>t({to:`/search`,search:{q:o}}));(0,B.useEffect)(()=>{let e=e=>{e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),i7(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let v=e=>{i7(!1),e()};return(0,z.jsxs)(Lse,{open:e,onOpenChange:i7,filter:Use,value:m,onValueChange:h,className:`sm:max-w-2xl`,children:[(0,z.jsx)(Rse,{placeholder:ft(),className:`max-md:pr-10`,value:i,onValueChange:a,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&u.length>0&&(e.preventDefault(),_())}}),(0,z.jsxs)(zse,{className:`max-h-[min(480px,60vh)] max-md:max-h-none`,children:[!f&&(0,z.jsx)(Bse,{children:ct()}),f&&(0,z.jsxs)(e7,{heading:(0,z.jsxs)(`span`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:pt()}),d>0&&(0,z.jsx)(`span`,{children:Sl({count:d})})]}),forceMount:!0,children:[u.map(e=>(0,z.jsxs)(t7,{value:p(e),className:`gap-3`,onSelect:()=>v(()=>t({to:`/t/$table`,params:{table:e.table},search:{key:e.key}})),children:[(0,z.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg border bg-panel text-muted-foreground`,children:(0,z.jsx)(xk,{className:`size-4`,"aria-hidden":!0})}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,z.jsx)(`span`,{className:`truncate text-base font-semibold`,children:(0,z.jsx)(D$,{text:e.label??e.key,needle:o})}),e.label!==null&&(0,z.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:(0,z.jsx)(D$,{text:e.key,needle:o})}),(0,z.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:e.table})]}),e.value!==e.key&&e.value!==e.label&&(0,z.jsxs)(`span`,{className:`truncate text-sm text-muted-foreground`,children:[`${e.column}: `,(0,z.jsx)(E$,{value:e.value,needle:o,around:Gse})]})]})]},`${e.table}${o7}${e.key}`)),u.length===0&&(0,z.jsx)(t7,{value:`${o7}searching`,disabled:!0,children:mt()}),u.length>0&&(0,z.jsxs)(t7,{value:`${o7}all`,className:`font-semibold text-tomato`,onSelect:_,children:[st({count:d}),(0,z.jsx)(tO,{className:`ml-auto size-4`,"aria-hidden":!0})]})]}),(0,z.jsx)(e7,{heading:Pi(),children:n?.tables.map(e=>(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/t/$table`,params:{table:e.name}})),children:e.name},e.name))}),n&&n.views.length>0&&(0,z.jsx)(e7,{heading:ht(),children:n.views.map(e=>(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/t/$table`,params:{table:e.name}})),children:e.name},e.name))}),n&&n.pages.length>0&&(0,z.jsx)(e7,{heading:_i(),children:n.pages.map(e=>(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/p/$page`,params:{page:e.name}})),children:e.title},e.name))}),(0,z.jsxs)(e7,{heading:Fi(),children:[(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/sql`})),children:ki()}),(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/erd`})),children:pi()}),!Yv()&&(0,z.jsx)(t7,{onSelect:()=>v(()=>t({to:`/sync`})),children:Ai()}),r!==null&&(0,z.jsx)(t7,{onSelect:()=>v(g1.open),children:fi()})]})]}),(0,z.jsx)(`div`,{className:`flex gap-4 border-t px-3.5 py-2 text-xs text-muted-foreground max-md:hidden`,children:[[`↑↓`,ut()],[`↵`,dt()],[`⌘↵`,lt()]].map(([e,t])=>(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`kbd`,{className:`mr-1 rounded border px-1 font-mono`,children:e}),t]},e))})]})}function s7(){return(0,B.useSyncExternalStore)(Tv.subscribe,Tv.expired)?(0,z.jsx)(`div`,{role:`alert`,className:`bg-err-soft px-4 py-2 text-[12px] text-err`,children:zl()}):null}function c7(){let e=iy(),t=Nh(),n=GJ();return(0,B.useEffect)(()=>e.listen(e=>{e.type===`conflict`&&iv.warning(Dt({table:e.table,key:e.key}),{description:e.winner===`file`?wt():Ct(),action:n?void 0:{label:Ot(),onClick:()=>void t({to:`/sync`})},duration:15e3})}),[e,t,n]),null}var qse=[`TEXT`,`INTEGER`,`REAL`,`BOOLEAN`,`JSON`];function l7({open:e,onOpenChange:t,adopt:n}){let r=Sg(),i=Nh(),{connected:a}=ay(),{data:o}=ry(),s=(0,B.useId)(),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(n??``),[f,p]=(0,B.useState)(`files`),[m,h]=(0,B.useState)(`id`),[g,_]=(0,B.useState)([]),v=H_({mutationFn:()=>Uv.createTable({name:u,mode:f,key:m,columns:Object.fromEntries(g.filter(e=>e.name!==``).map(e=>[e.name,e.type])),group:c.trim()===``?void 0:c.trim()}),onSuccess:async()=>{t(!1),await r.invalidateQueries({queryKey:[`meta`]}),i({to:`/t/$table`,params:{table:u}})}}),y=lA(v.error),b=e=>y?.field===e?(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:y.message}):null;return(0,z.jsx)(qk,{open:e,onOpenChange:t,children:(0,z.jsxs)(Qk,{children:[(0,z.jsx)($k,{children:(0,z.jsx)(nA,{children:n?Ft({table:n}):cn()})}),(0,z.jsxs)(`label`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:[on(),(0,z.jsx)(Ik,{"aria-label":gn(),value:u,disabled:n!==void 0,onChange:e=>d(e.target.value),className:`mt-1 font-mono`})]}),b(`name`),(0,z.jsxs)(`fieldset`,{className:`flex gap-4 text-[12px]`,children:[(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`input`,{type:`radio`,checked:f===`files`,onChange:()=>p(`files`)}),` `,tn({name:u||`name`})]}),(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`input`,{type:`radio`,checked:f===`list`,onChange:()=>p(`list`)}),` `,an({name:u||`name`})]})]}),(0,z.jsxs)(`label`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:[Kt(),(0,z.jsx)(Ik,{"aria-label":Gt(),value:m,onChange:e=>h(e.target.value),className:`mt-1 font-mono`})]}),b(`key`),(0,z.jsxs)(`label`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:[Wt(),(0,z.jsx)(Ik,{"aria-label":ud(),list:s,value:c,onChange:e=>l(e.target.value),className:`mt-1`})]}),(0,z.jsx)(`datalist`,{id:s,children:Vk(o?.tables??[]).map(e=>(0,z.jsx)(`option`,{value:e},e))}),b(`group`),!n&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[11.5px] font-semibold text-muted-foreground`,children:Ht()}),g.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,z.jsx)(Ik,{"aria-label":Rt({n:t+1}),value:e.name,onChange:e=>_(g.map((n,r)=>r===t?{...n,name:e.target.value}:n)),className:`font-mono max-md:basis-full`}),(0,z.jsx)(`select`,{"aria-label":Vt({n:t+1}),className:`rounded border bg-background px-2 max-md:h-9 max-md:flex-1`,value:e.type,onChange:e=>_(g.map((n,r)=>r===t?{...n,type:e.target.value}:n)),children:qse.map(e=>(0,z.jsx)(`option`,{children:e},e))}),(0,z.jsx)(V,{variant:`ghost`,size:`icon`,"aria-label":dn({n:t+1}),onClick:()=>_(g.filter((e,n)=>n!==t)),children:(0,z.jsx)(Fk,{className:`size-4`})})]},t)),(0,z.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>_([...g,{name:``,type:`TEXT`}]),children:kt()}),b(`columns`)]}),y&&y.field===null&&(0,z.jsx)(`p`,{className:`text-[11px] text-err`,children:y.message}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>t(!1),children:gt()}),(0,z.jsx)(V,{disabled:u===``||v.isPending||!a,title:a?void 0:yt(),onClick:()=>v.mutate(),children:Ut()})]})]})})}var Jse=_x,Yse={left:`inset-y-0 left-0 h-dvh w-[82%] max-w-[320px] border-r animate-[y-slide-right_160ms_ease-out]`,bottom:`inset-x-0 bottom-0 max-h-dvh border-t animate-[y-slide-up_160ms_ease-out]`};function Xse({side:e,title:t,className:n,children:r,...i}){return(0,z.jsxs)(xx,{children:[(0,z.jsx)(Cx,{className:`fixed inset-0 z-50 bg-black/40`}),(0,z.jsxs)(Dx,{"aria-describedby":void 0,className:T(`fixed z-50 flex flex-col bg-panel shadow-xl outline-none`,Yse[e],n),...i,children:[(0,z.jsx)(jx,{className:`sr-only`,children:t}),r]})]})}function Zse(e,t){let[,n,r]=e.split(`/`),i=r?decodeURIComponent(r):``;return n===`t`&&i?i:n===`p`&&i?t.find(e=>e.name===i)?.title??i:n===`sql`?ki():n===`sync`?Ai():n===`erd`?pi():`yamlite`}var Qse={toDb:{symbol:`M`,tone:`warn`,detail:()=>`file → DB`},toFile:{symbol:`M`,tone:`warn`,detail:()=>`DB → file`},deleteDb:{symbol:`−`,tone:`err`,detail:te},deleteFile:{symbol:`−`,tone:`err`,detail:ne}};function $se(e){let t=[];for(let n of e)if(n.type===`sync`){n.ok||t.push({at:n.at,symbol:`✗`,tone:`err`,text:n.table,detail:n.error??re()});for(let e of n.changes){let{detail:r,...i}=Qse[e.op];t.push({at:n.at,...i,detail:r(),text:`${n.table} / ${e.key}`})}}else n.type===`conflict`?t.push({at:n.at,symbol:`⚠`,tone:`err`,text:`${n.table} / ${n.key}`,detail:I({winner:n.winner})}):n.type===`error`?t.push({at:n.at,symbol:`✗`,tone:`err`,text:n.table??`yamlite`,detail:n.message}):t.push({at:n.at,symbol:`↻`,tone:`muted`,text:`yamlite.yaml`,detail:P()});return t.reverse()}function u7(e,t=new Set){return Object.entries(e).flatMap(([e,n])=>n.map(n=>{let r=n.indexOf(`: `),i=r>0?n.slice(0,r):``;if(i===``||i.includes(` `))return{table:e,key:null,view:null,text:n};let a=n.slice(r+2);return t.has(i)?{table:e,key:null,view:i,text:a}:{table:e,key:i,view:null,text:a}}))}function ece(e){let t=new Map;for(let n of e)n.key!==null&&t.set(n.key,[...t.get(n.key)??[],n.text]);return t}function tce(e,t){let n=new Map;for(let r of u7(e,t)){let e=r.view??r.table;n.set(e,(n.get(e)??0)+1)}return n}var nce=!1,d7=()=>nce;function f7(e,t){return t.value===null?{col:e.column,op:`null`}:{col:e.column,op:e.json?`has`:`eq`,value:t.value}}function rce(e,t,n){if(e.length!==1)return!1;let[r]=e,i=f7(t,n);return r.col===i.col&&r.op===i.op&&r.value===i.value}var ice=(e,t)=>(e.captures??[]).some(e=>e.column===t);function ace(e,t){if(Object.hasOwn(e.columns,t))return[t];let[n,...r]=t.split(`.`);return!n||r.length===0||r.some(e=>e===``)?null:Object.hasOwn(e.columns,n)&&e.columns[n]===`JSON`?[n,...r]:null}var oce=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function p7(e,t,n){let[r,...i]=t;return i.length===0?{...e,[r]:n}:{...e,[r]:p7(oce(e[r])?e[r]:{},i,n)}}function sce(e,t){let n={};for(let r of t){if(r.col===e.key||ice(e,r.col))continue;let t=ace(e,r.col);t!==null&&(r.op===`eq`?n=p7(n,t,r.value):r.op===`has`&&(n=p7(n,t,t.length>1?r.value:[r.value])))}return n}function cce(e,t){let n=[...e.captures??[]].sort((e,t)=>e.segment-t.segment),r=``;for(let[e,i]of n.entries()){if(i.segment!==e)break;let n=t.find(e=>e.col===i.column&&e.op===`eq`);if(!n)break;r+=`${String(n.value)}/`}return r}function lce({className:e}){return(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 64 64`,"aria-hidden":`true`,className:e,children:[(0,z.jsx)(`rect`,{width:`64`,height:`64`,rx:`15`,fill:`#e5484d`}),(0,z.jsx)(`path`,{d:`M15 19L27 38M39 19L22 50`,stroke:`#fff7ed`,strokeWidth:`7`,strokeLinecap:`round`,fill:`none`}),(0,z.jsx)(`circle`,{cx:`48`,cy:`29`,r:`4.5`,fill:`#1c1b29`}),(0,z.jsx)(`circle`,{cx:`48`,cy:`44`,r:`4.5`,fill:`#fff7ed`})]})}var m7=`flex items-center gap-2 rounded-md px-2.5 py-1.5 mx-1.5 text-[13px] hover:bg-panel-2 max-md:py-2.5 max-md:text-[15px]`,h7={className:T(m7,`bg-tomato text-[var(--y-on-accent)] font-semibold hover:bg-tomato [&>[data-count]]:text-current [&>[data-count]]:opacity-80`)};function g7({count:e,fallback:t}){return e===0?t:(0,z.jsxs)(`span`,{role:`img`,"aria-label":Ri({count:e}),title:Ri({count:e}),className:`flex shrink-0 items-center gap-0.5 rounded-full bg-warn-soft px-1 text-[10.5px] font-semibold text-warn`,children:[(0,z.jsx)(kk,{className:`size-3`}),e]})}function _7({onNewTable:e,onSearch:t}){let{data:n}=ry(),r=K$(),{warnings:i,connected:a}=ay(),o=Yv(),{data:s}=V_({queryKey:[`conflicts`],queryFn:Uv.conflicts,enabled:!o}),c=s?.conflicts.length??0,l=new Set(n?.views.map(e=>e.name)),[u,d]=Wk(),[f,p]=Gk(),m=bg({select:e=>e.matches.find(e=>e.routeId===`/t/$table`)}),h=m?.params?.table,g=m?.search?.filter??[],_=n?.views.find(e=>e.name===h),v=e=>{let t=e.split;return t!==null&&h===e.name?t.items.find(e=>rce(g,t,e)):void 0},y=_?.table??n?.tables.find(e=>v(e)!==void 0)?.name??null,[b,x]=(0,B.useState)(null);b!==null&&b!==y&&x(null);let S=e=>{let t=u7({[e.name]:i[e.name]??[]},l),r=e=>t.filter(t=>t.view===e).length,a=e.split,o=n?.views.filter(t=>t.table===e.name)??[],s=v(e),c=a!==null&&a.items.length>0||o.length>0,u=c&&(f.has(e.name)||y===e.name&&b!==e.name);return(0,z.jsxs)(B.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex items-center`,children:[(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.name},className:T(m7,`min-w-0 flex-1`),activeProps:s?{}:{className:T(h7.className,`min-w-0 flex-1`)},children:[(0,z.jsx)(g7,{count:r(null),fallback:(0,z.jsx)(xk,{className:`size-3.5 opacity-70`})}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`span`,{"data-count":!0,className:`ml-auto text-[11px] text-muted-foreground tabular-nums max-md:text-[12.5px]`,children:e.count})]}),c&&(0,z.jsx)(`button`,{type:`button`,"aria-label":Ni({table:e.name}),"aria-expanded":u,className:`mr-1.5 rounded-md p-1 text-muted-foreground hover:bg-panel-2 max-md:p-2`,onClick:()=>{y===e.name?u?(f.has(e.name)&&p(e.name),x(e.name)):x(null):p(e.name)},children:(0,z.jsx)(hO,{className:T(`size-3.5 transition-transform`,u&&`rotate-90`)})})]}),u&&a?.items.map(t=>(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.name},search:{filter:[f7(a,t)]},className:T(t===s?h7.className:m7,`min-w-0`),activeProps:{},style:{paddingLeft:`24px`},children:[(0,z.jsx)(LO,{className:`size-3.5 shrink-0 opacity-70`}),(0,z.jsx)(`span`,{className:`truncate`,children:t.value===null?Oi():String(t.value)}),(0,z.jsx)(`span`,{"data-count":!0,className:`ml-auto text-[11px] text-muted-foreground tabular-nums max-md:text-[12.5px]`,children:t.count})]},JSON.stringify(t.value))),u&&o.map(e=>(0,z.jsxs)(Yh,{to:`/t/$table`,params:{table:e.name},className:m7,activeProps:h7,style:{paddingLeft:`${10+e.depth*14}px`},children:[(0,z.jsx)(g7,{count:r(e.name),fallback:(0,z.jsx)(NO,{className:`size-3.5 shrink-0 opacity-70`})}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`span`,{"data-count":!0,className:`ml-auto text-[11px] text-muted-foreground tabular-nums max-md:text-[12.5px]`,children:e.count})]},e.name))]},e.name)};return(0,z.jsxs)(`aside`,{className:`flex h-full min-h-0 flex-col border-r bg-panel`,"aria-label":Ei(),children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2 px-3.5 pt-3.5 pb-2.5 text-base font-bold tracking-tight`,children:!d7()&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(lce,{className:`size-6`}),`YAMLite`,(0,z.jsx)(uce,{})]})}),(0,z.jsxs)(`div`,{className:`mx-2.5 mb-2 flex gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 justify-between rounded-md border bg-background px-2 py-1.5 text-[12px] text-muted-foreground max-md:py-2.5 max-md:text-[14px]`,onClick:()=>{t?.(),a7()},children:[(0,z.jsx)(`span`,{children:Ti()}),(0,z.jsx)(`kbd`,{className:`rounded border px-1 font-mono text-[10px] max-md:hidden`,children:`⌘K`})]}),r!==null&&(0,z.jsx)(`button`,{type:`button`,"aria-label":fi(),title:fi(),className:`grid place-items-center rounded-md border bg-background px-2 hover:bg-panel-2 max-md:px-3`,onClick:()=>{if(!t)return g1.toggle();t(),g1.open()},children:(0,z.jsx)(hk,{className:`size-4`})})]}),(0,z.jsx)(`div`,{className:`px-3.5 pt-2.5 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase max-md:text-[12px]`,children:Pi()}),(0,z.jsxs)(`nav`,{className:`flex flex-col gap-px overflow-auto`,children:[n&&Bk(n.tables).map(({group:e,tables:t})=>{if(e===null)return(0,z.jsx)(B.Fragment,{children:t.map(S)},``);let n=!u.has(e);return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e,className:`flex flex-col gap-px`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`mx-1.5 mt-1.5 flex items-center gap-1 rounded-md px-1.5 py-1 text-[11.5px] font-semibold text-muted-foreground hover:bg-panel-2 max-md:py-2 max-md:text-[13px]`,onClick:()=>d(e),children:[(0,z.jsx)(hO,{className:T(`size-3 transition-transform`,n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`truncate`,children:e})]}),n&&t.map(S)]},`g:${e}`)}),!o&&(0,z.jsxs)(`button`,{type:`button`,disabled:!a,title:a?void 0:yt(),className:T(m7,`text-muted-foreground disabled:opacity-50`),onClick:e,children:[(0,z.jsx)(rk,{className:`size-3.5`}),` `,gi()]})]}),n&&n.pages.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`px-3.5 pt-2.5 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase max-md:text-[12px]`,children:_i()}),(0,z.jsx)(`nav`,{className:`flex flex-col gap-px`,children:n.pages.map(e=>(0,z.jsxs)(Yh,{to:`/p/$page`,params:{page:e.name},className:m7,activeProps:h7,children:[(0,z.jsx)(FO,{className:`size-3.5 opacity-70`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.title})]},e.name))})]}),(0,z.jsx)(`div`,{className:`px-3.5 pt-2.5 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase max-md:text-[12px]`,children:Fi()}),(0,z.jsxs)(`nav`,{className:`flex flex-col gap-px`,children:[(0,z.jsxs)(Yh,{to:`/sql`,className:m7,activeProps:h7,children:[(0,z.jsx)(Tk,{className:`size-3.5 opacity-70`}),` `,ki()]}),(0,z.jsxs)(Yh,{to:`/erd`,className:m7,activeProps:h7,children:[(0,z.jsx)(qO,{className:`size-3.5 opacity-70`}),` `,pi()]}),!o&&(0,z.jsxs)(Yh,{to:`/sync`,className:m7,activeProps:h7,children:[(0,z.jsx)(ZD,{className:`size-3.5 opacity-70`}),` `,Ai(),c>0&&(0,z.jsx)(`span`,{className:`ml-auto rounded-full bg-err-soft px-1.5 text-[10.5px] font-semibold text-err`,children:c})]})]}),!o&&(0,z.jsx)(dce,{})]})}function uce(){let{data:e}=ry(),t=e?.root??``,n=t.split(/[\\/]/).filter(Boolean).at(-1)??t;return(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,"aria-label":Ci(),className:`ml-auto flex min-w-0 items-center gap-0.5 rounded px-1 font-mono text-[11px] font-normal text-muted-foreground hover:bg-panel-2 max-md:text-[12.5px]`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:n}),(0,z.jsx)(dO,{className:`size-3 shrink-0`})]})}),(0,z.jsxs)(zk,{align:`end`,className:`w-72 text-[13px]`,children:[(0,z.jsx)(`div`,{className:`font-mono text-[12px] break-all text-muted-foreground`,children:t}),(0,z.jsxs)(`dl`,{className:`mt-2.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:bi()}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:e?.configFile}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:xi()}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:e?.db}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Pi()}),(0,z.jsx)(`dd`,{children:e?.tables.length??0}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Si()}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:location.host})]})]})]})}function dce(){let e=A5(),[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1);if(!e)return null;let a=e.changes.length;return(0,z.jsxs)(`div`,{className:`mt-auto border-t px-3.5 py-2.5 text-[12px] max-md:pb-[calc(0.625rem+env(safe-area-inset-bottom))] max-md:text-[13.5px]`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-muted-foreground`,children:[(0,z.jsx)(DO,{className:`size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate font-mono`,children:e.branch??cr()}),(0,z.jsx)(`span`,{children:`·`}),a>0?(0,z.jsx)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:Qn({count:a})}):(0,z.jsx)(`span`,{className:`shrink-0`,children:dr()})]}),(0,z.jsxs)(`button`,{type:`button`,disabled:a===0||e.branch===null,className:T(`mt-2 flex w-full items-center justify-center gap-1.5 rounded-md py-1.5 text-[13px] max-md:py-2.5 max-md:text-[15px]`,a>0?`bg-tomato font-semibold text-[var(--y-on-accent)] hover:opacity-90`:`border bg-background text-muted-foreground disabled:opacity-60`),onClick:()=>n(!0),children:[(0,z.jsx)(aO,{className:`size-3.5`}),Ar()]}),e.restoresDefault&&e.defaultBranch&&(0,z.jsxs)(`button`,{type:`button`,className:`mt-1.5 flex w-full items-center justify-center gap-1.5 rounded-md border bg-background py-1.5 text-[13px] text-muted-foreground hover:text-foreground max-md:py-2.5 max-md:text-[15px]`,onClick:()=>i(!0),children:[(0,z.jsx)(ak,{className:`size-3.5`}),(0,z.jsx)(`span`,{className:`truncate`,children:Tr({branch:e.defaultBranch})})]}),t&&(0,z.jsx)($5,{git:e,open:t,onOpenChange:n}),r&&e.defaultBranch&&(0,z.jsx)(Y5,{branch:e.defaultBranch,open:r,onOpenChange:i})]})}var v7=`grid size-10 shrink-0 place-items-center rounded-md hover:bg-panel-2`;function fce({onNewTable:e}){let[t,n]=(0,B.useState)(!1),{data:r}=ry(),i=K$(),a=A5(),[o,s]=(0,B.useState)(!1),c=a?.branch?a.changes.length:0,l=bg({select:e=>e.location.pathname});return(0,z.jsxs)(`div`,{className:`flex items-center gap-1 border-b bg-background px-2 pt-[env(safe-area-inset-top)]`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":mi(),className:v7,onClick:()=>n(!0),children:(0,z.jsx)(VO,{className:`size-5`})}),(0,z.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-[16px] font-semibold`,children:Zse(l,r?.pages??[])}),(0,z.jsx)(`button`,{type:`button`,"aria-label":wi(),className:v7,onClick:a7,children:(0,z.jsx)(dk,{className:`size-5`})}),i!==null&&(0,z.jsx)(`button`,{type:`button`,"aria-label":fi(),className:v7,onClick:g1.open,children:(0,z.jsx)(hk,{className:`size-5`})}),a&&c>0&&(0,z.jsxs)(`button`,{type:`button`,"aria-label":`${Ar()} (${Qn({count:c})})`,className:`${v7} relative`,onClick:()=>s(!0),children:[(0,z.jsx)(aO,{className:`size-5`}),(0,z.jsx)(`span`,{className:`absolute top-1 right-1 min-w-4 rounded-full bg-tomato px-1 text-[10.5px] leading-4 font-semibold text-[var(--y-on-accent)]`,children:c})]}),a&&o&&(0,z.jsx)($5,{git:a,open:o,onOpenChange:s}),(0,z.jsx)(Jse,{open:t,onOpenChange:n,children:(0,z.jsx)(Xse,{side:`left`,title:mi(),onClick:e=>e.target instanceof Element&&e.target.closest(`a`)&&n(!1),children:(0,z.jsx)(_7,{onSearch:()=>n(!1),onNewTable:()=>{n(!1),e()}})})})]})}function pce({...e}){return(0,z.jsx)(fE,{"data-slot":`select`,...e})}function mce({...e}){return(0,z.jsx)(gE,{"data-slot":`select-value`,...e})}function hce({className:e,size:t=`default`,children:n,...r}){return(0,z.jsxs)(mE,{"data-slot":`select-trigger`,"data-size":t,className:T(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,z.jsx)(_E,{asChild:!0,children:(0,z.jsx)(dO,{className:`size-4 opacity-50`})})]})}function gce({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,z.jsx)(bE,{children:(0,z.jsxs)(SE,{"data-slot":`select-content`,className:T(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,z.jsx)(vce,{}),(0,z.jsx)(PE,{className:T(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,z.jsx)(yce,{})]})})}function _ce({className:e,children:t,...n}){return(0,z.jsxs)(RE,{"data-slot":`select-item`,className:T(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,z.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,z.jsx)(HE,{children:(0,z.jsx)(lO,{className:`size-4`})})}),(0,z.jsx)(BE,{children:t})]})}function vce({className:e,...t}){return(0,z.jsx)(WE,{"data-slot":`select-scroll-up-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(pO,{className:`size-4`})})}function yce({className:e,...t}){return(0,z.jsx)(KE,{"data-slot":`select-scroll-down-button`,className:T(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,z.jsx)(dO,{className:`size-4`})})}var bce={en:`English`,ja:`日本語`};function xce(){let e=E();return(0,z.jsxs)(pce,{value:e,onValueChange:t=>t!==e&&i(t),children:[(0,z.jsxs)(hce,{size:`sm`,"aria-label":di(),className:`h-6 gap-1 border-0 px-1.5 text-[11px] shadow-none max-md:size-10 max-md:justify-center max-md:p-0 max-md:[&>[data-slot=select-value]]:hidden max-md:[&>svg:last-child]:hidden`,children:[(0,z.jsx)(jO,{className:`size-3.5 max-md:size-4.5`}),(0,z.jsx)(mce,{})]}),(0,z.jsx)(gce,{position:`popper`,align:`end`,children:o.map(e=>(0,z.jsx)(_ce,{value:e,lang:e,children:bce[e]},e))})]})}var Sce={light:Td,dark:wd,system:Ed};function Cce(){let{connected:e,lastSyncAt:t,warnings:n}=ay(),{data:r}=ry(),i=qv(),{data:a}=V_({queryKey:[`conflicts`],queryFn:Uv.conflicts,enabled:i===null}),[o,s]=(0,B.useState)(Date.now()),[c,l]=(0,B.useState)(x);(0,B.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let u=Object.values(n).reduce((e,t)=>e+t.length,0),d=a?.conflicts.length??0,f=c===`system`?UO:c===`light`?yk:GO;return(0,z.jsxs)(`footer`,{className:`flex h-[30px] items-center gap-4 border-t bg-panel px-3 text-[11px] text-muted-foreground max-md:h-[calc(40px+env(safe-area-inset-bottom))] max-md:gap-3 max-md:pb-[env(safe-area-inset-bottom)] max-md:text-[12px]`,children:[i?(0,z.jsx)(`span`,{children:hu({at:i.generatedAt.slice(0,16).replace(`T`,` `)})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,"aria-live":`polite`,children:[(0,z.jsx)(`span`,{className:`size-[7px] rounded-full ${e?`bg-ok`:`bg-err`}`}),e?d7()?cu():(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`max-md:hidden`,children:wu({root:r?.root??``})}),(0,z.jsx)(`span`,{className:`md:hidden`,children:cu()})]}):lu()]}),(0,z.jsx)(`span`,{className:`max-md:hidden`,children:fu({ago:Xoe(t,o)})}),!d7()&&(0,z.jsx)(`span`,{className:`max-md:hidden`,children:location.host})]}),(0,z.jsxs)(`span`,{className:`ml-auto flex items-center gap-3.5`,children:[u>0&&(i?(0,z.jsx)(`span`,{className:`text-warn`,children:xu({count:u})}):(0,z.jsx)(Yh,{to:`/sync`,className:`text-warn hover:underline`,children:xu({count:u})})),d>0&&(0,z.jsx)(`span`,{className:`text-err`,children:su({count:d})}),(0,z.jsx)(xce,{}),(0,z.jsx)(`button`,{type:`button`,"aria-label":vu({theme:Sce[c]()}),className:`rounded p-1 hover:bg-panel-2 max-md:grid max-md:size-10 max-md:place-items-center`,onClick:()=>{let e=v(c);C(e),l(e)},children:(0,z.jsx)(f,{className:`size-3.5 max-md:size-4.5`})})]})]})}function wce(){return UJ()?(0,z.jsx)(WJ.Provider,{value:!0,children:(0,z.jsx)(Tce,{})}):(0,z.jsx)(Ece,{})}function y7(){let{configError:e}=ay();return e?(0,z.jsx)(`div`,{role:`alert`,className:`bg-warn-soft px-4 py-2 text-[12px] text-warn`,children:Nl({error:e})}):null}function Tce(){let e=kX();return(0,z.jsxs)(`div`,{className:`grid h-[var(--y-shell-h,100dvh)] grid-cols-1 grid-rows-[auto_1fr_auto]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(s7,{}),(0,z.jsx)(y7,{})]}),(0,z.jsx)(`main`,{className:`flex min-h-0 min-w-0`,children:(0,z.jsx)(dg,{})}),(0,z.jsx)(Fse,{}),(0,z.jsx)(V$,{position:e?`top-center`:`bottom-right`}),(0,z.jsx)(c7,{})]})}function Ece(){let[e,t]=(0,B.useState)(!1),n=kX(),r=K$(),i=_1()&&r!==null,[a,o]=JX(`yamlite-sidebar-width`,220,GX);return(0,z.jsxs)(`div`,{className:`grid h-[var(--y-shell-h,100dvh)] grid-cols-1 grid-rows-[auto_1fr_auto]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(s7,{}),(0,z.jsx)(y7,{}),n&&(0,z.jsx)(fce,{onNewTable:()=>t(!0)})]}),(0,z.jsxs)(`div`,{className:`grid min-h-0 grid-cols-1`,style:n?void 0:{gridTemplateColumns:`${a}px 1fr`},children:[!n&&(0,z.jsxs)(`div`,{className:`relative min-h-0`,children:[(0,z.jsx)(_7,{onNewTable:()=>t(!0)}),(0,z.jsx)(QX,{width:a,label:Di(),onResize:o,edge:`right`,bounds:GX})]}),(0,z.jsxs)(`main`,{className:`flex min-h-0 min-w-0`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:(0,z.jsx)(dg,{})}),i&&(0,z.jsx)(wse,{})]})]}),(0,z.jsx)(Cce,{}),(0,z.jsx)(Kse,{}),e&&(0,z.jsx)(l7,{open:!0,onOpenChange:t}),(0,z.jsx)(V$,{position:n?`top-center`:`bottom-right`}),(0,z.jsx)(c7,{})]})}var Dce=36,b7=1,Oce=2,x7=3,S7=4,kce=5,Ace=6,jce=7,Mce=8,Nce=9,Pce=10,Fce=11,Ice=12,Lce=13,Rce=14,zce=15,Bce=16,Vce=17,C7=18,Hce=19,w7=20,T7=21,E7=22,Uce=23,Wce=24;function D7(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function Gce(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function O7(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function Kce(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue scan;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function qce(e,t){let n=`[{<(`.indexOf(String.fromCharCode(t)),r=n<0?t:`]}>)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function k7(e,t){for(;e.next==95||D7(e.next);)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Jce(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),O7(e,t,!1)}else k7(e)}function A7(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function j7(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function M7(e){for(;!(e.next<0||e.next==10);)e.advance()}function N7(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var P7=` \r
|
|
124
|
+
`;function F7(e,t,n){let r=Object.create(null);r.true=r.false=kce,r.null=r.unknown=Ace;for(let t of e.split(` `))t&&(r[t]=w7);for(let e of t.split(` `))e&&(r[e]=T7);for(let e of(n||``).split(` `))e&&(r[e]=Wce);return r}var I7={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:`*+-%<>!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:F7(`absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone `,`array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying `)};function Yce(e,t,n,r){let i={};for(let t in I7)i[t]=(e.hasOwnProperty(t)?e:I7)[t];return t&&(i.words=F7(t,n||``,r)),i}function L7(e){return new ZA(t=>{let{next:n}=t;if(t.advance(),N7(n,P7)){for(;N7(t.next,P7);)t.advance();t.acceptToken(Dce)}else if(n==36&&e.doubleDollarQuotedStrings){let e=k7(t,``);t.next==36&&(t.advance(),Kce(t,e),t.acceptToken(x7))}else if(n==39||n==34&&e.doubleQuotedStrings)O7(t,n,e.backslashEscapes),t.acceptToken(x7);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)M7(t),t.acceptToken(b7);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))M7(t),t.acceptToken(b7);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(Oce)}else if((n==101||n==69)&&t.next==39)t.advance(),O7(t,39,!0),t.acceptToken(x7);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),O7(t,39,e.backslashEscapes),t.acceptToken(x7);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),O7(t,39,e.backslashEscapes),t.acceptToken(x7);break}if(!D7(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!N7(t.peek(1),P7)){let e=t.peek(1);t.advance(2),qce(t,e),t.acceptToken(x7)}else if(N7(n,e.identifierQuotes))O7(t,n==91?93:n,!1),t.acceptToken(Hce);else if(n==40)t.acceptToken(jce);else if(n==41)t.acceptToken(Mce);else if(n==123)t.acceptToken(Nce);else if(n==125)t.acceptToken(Pce);else if(n==91)t.acceptToken(Fce);else if(n==93)t.acceptToken(Ice);else if(n==59)t.acceptToken(Lce);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),A7(t),t.acceptToken(E7);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(O7(t,n,e.backslashEscapes),t.acceptToken(Uce)):(A7(t,n),t.acceptToken(E7))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();Gce(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(S7)}else if(n==46&&t.next>=48&&t.next<=57)j7(t,!0),t.acceptToken(S7);else if(n==46)t.acceptToken(Rce);else if(n>=48&&n<=57)j7(t,!1),t.acceptToken(S7);else if(N7(n,e.operatorChars)){for(;N7(t.next,e.operatorChars);)t.advance();t.acceptToken(zce)}else if(N7(n,e.specialVar))t.next==n&&t.advance(),Jce(t),t.acceptToken(Vce);else if(n==58||n==44)t.acceptToken(Bce);else if(D7(n)){let r=k7(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?C7:e.words[r.toLowerCase()]??C7)}})}var R7=L7(I7),Xce=oj.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,R7],topRules:{Script:[0,25]},tokenPrec:0});function z7(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function B7(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function V7(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Zce(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)V7(r)&&n.push(B7(e,r));return n}return[B7(e,t)]}function H7(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=z7(t);if(!V7(r))return n;n.unshift(B7(e,r)),t=z7(r)}}function Qce(e,t){let n=UB(e).resolveInner(t,-1),r=ele(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:H7(e.doc,z7(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:H7(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var $ce=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function ele(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&V7(t.nextSibling))o=B7(e,t.nextSibling);else if(n&&$ce.has(n))break;else a&&V7(t)&&(o=B7(e,t));o&&(r||=Object.create(null),r[o]=Zce(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function tle(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var nle=/^\w*$/,rle=/^[`'"\[]?\w*[`'"\]]?$/;function U7(e){return e.self&&typeof e.self.label==`string`}var ile=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(W7(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?W7(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):U7(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;U7(n)&&(r=n.self,n=n.children);for(let e=0;e<i.length;e++)r&&e==i.length-1&&a.addCompletion(r),a=a.child(i[e].replace(/\\\./g,`.`));a.addNamespace(n)}}};function W7(e,t,n,r){return RegExp(`^[a-z_][a-z_\\d]*$`,r?`i`:``).test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+G7(n)}}function G7(e){return e===`[`?`]`:e}function ale(e,t,n,r,i,a){let o=new ile(a?.spec.identifierQuotes?.[0]||`"`,!!a?.spec.caseInsensitiveIdentifiers),s=i?o.child(i):null;return o.addNamespace(e),t&&(s||o).addCompletions(t),n&&o.addCompletions(n),s&&o.addCompletions(s.list),r&&o.addCompletions((s||o).child(r).list),e=>{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=Qce(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=G7(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:tle(t,r,u),validFor:rle}}return{from:n,options:u,validFor:nle}}}function ole(e){return e==T7?`type`:e==w7?`keyword`:`variable`}function sle(e,t,n){return sG([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],oG(Object.keys(e).map(r=>n(t?r.toUpperCase():r,ole(e[r])))))}var cle=Xce.configure({props:[rV.add({Statement:sV()}),lV.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),dj({Keyword:W.keyword,Type:W.typeName,Builtin:W.standard(W.name),Bits:W.number,Bytes:W.string,Bool:W.bool,Null:W.null,Number:W.number,String:W.string,Identifier:W.name,QuotedIdentifier:W.special(W.string),SpecialVar:W.special(W.name),LineComment:W.lineComment,BlockComment:W.blockComment,Operator:W.operator,"Semi Punctuation":W.punctuation,"( )":W.paren,"{ }":W.brace,"[ ]":W.squareBracket})]}),lle=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=Yce(t,t.keywords,t.types,t.builtin),r=HB.define({name:`sql`,parser:cle.configure({tokenizers:[{from:R7,to:L7(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}});return new e(n,r,t)}};function ule(e,t){return{label:e,type:t,boost:-1}}function dle(e,t=!1,n){return sle(e.dialect.words,t,n||ule)}function fle(e){return e.schema?ale(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||K7):()=>null}function ple(e){return e.schema?(e.dialect||K7).language.data.of({autocomplete:fle(e)}):[]}function mle(e={}){let t=e.dialect||K7;return new ZB(t.language,[ple(e),t.language.data.of({autocomplete:dle(t,e.upperCaseKeywords,e.keywordCompletion)})])}var K7=lle.define({}),q7=`yamlite-sql-history`,hle=50;function J7(){try{let e=JSON.parse(localStorage.getItem(q7)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function gle(e){let t=[e,...J7().filter(t=>t!==e)].slice(0,hle);try{localStorage.setItem(q7,JSON.stringify(t))}catch{}return t}function Y7(e,t=!0,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i],o=e[i+1];if(a===`-`&&o===`-`){let t=e.indexOf(`
|
|
125
|
+
`,i);i=t<0?e.length:t,r+=` `}else if(a===`/`&&o===`*`){let t=e.indexOf(`*/`,i+2);i=t<0?e.length:t+2,r+=` `}else if(a===`'`||a===`"`||a==="`"||a===`[`){let o=a===`[`?`]`:a,s=i+1;for(;s<e.length;s++)if(e[s]===o){if(o!==`]`&&e[s+1]===o)s++;else break}r+=a===`'`&&!n||!t?`''`:e.slice(i,s+1),i=s+1}else r+=a,i++}return r}var _le=e=>Y7(e,!1).split(`;`).filter(e=>e.trim()!==``).length,X7=e=>/^\s*([A-Za-z]+)/.exec(Y7(e))?.[1]?.toUpperCase()??``,vle=new Set([`SELECT`,`EXPLAIN`,`VALUES`]),yle=/\b(?:INSERT|UPDATE|DELETE|REPLACE(?!\s*\())\b/i;function ble(e){let t=X7(e);return vle.has(t)||t===`WITH`&&!yle.test(Y7(e,!1))}function xle(e){let t=X7(e);return t===`DROP`?Wl():(t===`DELETE`||t===`UPDATE`)&&!/\bWHERE\b/i.test(Y7(e))?Gl():null}function Sle(e){return typeof e==`object`?e.key:e}function Cle(e,t){let n=e.length;return new Proxy(e,{get(e,r,i){if(typeof r==`string`){let i=r.charCodeAt(0);if(i>=48&&i<=57){let i=+r;if(Number.isInteger(i)&&i>=0&&i<n){let n=e[i];if(typeof n!=`object`){let r=t[i*2];n=e[i]={index:i,key:n,start:r,size:t[i*2+1],end:r+t[i*2+1],lane:0}}return n}}if(r===`length`)return n}return Reflect.get(e,r,i)}})}function Z7(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return(o.length!==r.length||o.some((e,t)=>r[t]!==e))&&(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1),i}return o.updateDeps=e=>{r=e},o}function Q7(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var $7=(e,t)=>Math.abs(e-t)<1.01,wle=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};function Tle({offset:e,isScrolling:t,elementMax:n,holdOffset:r,scrollOffset:i,pendingWrite:a,clampedMaxAtWrite:o}){return t&&a===null&&e===i?`spurious`:a!==null&&Math.abs(e-a.target)<1.5?`readBack`:a!==null&&!a.smooth&&n!==null&&a.target>n+r+.5&&Math.abs(e-(n+r))<1.5||a!==null&&!a.smooth&&a.lowMaxes?.some(t=>Math.abs(e-t)<1.5)?`clampedReadBack`:o!==null&&Math.abs(e-o)<1.5?`clampedEcho`:`external`}var Ele=e=>e===`smooth`||e===`smoothFinishing`;function Dle({kind:e,offset:t,command:n,target:r}){return e!==`spurious`&&e!==`readBack`&&e!==`clampedReadBack`&&n?.index!=null&&n.phase!==`queued`&&!Ele(n.phase)&&!$7(t,n.lastTargetOffset)&&!$7(t,r())&&e!==`clampedEcho`}var e9=40;function Ole(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<e9;)n--;if(n<0)return!1;let r=e[n],i=n-1;for(;i>=0&&r.t-e[i].t<e9;)i--;if(i<0)return!1;let a=e[i],o=(t.offset-r.offset)/(t.t-r.t),s=(r.offset-a.offset)/(r.t-a.t);return o*s>=0&&Math.abs(o)>=2*Math.abs(s)&&Math.abs(o)-Math.abs(s)>=.8}function kle(e){let t=e[e.length-1];if(t===void 0)return!1;let n=e.length-2;for(;n>=0&&t.t-e[n].t<e9;)n--;if(n<0)return!1;let r=e[n];return Math.abs(t.offset-r.offset)/(t.t-r.t)>=.05}var t9,n9=()=>{if(t9!==void 0)return t9;if(typeof navigator>`u`)return t9=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return t9=!0;let e=navigator.maxTouchPoints;return t9=navigator.platform===`MacIntel`&&e!==void 0&&e>0},r9,Ale=()=>r9===void 0?r9=n9()&&typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`overflow-anchor: auto`):r9,i9={capture:!0,passive:!0},jle=class{constructor(e){this.host=e,this._touch=null,this.inMotion=()=>this._touch!==null&&this._touch.phase!==`lateFling`,this.dragging=()=>this._touch?.phase===`down`&&this._touch.moved,this.tail=()=>this._touch?.phase===`tail`?this._touch.moved?`fling`:`tap`:null,this.onScroll=({isScrolling:e,ownReadBack:t,moved:n,external:r})=>(e&&this._touch?.phase===`tail`?this._openTail(this._touch.moved||!t,!1):this._touch?.phase===`lateFling`&&(this.host.now()>this._touch.until?this._touch=null:r&&e&&n&&this._openTail(!0,!1)),!t&&e&&n&&this._touch?.phase===`down`?(this._touch.moved=!0,!0):!1),this.touchStart=()=>{this.end(),this._touch={phase:`down`,moved:!1}},this.touchEnd=()=>{let e=this._touch?.phase===`down`&&this._touch.moved;this.end(),this._openTail(e,e)},this.end=()=>{let e=this.host.getWindow();this._touch?.phase===`tail`&&e!=null&&e.clearTimeout(this._touch.timerId),this._touch=null},this.listen=e=>{let t=()=>this.touchStart(),n=()=>this.touchEnd();return e.addEventListener(`touchstart`,t,i9),e.addEventListener(`touchend`,n,i9),e.addEventListener(`touchcancel`,n,i9),()=>{e.removeEventListener(`touchstart`,t,i9),e.removeEventListener(`touchend`,n,i9),e.removeEventListener(`touchcancel`,n,i9),this.end()}},this._openTail=(e,t)=>{let n=this.host.getWindow();if(!n9()||n==null)return;this.end();let r={phase:`tail`,moved:e,awaitingFling:t,timerId:n.setTimeout(()=>{this.host.tailStillMoving()?this._openTail(r.moved,r.awaitingFling):(this._touch=r.awaitingFling?{phase:`lateFling`,until:this.host.now()+1e3}:null,this.host.onTailClosed())},150)};this._touch=r}}get touch(){return this._touch}},a9=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},o9=e=>{let t=new Set;return{schedule:n=>{let r=e.requestAnimationFrame(()=>{t.delete(r),n()});t.add(r)},cancel:()=>{t.forEach(t=>e.cancelAnimationFrame(t)),t.clear()}}},Mle=e=>e,Nle=e=>{let t=e.overscan*Math.max(e.lanes??1,1),n=Math.max(e.startIndex-t,0),r=Math.min(e.endIndex+t,e.count-1)-n+1,i=Array(r);for(let e=0;e<r;e++)i[e]=n+e;return i},Ple=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(a9(n)),!r.ResizeObserver)return()=>{};let a=o9(r),o=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(a9(n))};e.options.useAnimationFrameWithResizeObserver?a.schedule(r):r()});return o.observe(n,{box:`border-box`}),()=>{o.unobserve(n),a.cancel()}},s9={passive:!0},Fle=typeof window>`u`||`onscrollend`in window,Ile=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Fle,o=0,s=a?null:wle(i,()=>t(n(r),!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,s9),a&&r.addEventListener(`scrollend`,u,s9),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},Lle=(e,t)=>Ile(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Rle=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},zle=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},c9=(e,t)=>e===`smooth`?t?`smoothLanded`:`smooth`:`instant`,l9=e=>e?.phase===`smooth`||e?.phase===`smoothLanded`;function Ble(e,t,n,r){if(t===0)return!1;let i=r(0),a=new Set,o=0;for(;o<e;){let e=n(o);if(e===i)break;a.add(e),o++}let s=e-o;if(s===0||s>=t)return!1;for(let e=0;e<s;e++)if(r(e)!==n(o+e))return!1;for(let e=s;e<t;e++)if(a.has(r(e)))return!1;return!0}var Vle=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._iosGesture=new jle({getWindow:()=>this.targetWindow,now:()=>this.now(),tailStillMoving:()=>{let e=this.scrollState;if(e?.phase!==`queued`||this.pendingWrite!==null)return!1;let t=this._readElementOffset();return t===null||this._lastElementOffset===null||Math.abs(t-this._lastElementOffset)<1?!1:(this._lastElementOffset=t,e.samples=[...e.samples??[],{t:this.now(),offset:t}],!0)},onTailClosed:()=>{let e=this.scrollState;e?.phase===`queued`&&kle(e.samples??[])&&(this.scrollState=null),this._flushHoldIfReady(!0),this._writeAwaitingCommand()}}),this._lastElementOffset=null,this.pendingWrite=null,this._clampedAdjustment=null,this.elementsCache=new Map,this._resizeBatch=null,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=null,n=()=>{if(e)return e;let n=this.targetWindow;if(!n||!n.ResizeObserver)return null;let i=t=o9(n);return e=new n.ResizeObserver(e=>{let t=()=>{let t={sync:!1};this._resizeBatch=t;try{e.forEach(r)}finally{this._resizeBatch=null,t.notify&&(this.notify(t.sync),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment())}};this.options.useAnimationFrameWithResizeObserver?i.schedule(t):t()})},r=e=>{let t=e.target,n=this.indexFromElement(t);if(t.isConnected)this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this));else{this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}}};return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t?.cancel(),e=null,t=null},observe:e=>n()?.observe(e,{box:`border-box`}),unobserve:e=>n()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Mle,rangeExtractor:Nle,onChange:()=>{},measureElement:Rle,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=this._singleLaneMeasurements?.items??s,l=e=>Sle(c[e]),u=e>0?l(0):null,d=e>0?l(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==u||t.getItemKey(o-1)!==d)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>0&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==d)&&(o>e||Ble(e,o,l,t.getItemKey))&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=null;if(r&&this.scrollOffset!==null&&!this._awaitingCommandReadBack()){let[e,t]=r,n=this.getMeasurements(),{count:a,getItemKey:s}=this.options,c=0;for(;c<a&&s(c)!==e;)c++;if(c<a){let e=n[c];if(e){let n=Math.max(0,e.start+t);!i&&n!==this.scrollOffset&&(o=n-this.scrollOffset,this.scrollOffset=n)}}}i?this.pendingScrollAnchor={kind:`follow`,behavior:i}:o!==null&&(this._canWriteScroll()?this.pendingScrollAnchor={kind:`anchor`,delta:o}:(this._holdOffset+=o,this._followOffsetTarget(o)))},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Z7(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{var e;this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,(e=this._momentumStop)==null||e.restore(),this._momentumStop=null,this.isScrolling=!1,this.scrollDirection=null,this._holdOffset=0,this._reportedOverscroll=!1,this._clampedAdjustment=null,this.pendingWrite=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{let n=t?this._elementMaxScrollOffset():null,r=this._reportedOverscroll;this._reportedOverscroll=e<0||n!==null&&e>n+1;let i=e;this._lastElementOffset=i,e=this._toLayoutOffset(e);let a=this._classifyScrollEvent(e,t,n);if(a===`spurious`)return;a===`readBack`?e=this.pendingWrite.target:a===`clampedReadBack`&&this.scrollState?.index!=null&&e<this.getMaxScrollOffset()-1.5?this.scrollState.lastTargetOffset=e:Dle({kind:a,offset:e,command:this.scrollState,target:()=>this.getScrollStateTarget(this.scrollState)})&&(this.scrollState=null),this.pendingWrite=null,this._clampedAdjustment!==null&&Math.abs(e-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null);let o=this.getScrollOffset(),s=this.scrollDirection;this.scrollDirection=t?o===e?this.scrollDirection:o<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t;let c=this.scrollState;if(c?.phase===`queued`&&a===`external`&&t){if(r||this._reportedOverscroll)c.samples=[];else{let e=this.now();c.samples=[...(c.samples??[]).filter(t=>e-t.t<=200),{t:e,offset:i}],(s!==null&&this.scrollDirection!==s||Ole(c.samples))&&(this.scrollState=null)}}this._iosGesture.onScroll({isScrolling:t,ownReadBack:a===`readBack`,moved:e!==o,external:a===`external`&&this.scrollState?.phase!==`smooth`&&this.scrollState?.phase!==`smoothFinishing`})&&this.scrollState?.phase===`queued`&&(this.scrollState=null),this._flushHoldIfReady(!0),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement&&this.unsubs.push(this._iosGesture.listen(this.scrollElement)),this._scrollToOffset(this.getScrollOffset())}this._noteClampMax();let t=this.pendingScrollAnchor;this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled&&(t.kind===`anchor`?this._canWriteScroll()?l9(this.scrollState)&&!$7(this.getScrollOffset()-t.delta,this.scrollState.lastTargetOffset)||(this._followOffsetTarget(t.delta),this._scrollToOffset(this.getScrollOffset())):(this._holdOffset+=t.delta,this._followOffsetTarget(t.delta),this.notify(!1)):this.scrollToEnd({behavior:t.behavior})),this._flushHoldIfReady(!1),this._retryClampedAdjustment()},this._classifyScrollEvent=(e,t,n)=>Tle({offset:e,isScrolling:t,elementMax:n,holdOffset:this._holdOffset,scrollOffset:this.scrollOffset,pendingWrite:this.pendingWrite,clampedMaxAtWrite:this._clampedAdjustment?.maxAtWrite??null}),this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;let{target:e,maxAtWrite:t}=this._clampedAdjustment,n=this.getMaxScrollOffset();n>t+.5&&(this._clampedAdjustment=e>n+.5?{target:e,maxAtWrite:n}:null,this._scrollToOffset(e))},this._writeAwaitingCommand=()=>{let e=this.scrollState;if(e===null||e.phase!==`queued`)return;let{behavior:t}=e;this.getMeasurements();let n=this.getScrollStateTarget(e);e.lastTargetOffset=n,this._clampedAdjustment=null,e.phase=c9(t,e.index!=null&&$7(n,this.getScrollOffset())),this._scrollToOffset(n,{behavior:t}),this.scheduleScrollReconcile()},this._readElementOffset=()=>{let e=this.scrollElement;if(e==null)return null;let{horizontal:t,isRtl:n}=this.options;return typeof e.scrollTop==`number`?t?e.scrollLeft*(n&&-1||1):e.scrollTop:typeof e.scrollY==`number`?t?e.scrollX:e.scrollY:null},this._canWriteScroll=()=>!(n9()&&this._iosGesture.inMotion())&&!this._reportedOverscroll,this._flushHoldIfReady=e=>{if(this._holdOffset===0||!this.scrollElement||!this.options.enabled||!this._canWriteScroll()||this.scrollState?.phase===`smooth`)return;this._holdOffset=0,this.scrollOffset!==null&&this.scrollOffset<0&&(this.scrollOffset=0),this.notify(e);let t=this.getCommandWrittenOffset()??this.getScrollOffset();this._clampedAdjustment=this._clampedBy(t),this._scrollToOffset(t)},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Z7(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Z7(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._singleLaneMeasurements?.flat;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e}let o=u===0?Array(e):this._singleLaneMeasurements.items.slice(),c;if(u===0)c=t+n;else{let e=u-1;c=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t);o[t]=e;let n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=c,a[t*2+1]=i,c+=i+s}this._singleLaneMeasurements={flat:a,items:o};let d=Cle(o,a);return this.measurementsCache=d,d}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Z7(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Ule(e,t,n,r,r===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Z7(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t,this.options.lanes]},(e,t,n,r,i,a)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n,lanes:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!l9(this.scrollState))return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),e.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{var n;if(!this.isIndexInRange(e))return;this._resizeBatch?.sync&&this.getMeasurements();let r,i,a,o=this._singleLaneMeasurements?.flat;if(this.options.lanes===1&&o!=null)a=this.options.getItemKey(e),i=o[e*2],r=o[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;a=t.key,i=t.start,r=t.size}let s=this.itemSizeCache.get(a)??r,c=t-s;if(c!==0){let o=this.options.anchorTo===`end`&&!l9(this.scrollState)&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,l=o?this._getLayoutTotalSize():0,u=this.getScrollOffset(),d=this.itemSizeCache.has(a)?i+s<=u&&this.scrollDirection!==`backward`:i<u,f=!l9(this.scrollState)&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?d:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:a,start:i,size:r,end:i+r,lane:0},c,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(a,t),this.itemSizeCacheVersion++;let p=!1;if(this._awaitingCommandReadBack()||(o?p=this.applyScrollAdjustment(this._getLayoutTotalSize()-l):f&&(p=this.applyScrollAdjustment(c))),this._resizeBatch){this._resizeBatch.notify=!0,(n=this._resizeBatch).sync||(n.sync=p);return}this.notify(p),this._noteClampMax(),this._flushHoldIfReady(!0),this._retryClampedAdjustment()}},this.getVirtualItems=Z7(()=>[this.getVirtualIndexes(),this.getMeasurements(),this._holdOffset],(e,t,n)=>{let r=[];for(let i=0,a=e.length;i<a;i++){let a=t[e[i]];r.push(n===0?a:{...a,start:a.start-n,end:a.end-n})}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._singleLaneMeasurements?.flat,r=this.options.lanes===1&&n!=null;return Q7(t[u9(0,t.length-1,r?e=>n[e*2]:e=>Q7(t[e]).start,e)])},this._noteClampMax=()=>{if(!this._awaitingCommandReadBack())return;let e=this._elementMaxScrollOffset();if(e===null)return;let t=this.pendingWrite,n=Math.max(e,0)+this._holdOffset;if(n>=t.target)return;let r=t.lowMaxes??=[];r[r.length-1]!==n&&r.push(n)},this.getMaxScrollOffset=()=>(this._elementMaxScrollOffset()??0)+this._holdOffset,this._toLayoutOffset=e=>{let t=e+this._holdOffset;return this.pendingScrollAnchor?.kind===`anchor`&&(t+=this.pendingScrollAnchor.delta),t},this._elementMaxScrollOffset=()=>{let e=this.scrollElement;if(e===null)return null;if(`scrollHeight`in e)return this.options.horizontal?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight;if(`document`in e){let t=e.document.documentElement;return this.options.horizontal?t.scrollWidth-e.innerWidth:t.scrollHeight-e.innerHeight}return null},this._momentumStop=null,this._stopMomentum=e=>{let t=this.scrollElement,n=this.targetWindow;if(t===null||n===null)return;let r=`document`in t?t.document.scrollingElement:t;if(!r?.style)return;if(this._momentumStop){this._momentumStop.done=e;return}let{style:i}=r,a=this.options.horizontal?`overflow-x`:`overflow-y`,o=i.getPropertyValue(a),s=i.getPropertyPriority(a);i.setProperty(a,`hidden`,`important`);let c={restore:()=>i.getPropertyValue(a)!==`hidden`||i.getPropertyPriority(a)!==`important`?!1:(i.setProperty(a,o,s),!0),done:e};this._momentumStop=c,n.requestAnimationFrame(()=>n.requestAnimationFrame(()=>{this._momentumStop===c&&(this._momentumStop=null,c.restore()&&c.done())}))},this._clampedBy=e=>{let t=this._elementMaxScrollOffset();if(t===null)return null;let n=t+this._holdOffset;return e>n+.5?{target:e,maxAtWrite:n}:null},this.getVirtualDistanceFromEnd=()=>Math.max(this._getLayoutTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1){let e=this.getMaxScrollOffset(),n=e-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(n,e),0),t]}let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._startScroll({index:null,align:t},this.getOffsetForAlignment(e,t),n,`absolute`)},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r;this._startScroll({index:e,align:a},i,n,`absolute`)},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getOffsetForAlignment((this.getCommandWrittenOffset()??this.getScrollOffset())+e,`start`);this._startScroll({index:null,align:`start`},n,t,`relative`)},this.scrollToEnd=({behavior:e=`auto`}={})=>{this.options.count>0?this._startScroll({index:this.options.count-1,align:`end`,toEnd:!0},Math.max(this.getMaxScrollOffset(),0),e,`absolute`):this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>Math.max(this._getLayoutTotalSize()-this._holdOffset,0),this._getLayoutTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._singleLaneMeasurements?.flat;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n}={})=>{let r={target:e+(t??0),smooth:n===`smooth`};return this.pendingWrite=r,this.options.scrollToFn(e-this._holdOffset,{behavior:n,adjustments:t},this),r},this.getCommandWrittenOffset=()=>this.scrollState!==null&&this.pendingWrite!==null&&!this.pendingWrite.smooth?this.pendingWrite.target:null,this._awaitingCommandReadBack=()=>{let e=this.getCommandWrittenOffset();return!(n9()&&this._iosGesture.dragging())&&e!==null&&!$7(e,this.getScrollOffset())},this._followOffsetTarget=e=>{this.scrollState!==null&&this.scrollState.index==null&&(this.scrollState.lastTargetOffset+=e)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}get scrollAdjustments(){return 0}applyScrollAdjustment(e,t){if(e===0)return!1;if(this._followOffsetTarget(e),this._canWriteScroll()){let n=this.getScrollOffset();this._clampedAdjustment=this._clampedBy(n+e);let r=this._scrollToOffset(n,{adjustments:e,behavior:t});return this.scrollOffset!==null&&(this.pendingWrite===r&&(this.scrollOffset+=e),this.scrollOffset<0&&(this.scrollOffset=0)),!0}return this._holdOffset+=e,this.scrollOffset!==null&&(this.scrollOffset+=e),!0}scheduleScrollReconcile(){this.targetWindow?this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}):this.scrollState=null}getScrollStateTarget(e){let t=e.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:e.index==null?void 0:this.getOffsetForIndex(e.index,e.align);return t?t[0]:e.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}if(this.scrollState.phase===`queued`){this.scheduleScrollReconcile();return}this.getMeasurements();let e=this.getScrollStateTarget(this.scrollState),t=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,n=e!==this.scrollState.lastTargetOffset;if(!n&&$7(e,this.getScrollOffset())){if(this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothLanded`:this.scrollState.phase===`smoothFinishing`&&(this.scrollState.phase=`instant`),this.scrollState.stableFrames++,this.scrollState.stableFrames>=t){this.getScrollOffset()!==e&&this._scrollToOffset(e,{behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let t=this.getSize()||600,n=Math.abs(e-this.getScrollOffset()),r=l9(this.scrollState)&&n>t;this.scrollState.lastTargetOffset=e,r?this.scrollState.phase=`smooth`:this.scrollState.phase===`smooth`?this.scrollState.phase=`smoothFinishing`:this.scrollState.phase===`smoothLanded`&&(this.scrollState.phase=`instant`),this._scrollToOffset(e,{behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}_startScroll(e,t,n,r){let i=this._iosGesture.tail();if(r===`absolute`&&i!==null){if(i===`fling`&&Ale()){this._stopMomentum(()=>{this.scrollState?.phase!==`queued`||this._iosGesture.tail()!==`fling`||this._reportedOverscroll||(this._iosGesture.end(),this._flushHoldIfReady(!0),this._writeAwaitingCommand())}),this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,phase:`queued`,behavior:n,samples:[]},this.scheduleScrollReconcile();return}this._iosGesture.end()}this.scrollState={...e,startedAt:this.now(),lastTargetOffset:t,stableFrames:0,behavior:n,phase:c9(n,e.index!=null&&$7(t,this.getScrollOffset()))},this._scrollToOffset(t,{behavior:n}),this.scheduleScrollReconcile()}},u9=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Hle(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Ule(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Hle(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=u9(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var d9=typeof document<`u`?B.useLayoutEffect:B.useEffect;function Wle({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=B.useReducer(e=>e+1,0)[1],a=B.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=B.useRef(!1),s=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},c=(e,t,n)=>{let r=a.current,i=!!e.options.horizontal,o=t.start-e.options.scrollMargin;r.lastPositions.get(n)!==o&&(r.lastPositions.set(n,o),r.mode===`transform`?n.style.transform=i?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:n.style[i?`left`:`top`]=`${o}px`)},l=e=>{let t=a.current;if(t.enabled&&t.container){s(e);for(let t of e.getVirtualItems()){let n=e.elementsCache.get(t.key);n&&c(e,t,n)}}},u={...r,onChange:(t,n)=>{var s;let c=a.current,u=!0;if(c.enabled){l(t);let e=t.range,n=c.prevRange;u=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,u&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}u&&(e&&n&&!o.current?(0,W_.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[d]=B.useState(()=>{let e=new Vle(u),t=e.measureElement;return e.measureElement=n=>{o.current=!0;try{t(n)}finally{o.current=!1}let r=a.current;if(n!==null&&r.enabled&&r.container){let t=e.measurementsCache[e.indexFromElement(n)];t&&c(e,t,n)}},Object.assign(e,{containerRef:t=>{let n=a.current;n.container=t,n.lastSize=null,t!==null&&l(e)}})});return d.setOptions(u),d9(()=>d._didMount(),[]),d9(()=>(s(d),d._willUpdate())),d9(()=>{l(d)}),d}function Gle(e){return Wle({observeElementRect:Ple,observeElementOffset:Lle,scrollToFn:zle,...e})}var f9=(0,B.createContext)(``);function Kle(e,t){if(t===``)return[{text:e,match:!1}];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0;for(let t=n.indexOf(r);t>=0;t=n.indexOf(r,a))t>a&&i.push({text:e.slice(a,t),match:!1}),i.push({text:e.slice(t,t+r.length),match:!0}),a=t+r.length;return a<e.length&&i.push({text:e.slice(a),match:!1}),i}function p9({text:e}){let t=Kle(e,(0,B.useContext)(f9));return t.length===1&&!t[0]?.match?e:t.map((e,t)=>e.match?(0,z.jsx)(`mark`,{className:`rounded-[2px] bg-warn-soft text-foreground`,children:e.text},t):e.text)}function m9({value:e}){return typeof e==`string`?(0,z.jsx)(`span`,{className:`text-syn-str`,children:JSON.stringify(e)}):typeof e==`number`?(0,z.jsx)(`span`,{className:`text-syn-num`,children:e}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:String(e)})}function h9({value:e}){if(xJ(e))return(0,z.jsx)(m9,{value:e});let t=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e);return(0,z.jsx)(`div`,{className:`font-mono text-[12px] leading-[1.7]`,children:t.map(([t,n])=>(0,z.jsxs)(`div`,{children:[!Array.isArray(e)&&(0,z.jsx)(`span`,{className:`text-syn-key`,children:t}),!Array.isArray(e)&&`: `,xJ(n)?(0,z.jsx)(m9,{value:n}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:Array.isArray(n)?`[${n.length}]`:`{${Object.keys(n).length}}`}),(0,z.jsx)(`div`,{className:`ml-[3px] border-l pl-3.5`,children:(0,z.jsx)(h9,{value:n})})]})]},t))})}function g9({title:e,value:t,children:n}){return(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:n}),(0,z.jsxs)(zk,{className:`w-[min(20rem,calc(100vw-2rem))]`,align:`start`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`div`,{className:`mb-1 flex justify-between text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>void navigator.clipboard?.writeText(JSON.stringify(t,null,2)),children:ui()})]}),(0,z.jsx)(h9,{value:t})]})]})}var _9=`inline-block rounded-full bg-chip px-[7px] text-[11.5px] text-chip-foreground mr-[3px]`;function qle({value:e,type:t,format:n,column:r,rowKey:i}){let a=kJ(e,t,n);switch(a.kind){case`null`:return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});case`bool`:return(0,z.jsx)(`span`,{role:`img`,"aria-label":a.value?`true`:`false`,className:`inline-flex size-3.5 items-center justify-center rounded-[3px] border-[1.5px] ${a.value?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground`}`,children:a.value&&(0,z.jsx)(lO,{className:`size-2.5`,strokeWidth:4})});case`number`:return(0,z.jsx)(`span`,{className:`font-mono tabular-nums`,children:(0,z.jsx)(p9,{text:a.text})});case`text`:return(0,z.jsx)(`span`,{children:(0,z.jsx)(p9,{text:a.text})});case`chips`:return(0,z.jsxs)(`span`,{children:[a.items.map((e,t)=>(0,z.jsx)(`span`,{className:_9,children:(0,z.jsx)(p9,{text:e})},`${t}-${e}`)),a.more>0&&(0,z.jsxs)(`span`,{className:`inline-block rounded-full bg-chip px-[7px] text-[11.5px] text-chip-foreground mr-[3px]`,children:[`+`,a.more]})]});case`map`:return(0,z.jsx)(g9,{title:`${r} · ${i}`,value:e,children:(0,z.jsxs)(`button`,{type:`button`,className:`text-left max-md:min-h-8`,onClick:e=>e.stopPropagation(),children:[a.entries.map(([e,t])=>(0,z.jsxs)(`span`,{className:`mr-1.5`,children:[(0,z.jsx)(`span`,{className:`mr-0.5 text-[11px] text-muted-foreground`,children:e}),(0,z.jsx)(p9,{text:t})]},e)),a.more>0&&(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`+`,a.more]})]})});case`nested`:return(0,z.jsx)(g9,{title:`${r} · ${i}`,value:e,children:(0,z.jsxs)(`button`,{type:`button`,className:`text-left max-md:min-h-8`,onClick:e=>e.stopPropagation(),children:[(0,z.jsx)(`span`,{className:`mr-1.5 rounded border px-1 font-mono text-[10px] text-muted-foreground`,children:a.label}),(0,z.jsx)(`span`,{className:`border-b border-dotted border-muted-foreground`,children:a.preview})]})})}}function v9({label:e,hint:t,className:n,children:r}){return(0,z.jsx)(`span`,{className:`contents`,onClick:e=>{e.stopPropagation(),e.preventDefault()},children:(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,"aria-label":e,title:typeof t==`string`?t:void 0,className:T(`shrink-0`,n),children:r})}),(0,z.jsx)(zk,{className:`w-auto max-w-[min(20rem,calc(100vw-2rem))] text-[13px] whitespace-pre-line`,children:t})]})})}function y9({column:e,row:t,rowKey:n}){let r=t[e.name],i=kJ(r,e.type,e.format),{reference:a}=e;return a&&(i.kind===`text`||i.kind===`number`)?(0,z.jsx)(HJ,{reference:a,value:String(r),children:(0,z.jsx)(p9,{text:String(r)})}):a&&i.kind===`chips`?(0,z.jsxs)(`span`,{children:[i.items.map((e,t)=>(0,z.jsx)(HJ,{reference:a,value:e,className:`${_9} hover:underline`,children:(0,z.jsx)(p9,{text:e})},`${t}-${e}`)),i.more>0&&(0,z.jsxs)(`span`,{className:`inline-block rounded-full bg-chip px-[7px] text-[11.5px] text-chip-foreground mr-[3px]`,children:[`+`,i.more]})]}):(0,z.jsx)(qle,{value:r,type:e.type,format:e.format,column:e.name,rowKey:n})}var Jle=34,Yle=44,b9=`sticky left-0 z-[1] bg-background shadow-[1px_0_0_var(--border)]`,Xle=16;function Zle({column:e,width:t,onResize:n}){let r=e=>t??e.parentElement?.getBoundingClientRect().width??0;return(0,z.jsx)(`div`,{role:`separator`,"aria-label":Ur({column:e}),"aria-orientation":`vertical`,"aria-valuenow":t,tabIndex:0,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget;i.setPointerCapture?.(t.pointerId),document.body.setAttribute(`data-resizing`,``);let a=t.clientX,o=r(i),s=t=>n(e,o+t.clientX-a),c=()=>{document.removeEventListener(`pointermove`,s),document.removeEventListener(`pointerup`,c),document.removeEventListener(`pointercancel`,c),i.removeEventListener(`lostpointercapture`,c),document.body.removeAttribute(`data-resizing`)};document.addEventListener(`pointermove`,s),document.addEventListener(`pointerup`,c),document.addEventListener(`pointercancel`,c),i.addEventListener(`lostpointercapture`,c)},onDoubleClick:()=>n(e,null),onKeyDown:t=>{let i=t.key===`ArrowRight`?Xle:t.key===`ArrowLeft`?-16:0;i!==0&&(t.preventDefault(),n(e,r(t.currentTarget)+i))},className:`absolute inset-y-0 -right-[3px] z-[2] w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/40 focus-visible:bg-primary/40`})}function x9({columns:e,rows:t,keyCol:n,stickyCol:r=n,rowId:i,selectedKey:a,onSelect:o,onEndReached:s,flagged:c,sort:l,onSort:u,widths:d,onResize:f,pinned:p=!0,onTogglePin:m,preview:h}){let g=(0,B.useRef)(null),_=kX(),v=_?Yle:Jle,y=Gle({count:t.length,getScrollElement:()=>g.current,estimateSize:()=>v,overscan:10});(0,B.useEffect)(()=>y.measure(),[v,y]);let b=y.getVirtualItems(),x=b.at(-1)?.index??0;(0,B.useEffect)(()=>{t.length>0&&x>=t.length-20&&s?.()},[x,t.length,s]);let[S,C]=_?[`minmax(120px, 160px)`,`minmax(96px, 1fr)`]:[`minmax(160px, 220px)`,`minmax(110px, 1fr)`],w=e.map(e=>{let t=d?.[e.name];return t===void 0?e.name===n?S:C:`${t}px`}).join(` `),E=p?r:void 0,[D,O]=(l??``).split(`:`);return(0,z.jsx)(`div`,{ref:g,role:`grid`,"aria-rowcount":t.length,className:`min-h-0 flex-1 overflow-auto text-[12.5px] max-md:text-[14px]`,children:(0,z.jsxs)(`div`,{className:`w-max min-w-full`,children:[(0,z.jsx)(`div`,{role:`row`,className:`sticky top-0 z-10 grid border-b bg-background`,style:{gridTemplateColumns:w},children:e.map(e=>(0,z.jsxs)(`div`,{role:`columnheader`,className:T(`group/header relative flex min-w-0 items-center`,e.name===E&&b9),children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1 px-3 py-[7px] text-left text-[11.5px] font-semibold whitespace-nowrap text-muted-foreground max-md:text-[12.5px]`,onClick:()=>u?.(e.name),children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-panel-2 px-1 font-mono text-[9.5px] font-medium max-md:text-[11px]`,children:e.name===n?Rr():e.note??e.type}),D===e.name&&(O===`desc`?(0,z.jsx)(YD,{className:`size-3 shrink-0`}):(0,z.jsx)(aO,{className:`size-3 shrink-0`}))]}),e.name===r&&m&&(0,z.jsx)(`button`,{type:`button`,"aria-label":p?Wr():zr(),"aria-pressed":p,title:p?Gr():Br(),className:T(`mr-1 grid size-6 shrink-0 place-items-center rounded text-muted-foreground hover:bg-panel-2 hover:text-foreground focus-visible:opacity-100 max-md:size-8`,p&&`opacity-0 group-hover/header:opacity-100 max-md:opacity-100`),onClick:m,children:p?(0,z.jsx)($O,{className:`size-3.5`}):(0,z.jsx)(ZO,{className:`size-3.5`})}),f&&!_&&(0,z.jsx)(Zle,{column:e.name,width:d?.[e.name],onResize:f})]},e.name))}),(0,z.jsx)(`div`,{style:{height:y.getTotalSize(),position:`relative`},children:b.map(r=>{let s=t[r.index],l=i?i(s):String(s[n]),u=l===a,d=h?.get(l);return(0,z.jsx)(`div`,{role:`row`,"aria-selected":u,"data-key":l,"data-preview":d?.op,className:T(`group absolute inset-x-0 grid cursor-pointer border-b md:hover:bg-panel`,u&&`bg-tomato-soft md:hover:bg-tomato-soft`,d&&`bg-warn-soft md:hover:bg-warn-soft`,d?.op===`delete`&&`line-through opacity-60`,d?.op===`insert`&&`cursor-default`),style:{gridTemplateColumns:w,height:v,transform:`translateY(${r.start}px)`},onClick:()=>d?.op!==`insert`&&o?.(l,s),children:e.map(e=>(0,z.jsxs)(`div`,{role:`gridcell`,className:T(`flex items-center overflow-hidden px-3 whitespace-nowrap`,e.name===n&&`font-mono text-[12px] max-md:text-[13px]`,e.name===E&&b9,e.name===E&&d&&`bg-warn-soft`,e.name===E&&!d&&(u?`bg-tomato-soft`:`md:group-hover:bg-panel`)),children:[e.name===n&&(c?.has(l)?(0,z.jsx)(v9,{label:`has warnings`,hint:c.get(l)?.join(`
|
|
126
|
+
`),className:`mr-1.5 grid min-h-6 min-w-[1em] place-items-center text-warn max-md:-my-2 max-md:-ml-2 max-md:mr-0 max-md:min-h-8 max-md:min-w-8`,children:`⚠`}):(0,z.jsx)(`span`,{"aria-hidden":!0,className:`mr-1.5 w-[1em] shrink-0`})),d?.op===`update`&&d.changed.includes(e.name)?(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 truncate`,children:[(0,z.jsx)(`span`,{"data-testid":`preview-old`,className:`text-muted-foreground line-through`,children:(0,z.jsx)(y9,{column:e,row:d.before??s,rowKey:l})}),`→`,(0,z.jsx)(`span`,{className:`font-semibold text-ok`,children:(0,z.jsx)(y9,{column:e,row:d.after??s,rowKey:l})})]}):(0,z.jsx)(`span`,{className:`truncate`,children:(0,z.jsx)(y9,{column:e,row:s,rowKey:l})})]},e.name))},l)})})]})})}var Qle={toFile:`M`,deleteFile:`−`,toDb:`M`,deleteDb:`−`};function $le(){let e=h(),t=kX(),{data:n}=ry(),r=iy(),[i,a]=(0,B.useState)(J7),[o,s]=(0,B.useState)(()=>i[0]??`select * from `),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)([]),[f,p]=(0,B.useState)(null),m=(0,B.useRef)(()=>{}),g=()=>{m.current(),d([]);let e=r.listen(e=>{if(e.type!==`sync`)return;let t=e.changes.filter(e=>e.op===`toFile`||e.op===`deleteFile`);t.length>0&&d(n=>[...n,...t.map(t=>({table:e.table,key:t.key,op:t.op}))])}),t=setTimeout(e,1e4);m.current=()=>{clearTimeout(t),e()}};(0,B.useEffect)(()=>()=>m.current(),[]);let _=H_({mutationFn:e=>Uv.sql(e),onMutate:g,onSuccess:(e,t)=>{a(gle(t)),`columns`in e&&(m.current(),d([]))},onError:()=>{m.current(),d([])}}),v=(0,B.useRef)(()=>{});v.current=()=>{if(_.isPending)return;let e=Yv()?null:xle(o);e?l(e):_.mutate(o)};let y=(0,B.useMemo)(()=>[mle({schema:Object.fromEntries((n?.tables??[]).map(e=>[e.name,Object.keys(e.columns)]))}),CM.highest(qR.of([{key:`Mod-Enter`,run:()=>(v.current(),!0)}])),X.lineWrapping],[n]),b=Qv(n),x=_.data;return(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b px-[18px] py-3 max-md:px-3`,children:[(0,z.jsx)(`h1`,{className:`max-md:sr-only text-lg font-semibold tracking-tight`,children:ki()}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsxs)(S5,{children:[(0,z.jsx)(C5,{asChild:!0,children:(0,z.jsxs)(V,{variant:`outline`,size:`sm`,disabled:i.length===0,children:[(0,z.jsx)(ak,{className:`size-3.5`}),` `,Jl()]})}),(0,z.jsx)(w5,{className:`max-w-[min(480px,calc(100vw-2rem))]`,children:i.map(e=>(0,z.jsx)(T5,{className:`truncate font-mono text-[12px]`,onSelect:()=>s(e),children:e},e))})]}),!t&&(0,z.jsxs)(V,{size:`sm`,onClick:()=>v.current(),disabled:_.isPending,children:[(0,z.jsx)(tk,{className:`size-3.5`}),` `,$l()]})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2.5 px-[18px] py-3.5 max-md:px-3`,children:[(0,z.jsx)(Qq,{"aria-label":`SQL`,value:o,onChange:s,extensions:y,theme:e,minHeight:`110px`,className:`overflow-hidden rounded-lg border text-[12.5px]`}),t&&(0,z.jsxs)(V,{size:`lg`,className:`w-full`,onClick:()=>v.current(),disabled:_.isPending,children:[(0,z.jsx)(tk,{className:`size-4`}),` `,Ql()]}),_.isError&&(0,z.jsx)(`div`,{role:`alert`,className:`rounded-md bg-err-soft px-3 py-2 font-mono text-[12px] text-err`,children:_.error.message}),x&&`columns`in x&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`text-[11.5px] text-muted-foreground`,children:[Zl({count:x.rows.length}),x.truncated?tu():``,` · `,x.ms,` ms`]}),(0,z.jsx)(x9,{columns:x.columns.map(e=>({name:e,type:`TEXT`})),rows:x.rows.map((e,t)=>({...e,__row:t})),keyCol:`__row`,stickyCol:x.columns[0]})]}),x&&!(`columns`in x)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex gap-3 text-[11.5px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`text-ok`,children:Ul({count:x.changes})}),(0,z.jsxs)(`span`,{children:[x.ms,` ms`]})]}),!Yv()&&x.unmanaged&&(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md bg-warn-soft px-3 py-2 text-[12px] text-warn`,children:[iu({table:x.unmanaged}),(0,z.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>p(x.unmanaged??null),children:Bl()})]}),u.length>0&&(0,z.jsxs)(`div`,{className:`rounded-lg border px-3 py-2 font-mono text-[12px] leading-[1.8]`,children:[(0,z.jsx)(`div`,{className:`font-sans text-[11px] text-muted-foreground`,children:eu()}),u.map((e,t)=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mr-1.5 font-bold text-warn`,children:Qle[e.op]}),b(e.table,e.key)]},`${t}-${e.table}-${e.key}`))]})]})]}),c&&(0,z.jsx)(qk,{open:!0,onOpenChange:e=>!e&&l(null),children:(0,z.jsxs)(Qk,{children:[(0,z.jsxs)($k,{children:[(0,z.jsx)(nA,{children:Kl()}),(0,z.jsx)(rA,{children:c})]}),(0,z.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded bg-panel p-2 font-mono text-[12px]`,children:o}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>l(null),children:gt()}),(0,z.jsx)(V,{variant:`destructive`,onClick:()=>{l(null),_.mutate(o)},children:ql()})]})]})}),f&&(0,z.jsx)(l7,{open:!0,adopt:f,onOpenChange:e=>!e&&p(null)})]})}function eue(e,t,n){let r=e??{},i=t??{},a=new Set(IJ(r,i));return[...new Set([...Object.keys(r),...Object.keys(i)])].filter(e=>e!==n).map(e=>({field:e,winner:r[e],saved:i[e],same:!a.has(e)}))}function S9(e){return e===`file`?jo():e===`db`?Mo():No()}var tue={ok:`text-ok`,warn:`text-warn`,err:`text-err`,muted:`text-muted-foreground`},nue=e=>e===void 0?`—`:JSON.stringify(e);function C9({entry:e,detail:t,keyCol:n}){return(0,z.jsx)(GZ,{className:`md:text-[11.5px]`,labels:[(0,z.jsx)(`span`,{className:`text-ok`,children:Nu({winner:e.winner??``})}),Eu()],note:t.deleted?Ou():void 0,format:nue,rows:eue(t.current,t.saved,n).map(e=>({field:e.field,a:e.winner,b:e.saved,dim:e.same}))})}function rue({entry:e}){let[t,n]=(0,B.useState)(!1),[r,i]=(0,B.useState)(!1),a=Sg(),{connected:o}=ay(),s=kX(),{data:c}=ry(),l=c?.tables.find(t=>t.name===e.table)?.key,u=V_({queryKey:[`conflict`,e.id],queryFn:()=>Uv.conflict(e.id),enabled:t||r}),d=e=>{a.invalidateQueries({queryKey:[`conflicts`]}),iv.success(e)},f=H_({mutationFn:t=>Uv.restore(e.id,t),onSuccess:()=>{i(!1),d(Yu({table:e.table,key:e.key??``}))},onError:t=>{iv.error(t.message),t instanceof Sv&&t.status===409&&a.invalidateQueries({queryKey:[`conflict`,e.id]})}}),p=H_({mutationFn:()=>Uv.dismiss(e.id),onSuccess:()=>d(Au()),onError:e=>iv.error(e.message)}),m=o?e.restorable?void 0:Ku():yt();return(0,z.jsxs)(`div`,{className:`border-b px-3.5 py-2.5 text-[12px] last:border-b-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left max-md:basis-full max-md:flex-wrap`,onClick:()=>n(!t),children:[t?(0,z.jsx)(dO,{className:`size-3.5`}):(0,z.jsx)(hO,{className:`size-3.5`}),(0,z.jsxs)(`span`,{className:`font-semibold`,children:[e.table,` / `,e.key??e.file]}),(0,z.jsxs)(`span`,{className:`truncate text-[11.5px] text-muted-foreground max-md:basis-full max-md:pl-5 max-md:text-[12.5px] max-md:whitespace-normal`,children:[D5(e.at),` · `,e.winner?ed({winner:e.winner}):zu()]})]}),(0,z.jsx)(V,{size:s?`default`:`sm`,variant:`outline`,disabled:!o||!e.restorable||f.isPending,title:m,onClick:()=>i(!0),children:S9(e.restorable?e.winner:null)}),(0,z.jsx)(V,{size:s?`default`:`sm`,variant:`ghost`,disabled:!o||p.isPending,title:o?void 0:yt(),onClick:()=>p.mutate(),children:ku()})]}),s&&m&&(0,z.jsx)(`p`,{className:`mt-1 text-[12px] text-muted-foreground`,children:m}),t&&u.data&&(0,z.jsx)(`div`,{className:`mt-2`,children:(0,z.jsx)(C9,{entry:e,detail:u.data,keyCol:l})}),r&&(0,z.jsx)(qk,{open:!0,onOpenChange:e=>!e&&i(!1),children:(0,z.jsxs)(Qk,{children:[(0,z.jsx)($k,{children:(0,z.jsx)(nA,{children:Gu({table:e.table,key:e.key??``})})}),u.data?(0,z.jsx)(C9,{entry:e,detail:u.data,keyCol:l}):(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:u.error?u.error.message:bt()}),(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:Hu()}),(0,z.jsxs)(tA,{children:[(0,z.jsx)(V,{variant:`outline`,onClick:()=>i(!1),children:gt()}),(0,z.jsx)(V,{disabled:!u.data||f.isPending,onClick:()=>u.data&&f.mutate(u.data.current),children:S9(e.winner)})]})]})})]})}function w9({title:e,count:t,tone:n,children:r}){return(0,z.jsxs)(`div`,{className:`mb-3.5 overflow-hidden rounded-[10px] border`,children:[(0,z.jsxs)(`h3`,{className:`flex items-center gap-2 border-b bg-panel px-3.5 py-2.5 text-[13px] font-semibold`,children:[t!==void 0&&t>0&&(0,z.jsx)(`span`,{className:`rounded-full px-1.5 text-[10.5px] ${n===`err`?`bg-err-soft text-err`:`bg-warn-soft text-warn`}`,children:t}),e]}),r]})}function iue(){let e=iy(),{activity:t,warnings:n,connected:r,lastSyncAt:i}=ay(),{data:a}=V_({queryKey:[`conflicts`],queryFn:Uv.conflicts});(0,B.useEffect)(()=>e.markConflictsSeen(),[e]);let o=a?.conflicts??[],{data:s}=ry(),c=u7(n,new Set(s?.views.map(e=>e.name))),l=$se(t);return(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 border-b px-[18px] py-3 max-md:px-3`,children:[(0,z.jsx)(`h1`,{className:`max-md:sr-only text-lg font-semibold tracking-tight`,children:Ai()}),(0,z.jsxs)(`span`,{className:`text-[12px] text-muted-foreground`,children:[r?Zu():lu(),i&&Iu({at:D5(i)})]})]}),(0,z.jsxs)(`div`,{className:`overflow-auto px-[18px] py-3.5 max-md:px-3`,children:[(0,z.jsx)(w9,{title:Du(),count:o.length,tone:`err`,children:o.length===0?(0,z.jsx)(`p`,{className:`px-3.5 py-2.5 text-[12px] text-muted-foreground`,children:Ru()}):o.map(e=>(0,z.jsx)(rue,{entry:e},e.id))}),(0,z.jsx)(w9,{title:Xu(),count:c.length,tone:`warn`,children:c.length===0?(0,z.jsx)(`p`,{className:`px-3.5 py-2.5 text-[12px] text-muted-foreground`,children:Bu()}):c.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-3.5 py-2 text-[12px] last:border-b-0 max-md:text-[13px]`,children:[(0,z.jsxs)(`span`,{className:`font-semibold`,children:[e.table,e.key&&` / ${e.key}`,e.view&&` / ${e.view}`]}),(0,z.jsx)(`span`,{className:`flex-1 text-muted-foreground max-md:order-last max-md:basis-full`,children:e.text}),e.key&&(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.table},search:{key:e.key},className:`text-tomato max-md:py-1.5`,children:Vu()}),e.view&&(0,z.jsx)(Yh,{to:`/t/$table`,params:{table:e.view},className:`text-tomato max-md:py-1.5`,children:Vu()})]},`${t}-${e.text}`))}),(0,z.jsx)(w9,{title:Tu(),children:l.length===0?(0,z.jsx)(`p`,{className:`px-3.5 py-2.5 text-[12px] text-muted-foreground`,children:Lu()}):l.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 border-b px-3.5 py-2 text-[12px] last:border-b-0 max-md:text-[13px]`,children:[(0,z.jsx)(`span`,{className:`w-3 font-mono font-bold ${tue[e.tone]}`,children:e.symbol}),(0,z.jsx)(`span`,{className:`font-semibold`,children:e.text}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[D5(e.at),` · `,e.detail]})]},`${t}-${e.at}-${e.text}`))})]})]})}var T9=e=>`yamlite-grid:${e}`;function aue(e){try{let t=JSON.parse(localStorage.getItem(T9(e))??`{}`);return{widths:Object.fromEntries(Object.entries(t.widths??{}).filter(([,e])=>typeof e==`number`&&Number.isFinite(e))),unpinned:t.unpinned===!0}}catch{return{widths:{},unpinned:!1}}}function oue(e){let[t,n]=(0,B.useState)(()=>aue(e)),r=t=>{n(t);try{localStorage.setItem(T9(e),JSON.stringify(t))}catch{}};return{...t,setWidth:(e,n)=>{let{[e]:i,...a}=t.widths;r({...t,widths:n===null?a:{...a,[e]:Math.max(60,Math.round(n))}})},togglePin:()=>r({...t,unpinned:!t.unpinned})}}var E9=e=>()=>e,D9=[[`eq`,E9(`=`)],[`ne`,E9(`≠`)],[`lt`,E9(`<`)],[`lte`,E9(`≤`)],[`gt`,E9(`>`)],[`gte`,E9(`≥`)],[`contains`,bn],[`has`,xn],[`null`,Cn],[`notnull`,Sn]],O9=e=>`${e.col} ${D9.find(([t])=>t===e.op)?.[1]()??e.op}${e.value===void 0?``:` ${JSON.stringify(e.value)}`}`;function sue(e,t){return t===`BOOLEAN`?e===`true`:(t===`INTEGER`||t===`REAL`)&&e.trim()!==``&&!Number.isNaN(Number(e))?t===`INTEGER`&&!Number.isSafeInteger(Number(e))?e:Number(e):e}function cue({columns:e,filters:t,search:n,onChange:r}){let i=Object.keys(e),[a,o]=(0,B.useState)({col:i[0]??``,op:`eq`,text:``}),[s,c]=(0,B.useState)(n??``),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>c(n??``),[n]),(0,B.useEffect)(()=>{let e=setTimeout(()=>{(n??``)!==s&&r({filters:t,search:s||void 0})},300);return()=>clearTimeout(e)},[s,n,t,r]);let d=()=>{let i=a.op!==`null`&&a.op!==`notnull`,o=i?sue(a.text,(Object.hasOwn(e,a.col)?e[a.col]:void 0)??`TEXT`):void 0;r({filters:[...t,{col:a.col,op:a.op,...i?{value:o}:{}}],search:n}),u(!1)};return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b px-[18px] py-2 max-md:px-3`,children:[(0,z.jsxs)(`div`,{className:`relative w-full max-w-[280px] max-md:max-w-none max-md:basis-full`,children:[(0,z.jsx)(dk,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,z.jsx)(Ik,{type:`search`,"aria-label":Tn(),placeholder:En(),className:`h-7 pl-7 text-[12px] max-md:h-9`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Escape`&&c(``)})]}),t.map((e,i)=>(0,z.jsxs)(`button`,{type:`button`,className:`rounded-full border border-tomato bg-tomato-soft px-2 py-0.5 text-[11.5px] text-tomato max-md:min-h-8 max-md:px-3 max-md:text-[13px]`,onClick:()=>r({filters:t.filter((e,t)=>t!==i),search:n}),children:[O9(e),` ×`]},`${i}-${O9(e)}`)),(0,z.jsxs)(Lk,{open:l,onOpenChange:u,children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,className:`rounded-full border border-dashed px-2 py-0.5 text-[11.5px] text-muted-foreground max-md:min-h-8 max-md:px-3 max-md:text-[13px]`,children:vn()})}),(0,z.jsxs)(zk,{className:`flex w-[min(20rem,calc(100vw-2rem))] flex-col gap-2`,children:[(0,z.jsx)(`select`,{"aria-label":yn(),className:`rounded border bg-background px-2 py-1 max-md:py-2`,value:a.col,onChange:e=>o({...a,col:e.target.value}),children:i.map(e=>(0,z.jsx)(`option`,{children:e},e))}),(0,z.jsx)(`select`,{"aria-label":wn(),className:`rounded border bg-background px-2 py-1 max-md:py-2`,value:a.op,onChange:e=>o({...a,op:e.target.value}),children:D9.map(([e,t])=>(0,z.jsx)(`option`,{value:e,children:t()},e))}),a.op!==`null`&&a.op!==`notnull`&&(0,z.jsx)(Ik,{"aria-label":Dn(),value:a.text,onChange:e=>o({...a,text:e.target.value}),onKeyDown:e=>e.key===`Enter`&&d()}),(0,z.jsx)(V,{size:`sm`,onClick:d,children:_n()})]})]})]})}var lue=O(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function uue({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?_:`span`;return(0,z.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:T(lue({variant:t}),e),...r})}function k9({title:e,heading:t,actions:n,flush:r=!1,children:i}){return(0,z.jsxs)(`section`,{"data-slot":`section-card`,className:`overflow-hidden rounded-lg border`,children:[(0,z.jsxs)(`header`,{className:`flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b bg-muted px-4 py-1.5`,children:[(0,z.jsx)(`h3`,{className:iA,children:e}),t,n&&(0,z.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),(0,z.jsx)(`div`,{className:T(!r&&`flex flex-col gap-2 px-4 py-3`),children:i})]})}function due(e){return{required:[...e.required],values:{...e.values},formats:{...e.formats},min:{...e.min},max:{...e.max},references:Object.fromEntries(e.references.map(e=>[e.column,e.target?`${e.table}.${e.target}`:e.table]))}}var A9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function fue(e,t){return e!==void 0&&t!==void 0?`${e} – ${t}`:e===void 0?t===void 0?null:`≤ ${t}`:`≥ ${e}`}function pue(e,t){let n=[];e.required.includes(t)&&n.push(`required`);let r=A9(e.values,t);r&&n.push(`values ${r.length}`);let i=A9(e.formats,t);i&&n.push(i);let a=fue(A9(e.min,t),A9(e.max,t));a&&n.push(a);let o=A9(e.references,t);return o&&n.push(`→ ${o}`),n}var mue=/^\w+__\w+: /;function hue(e,t,n){return t.filter(t=>{let r=t;if(n){let e=`${n}: `;if(!t.startsWith(e))return!1;r=t.slice(e.length)}else if(mue.test(t))return!1;return r.startsWith(`${e} `)||r.startsWith(`references.${e}:`)})}var j9=(e,t)=>e===`INTEGER`||e===`REAL`?`number`:t===`date`||t===`datetime`?t:null,gue=e=>e.columns?{columns:[...e.columns],unique:e.unique}:{expr:e.expr??``,unique:e.unique},M9=e=>`${e.unique?`unique `:``}(${`columns`in e?e.columns.join(`, `):e.expr})`,N9=e=>JSON.stringify([`columns`in e?e.columns:null,`expr`in e?e.expr:null,e.unique]),_ue=(e,t)=>P9(e.map(N9),t.map(N9)),P9=(e,t)=>{let n=new Set(e);return n.size===new Set(t).size&&t.every(e=>n.has(e))},F9=(e,t)=>JSON.stringify([e.required.includes(t),A9(e.values,t)??null,A9(e.formats,t)??null,A9(e.min,t)??null,A9(e.max,t)??null,A9(e.references,t)??null]);function vue({indexes:e,known:t,columns:n,onChange:r}){let[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),f=new Map(t.map(e=>[e.definition,e.inDb])),p=n.filter(e=>!o.includes(e)),m=()=>{a(!1),s([]),l(``),d(!1)};return(0,z.jsxs)(k9,{title:Zc(),actions:!i&&(0,z.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(!0),children:`+ ${Ns()}`}),children:[e.length===0&&!i&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:el()}),e.length>0&&(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(t=>{let n=M9(t),i=f.get(n);return(0,z.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border px-3 py-1.5`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:n}),i!==void 0&&(0,z.jsx)(`span`,{className:`ml-auto text-[12px] ${i?`text-ok`:`text-warn`}`,children:i?Wc():tl()}),(0,z.jsx)(`button`,{type:`button`,"aria-label":_c({index:n}),className:`px-1 text-[15px] text-muted-foreground hover:text-foreground ${i===void 0?`ml-auto`:``}`,onClick:()=>r(e.filter(e=>M9(e)!==n)),children:`×`})]},n)})}),i&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border px-3 py-2`,children:[o.length>0&&(0,z.jsx)(`ol`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,z.jsxs)(`li`,{className:`inline-flex items-center rounded-full bg-chip py-0.5 pr-1 pl-2.5 text-[13px] text-chip-foreground`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`button`,{type:`button`,"aria-label":mc({column:e}),className:`ml-1 px-1 opacity-60 hover:opacity-100`,onClick:()=>s(o.filter(t=>t!==e)),children:`×`})]},e))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`select`,{"aria-label":$s(),className:`h-9 rounded-md border bg-background px-2 text-base md:text-sm w-56 max-md:w-full font-mono`,value:c,onChange:e=>l(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`—`}),p.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsx)(V,{type:`button`,variant:`outline`,disabled:c===``,onClick:()=>{s([...o,c]),l(``)},children:Ms()}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":Ic(),className:`size-4`,checked:u,onChange:e=>d(e.target.checked)}),(0,z.jsx)(`span`,{children:Ic()})]})]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(V,{type:`button`,variant:`ghost`,onClick:m,children:Us()}),(0,z.jsx)(V,{type:`button`,disabled:o.length===0,onClick:()=>{let t={columns:o,unique:u},n=M9(t);e.some(e=>M9(e)===n)||r([...e,t]),m()},children:Ns()})]})]})]})}var yue={TEXT:[`date`,`datetime`,`markdown`],JSON:[`list`,`map`]},I9=[`markdown`,`list`,`map`],L9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function R9(e,t){let n=t.trim();if(n!==``){if(e===`INTEGER`||e===`REAL`){let e=Number(n);return Number.isFinite(e)?e:void 0}return e===`BOOLEAN`?n===`true`||n!==`false`&&void 0:n}}function z9({title:e,children:t,hints:n=[]}){return(0,z.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`h4`,{className:aA,children:e}),t,(0,z.jsx)(B9,{hints:n})]})}function B9({hints:e}){return e.length===0?null:(0,z.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-[12.5px] text-warn`,children:e.map(e=>(0,z.jsx)(`li`,{children:e},e))})}function bue(e,t){return t.includes(`references.${e}: `)||/ not found in \S+ \(/.test(t)?`references`:t.includes(`${e} missing (`)?`required`:t.includes(` not in values (`)?`values`:`other`}function xue({column:e,type:t,draft:n,tables:r,hints:i,set:a,toggleRequired:o,onBack:s}){let c=L9(n.formats,e),l=L9(n.values,e)??[],u=j9(t,c),d=L9(n.references,e)??``,f=d.indexOf(`.`),p=f<0?d:d.slice(0,f),m=f<0?``:d.slice(f+1),h=t=>i.filter(n=>bue(e,n)===t),g=!I9.includes(c),_=yue[t],v=n=>{let r=[...new Set(n.map(e=>l.find(t=>String(t)===e)??R9(t,e)))];a(`values`,e,r.length===0?void 0:r)},y=n=>{a(`formats`,e,n),I9.includes(n)&&a(`values`,e,void 0),j9(t,n)!==u&&(a(`min`,e,void 0),a(`max`,e,void 0))},b=(t,n)=>{let r=n===``?void 0:u===`number`?Number(n):n;a(t,e,r!==void 0&&typeof r==`number`&&!Number.isFinite(r)?void 0:r)},x=(t,n)=>a(`references`,e,t===``?void 0:n.trim()===``?t:`${t}.${n.trim()}`);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-5 text-[13px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,z.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-2`,onClick:s,children:`‹ ${Rs()}`}),(0,z.jsx)(`h3`,{className:`font-mono text-[15px] font-semibold`,children:e})]}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:Fc({type:t})})]}),(0,z.jsx)(z9,{title:Ac(),hints:h(`required`),children:(0,z.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`input`,{type:`checkbox`,"aria-label":Ac(),className:`size-4`,checked:n.required.includes(e),onChange:t=>o(e,t.target.checked)}),(0,z.jsx)(`span`,{children:jc()})]})}),g&&(0,z.jsx)(z9,{title:Lc(),hints:h(`values`),children:(0,z.jsx)(BJ,{label:Lc(),value:l.map(String),onChange:v,placeholder:Rc(),removeLabel:e=>bc({value:e}),accept:e=>R9(t,e)!==void 0,unique:!0})}),_&&(0,z.jsx)(z9,{title:Ys(),children:(0,z.jsxs)(`select`,{"aria-label":Ys(),className:`h-9 rounded-md border bg-background px-2 text-base md:text-sm w-56 max-md:w-full`,value:c??``,onChange:e=>y(e.target.value===``?void 0:e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:cc()}),_.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})}),u&&(0,z.jsx)(`div`,{className:`flex flex-wrap gap-3 max-md:flex-col`,children:[`min`,`max`].map(t=>(0,z.jsx)(z9,{title:t===`min`?ac():ic(),children:(0,z.jsx)(Ik,{"aria-label":t===`min`?ac():ic(),type:u===`number`?`number`:u===`date`?`date`:`text`,className:`w-56 max-md:w-full`,value:String(L9(n[t],e)??``),onChange:e=>b(t,e.target.value)})},t))}),(0,z.jsx)(B9,{hints:g?h(`other`):[...h(`values`),...h(`other`)]}),(0,z.jsx)(z9,{title:lc(),hints:h(`references`),children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`select`,{"aria-label":lc(),className:`${oA} ${sA}`,value:p,onChange:e=>x(e.target.value,``),children:[(0,z.jsx)(`option`,{value:``,children:cc()}),r.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsx)(Ik,{"aria-label":uc(),placeholder:dc(),className:`${sA} font-mono`,disabled:p===``,value:m,onChange:e=>x(p,e.target.value)})]})})]})}function Sue({fields:e,names:t,json:n,onChange:r}){let i=n.filter(t=>!e.includes(t)),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),l=i.includes(s)?s:``,u=e=>Object.hasOwn(t,e)?t[e]:e,d=()=>{o(!1),c(``)},f=n=>{(!Object.hasOwn(t,n)||window.confirm(Ec({view:u(n)})))&&r(e.filter(e=>e!==n))};return(0,z.jsxs)(k9,{title:Yc(),actions:i.length>0&&!a&&(0,z.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!0),children:`+ ${Ps()}`}),children:[e.length>0&&(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border px-3 py-1.5`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:u(e)}),(0,z.jsx)(`button`,{type:`button`,"aria-label":Cc({view:u(e)}),className:`px-1 text-[15px] text-muted-foreground hover:text-foreground ml-auto`,onClick:()=>f(e),children:`×`})]},e))}),i.length===0?(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:sc()}):a?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border px-3 py-2`,children:[(0,z.jsxs)(`select`,{"aria-label":zc(),className:`${oA} ${sA} font-mono`,value:l,onChange:e=>c(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`—`}),i.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]}),(0,z.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,z.jsx)(V,{type:`button`,variant:`ghost`,onClick:d,children:Us()}),(0,z.jsx)(V,{type:`button`,disabled:l===``,onClick:()=>{r([...e,l]),d()},children:Ps()})]})]}):e.length===0&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:el()})]})}var V9=e=>e instanceof Sv&&e.status===409&&`current`in e.body,H9=e=>e instanceof Error?e.message:String(e);function Cue(e){let t=Sg(),{data:n}=ry(),r=kX(),i=Object.keys(e.columns),[a,o]=(0,B.useState)(()=>r?null:i.find(t=>!e.fixed.includes(t))??null),[s]=(0,B.useState)(e.base),c=e.views.filter(t=>t.path.length===e.target.path.length+1),[l]=(0,B.useState)(()=>({rules:e.initial,indexes:(e.indexes??[]).map(gue),views:c.map(e=>e.path.at(-1))})),[u,d]=(0,B.useState)(l),f=u.rules,p=e=>d(t=>({...t,rules:e(t.rules)})),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(!1),S=O$(u,300),C=t=>({...e.indexes!==void 0&&!_ue(t.indexes,l.indexes)?{indexes:t.indexes}:{},...P9(t.views,l.views)?{}:{views:t.views}}),w=JSON.stringify(u.rules)!==JSON.stringify(l.rules)||Object.keys(C(u)).length>0,T=e=>{(!w||window.confirm(Ks()))&&e()},E=t=>T(()=>e.onOpenView(t)),D=e.views.filter(t=>u.views.includes(t.path[e.target.path.length]));(0,B.useEffect)(()=>{let t=!0;return Uv.previewRules(e.target,S.rules,s,C(S)).then(e=>{t&&(h(e),_(S),y(null))},e=>{t&&(V9(e)?x(!0):y(H9(e)))}),()=>{t=!1}},[S,s,e.target]);let O=()=>{t.invalidateQueries({queryKey:[`schema`]}),t.invalidateQueries({queryKey:[`meta`]}),t.invalidateQueries({queryKey:[`git`]}),t.invalidateQueries({queryKey:[`gitdiff`]})},k=H_({mutationFn:()=>Uv.saveRules(e.target,u.rules,s,C(u)),onSuccess:()=>{O(),e.onDone()},onError:e=>V9(e)?x(!0):y(H9(e))}),A=(e,t,n)=>p(r=>{let i={...r[e]};return n===void 0?delete i[t]:i[t]=n,{...r,[e]:i}}),j=(e,t)=>p(n=>({...n,required:t?[...n.required.filter(t=>t!==e),e]:n.required.filter(t=>t!==e)})),M=()=>{window.confirm(Ks())&&(O(),e.onDone())},N=m?.added??[],P=m?.removed??[],F=[...(m?.indexes?.added??[]).map(e=>Qs({index:e})),...(m?.indexes?.removed??[]).map(e=>nc({index:e}))],ee=a===null?void 0:e.columns[a],I=(0,z.jsxs)(`nav`,{className:`flex flex-col gap-1`,children:[i.map(t=>{let n=e.fixed.includes(t),r=pue(f,t),i=!n&&F9(f,t)!==F9(l.rules,t),s=a===t;return(0,z.jsxs)(`button`,{type:`button`,disabled:n,"aria-current":s||void 0,onClick:()=>o(t),className:`flex flex-col items-start gap-0.5 rounded-md px-3 py-2 text-left disabled:cursor-default ${s?`bg-accent`:`hover:bg-background disabled:hover:bg-transparent`}`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[13px] ${s?`font-semibold`:``}`,children:t}),(n||r.length>0||i)&&(0,z.jsxs)(`span`,{className:`text-[12px] text-muted-foreground`,children:[n?Js():r.join(` · `),i&&(0,z.jsx)(`span`,{className:`text-tomato`,children:`${r.length>0?` · `:``}${Ws()}`})]})]},t)}),D.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>E(e.name),className:`rounded-md px-3 py-2 text-left font-mono text-[13px] hover:bg-background`,children:`${e.name} ▸`},e.name))]}),te=a!==null&&ee!==void 0&&(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,z.jsx)(xue,{column:a,type:ee,draft:f,tables:(n?.tables??[]).map(e=>e.name),hints:hue(a,N,e.viewName),set:A,toggleRequired:j,onBack:r?()=>o(null):void 0},a)}),ne=(0,z.jsxs)(`footer`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-[13px] ${e.footer===void 0?`border-t pt-3`:Zk}`,children:[b&&(0,z.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-3 text-warn`,children:[(0,z.jsx)(`span`,{children:Gs()}),(0,z.jsx)(V,{type:`button`,variant:`outline`,onClick:M,children:rc()})]}),m&&(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N.length>0&&(0,z.jsx)(`p`,{className:`text-warn`,children:Ls({count:N.length})}),P.length>0&&(0,z.jsx)(`p`,{className:`text-ok`,children:kc({count:P.length})}),F.map(e=>(0,z.jsx)(`p`,{className:`font-mono`,children:e},e)),!m.changed&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:oc()}),N.length>0&&(0,z.jsx)(`ul`,{className:`max-h-24 list-disc overflow-y-auto pl-5 text-[12.5px] text-muted-foreground`,children:N.slice(0,5).map(e=>(0,z.jsx)(`li`,{children:e},e))})]}),v!==null&&(0,z.jsx)(`p`,{className:`w-full text-err`,children:v}),(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 justify-end gap-2`,children:[(0,z.jsx)(V,{type:`button`,variant:`outline`,onClick:e.onDone,children:Us()}),(0,z.jsx)(V,{type:`button`,disabled:!m?.changed||g!==u||v!==null||b||k.isPending,onClick:()=>k.mutate(),children:Mc()})]})]}),re=e.trail&&e.trail.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground`,children:`·`}),(0,z.jsxs)(`nav`,{"aria-label":Hs(),className:`flex flex-wrap items-center gap-x-1 gap-y-1 font-mono`,children:[e.trail.map(e=>(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":Vs({name:e.label}),className:`rounded-md px-1.5 py-0.5 text-muted-foreground underline-offset-2 hover:bg-background hover:text-foreground hover:underline`,onClick:()=>T(e.onOpen),children:e.label}),(0,z.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground`,children:`›`})]},e.label)),(0,z.jsx)(`span`,{className:`px-1.5 font-semibold`,title:e.viewName,children:e.here})]})]}),ie=(0,z.jsx)(`div`,{className:`bg-muted p-2`,children:I}),ae=te&&(0,z.jsx)(`div`,{className:`px-4 py-4`,children:te});return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[13px]`,children:[(0,z.jsx)(k9,{title:Uc(),heading:re,flush:!0,children:r?ae||ie:(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,14rem)_minmax(0,1fr)]`,children:[(0,z.jsx)(`div`,{className:`border-r bg-muted p-2`,children:I}),ae||(0,z.jsx)(`div`,{})]})}),e.indexes!==void 0&&(0,z.jsx)(vue,{indexes:u.indexes,known:e.indexes,columns:i,onChange:e=>d(t=>({...t,indexes:e}))}),(0,z.jsx)(Sue,{fields:u.views,names:Object.fromEntries(c.map(e=>[e.path.at(-1),e.name])),json:i.filter(t=>e.columns[t]===`JSON`),onChange:e=>d(t=>({...t,views:e}))}),e.footer===void 0?ne:e.footer&&(0,W_.createPortal)(ne,e.footer)]})}var U9=(e,t)=>e!==void 0&&t!==void 0?`${e} – ${t}`:e===void 0?t===void 0?null:`≤ ${t}`:`≥ ${e}`,W9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,G9=`border-b px-2 py-1.5 text-left align-top`,K9=`w-full [&_tr:last-child>td]:border-b-0`,q9=()=>(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:el()}),J9=e=>({target:{table:e.table,path:e.path},viewName:e.name});function wue({editing:e,meta:t,schema:n,onEdit:r,onDone:i,footer:a}){let o=e.viewName===void 0?void 0:t.views.find(t=>t.name===e.viewName),s=t.tables.find(t=>t.name===e.target.table),c=o??s;if(!c||n.base===void 0)return null;let l=e.target.path.length,u=[{label:e.target.table,onOpen:()=>r({target:{table:e.target.table,path:[]}})},...e.target.path.slice(0,-1).flatMap((n,i)=>{let a=t.views.find(t=>t.table===e.target.table&&t.path.length===i+1&&t.path.every((t,n)=>e.target.path[n]===t));return a?[{label:n,onOpen:()=>r(J9(a))}]:[]})],d=t.views.filter(t=>t.table===e.target.table&&t.path.length>l&&e.target.path.every((e,n)=>t.path[n]===e));return(0,z.jsx)(Cue,{target:e.target,viewName:e.viewName,columns:o?o.columns:n.columns,fixed:o?o.identity:[n.key],initial:due(c),base:n.base,indexes:o?void 0:n.indexes,views:d.map(e=>({name:e.name,path:e.path})),trail:l>0?u:void 0,here:e.target.path.at(-1),onOpenView:e=>{let n=t.views.find(t=>t.name===e);n&&r(J9(n))},onDone:i,footer:a},`${e.target.table}/${e.target.path.join(`.`)}`)}function Y9({view:e,editor:t}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[12.5px]`,children:[(0,z.jsx)(k9,{title:hl(),children:(0,z.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:il()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:e.parent}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Xc()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:e.identity.length>0?e.identity.join(`, `):`—`}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Gc()}),(0,z.jsx)(`dd`,{children:e.inDb?_l():rl()})]})}),t??(0,z.jsx)(k9,{title:Uc(),children:(0,z.jsx)(`div`,{className:`-mx-2 overflow-x-auto`,children:(0,z.jsx)(`table`,{className:K9,children:(0,z.jsx)(`tbody`,{children:Object.entries(e.columns).map(([t,n])=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${G9} font-mono`,children:t}),(0,z.jsx)(`td`,{className:`${G9} font-mono text-muted-foreground`,children:n}),(0,z.jsx)(`td`,{className:`${G9} text-muted-foreground`,children:e.identity.includes(t)?Xc():[Object.hasOwn(e.declared,t)?Kc():Qc(),...e.required.includes(t)?[sl()]:[],...W9(e.formats,t)?[W9(e.formats,t)]:[],...(()=>{let n=U9(W9(e.min,t),W9(e.max,t));return n?[n]:[]})()].join(` · `)}),(0,z.jsx)(`td`,{className:`${G9} font-mono text-muted-foreground`,children:Object.hasOwn(e.values,t)?e.values[t]?.map(String).join(`, `):``})]},t))})})})})]})}function Tue({table:e,view:t,path:n,open:r,onOpenChange:i}){let[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),{data:l}=ry(),u=t?.table??e,{data:d,error:f}=V_({queryKey:[`schema`,u],queryFn:()=>Uv.schema(u),enabled:r&&(!t||a!==null)}),p=t!==void 0&&(a===null||a.viewName!==void 0),m=!Yv()&&l!==void 0&&!l.configError&&(t!==void 0||d!==void 0),h=a&&l&&d?(0,z.jsx)(wue,{editing:a,meta:l,schema:d,onEdit:o,onDone:()=>o(null),footer:s}):null;return(0,z.jsx)(qk,{open:r,onOpenChange:i,children:(0,z.jsxs)(Qk,{pinned:!0,className:a?`sm:max-w-4xl`:`sm:max-w-2xl`,children:[(0,z.jsxs)($k,{pinned:!0,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 max-sm:justify-center`,children:[(0,z.jsx)(nA,{children:pl({table:e})}),a&&(0,z.jsx)(uue,{variant:`outline`,className:`border-tomato text-[12px] text-tomato`,children:Jc()})]}),(0,z.jsx)(rA,{children:a?qc():t?gl():ll()}),n&&!(a&&!p)&&(0,z.jsx)(`p`,{className:`font-mono text-[12px] break-all text-muted-foreground md:hidden`,children:n}),m&&!a&&(0,z.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,className:`self-start`,onClick:()=>o(t?J9(t):{target:{table:e,path:[]}}),children:qs()})]}),(0,z.jsx)(eA,{children:p?(0,z.jsx)(Y9,{view:t,editor:h??(a&&f?(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:f.message}):null)}):(0,z.jsxs)(z.Fragment,{children:[f&&(0,z.jsx)(`p`,{className:`text-[12px] text-err`,children:f.message}),d&&(0,z.jsxs)(`div`,{className:`flex flex-col gap-4 text-[12.5px]`,children:[(0,z.jsx)(k9,{title:cl(),children:(0,z.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:al()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:d.mode===`files`?d.files:d.path}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:$c()}),(0,z.jsx)(`dd`,{className:`font-mono`,children:d.key}),(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:Gc()}),(0,z.jsx)(`dd`,{children:d.inDb?ul():rl()})]})}),h??(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(k9,{title:Uc(),children:(0,z.jsx)(`div`,{className:`-mx-2 overflow-x-auto`,children:(0,z.jsx)(`table`,{className:K9,children:(0,z.jsx)(`tbody`,{children:Object.entries(d.columns).map(([e,t])=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${G9} font-mono`,children:e}),(0,z.jsx)(`td`,{className:`${G9} font-mono text-muted-foreground`,children:t}),(0,z.jsx)(`td`,{className:`${G9} text-muted-foreground`,children:e===d.key?$c():[e in d.declared?Kc():Qc(),...d.required.includes(e)?[sl()]:[],...W9(d.formats,e)?[W9(d.formats,e)]:[],...(()=>{let t=U9(W9(d.min,e),W9(d.max,e));return t?[t]:[]})()].join(` · `)}),(0,z.jsx)(`td`,{className:`${G9} font-mono text-muted-foreground`,children:Object.hasOwn(d.values,e)?d.values[e]?.map(String).join(`, `):``})]},e))})})})}),(0,z.jsx)(k9,{title:ol(),children:d.references.length===0?(0,z.jsx)(q9,{}):d.references.map(e=>(0,z.jsxs)(`div`,{className:`rounded-md border px-3 py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-mono`,children:[(0,z.jsx)(`span`,{children:e.column}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,z.jsx)(`span`,{children:`${e.table}.${e.target}`}),(0,z.jsx)(`span`,{className:`ml-auto font-sans text-[11px] ${e.problems.length>0?`text-warn`:`text-ok`}`,children:e.problems.length>0?Hc({count:e.problems.length}):`OK`})]}),e.problems.length>0&&(0,z.jsx)(`ul`,{className:`mt-1.5 list-disc pl-5 text-[11.5px] text-muted-foreground`,children:e.problems.map(e=>(0,z.jsx)(`li`,{children:e},e))})]},e.column))})]}),!h&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(k9,{title:Zc(),children:[d.indexes.length===0&&d.otherIndexes.length===0?(0,z.jsx)(q9,{}):(0,z.jsx)(`div`,{className:`-mx-2 overflow-x-auto`,children:(0,z.jsx)(`table`,{className:K9,children:(0,z.jsxs)(`tbody`,{children:[d.indexes.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${G9} font-mono`,children:e.definition}),(0,z.jsx)(`td`,{className:`${G9} font-mono text-[11px] text-muted-foreground`,children:e.name}),(0,z.jsx)(`td`,{className:`${G9} ${e.inDb?`text-ok`:`text-warn`}`,children:e.inDb?Wc():tl()})]},e.name)),d.otherIndexes.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`${G9} font-mono`,children:e}),(0,z.jsx)(`td`,{className:`${G9} text-[11px] text-muted-foreground`,colSpan:2,children:ml()})]},e))]})})}),d.indexes.some(e=>!e.inDb)&&(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:nl()})]}),(0,z.jsx)(k9,{title:Yc(),children:d.views.length===0?(0,z.jsx)(q9,{}):d.views.map(e=>(0,z.jsxs)(`div`,{className:`rounded-md border px-3 py-2`,style:{marginLeft:`${(e.depth-1)*16}px`},children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-mono`,children:[(0,z.jsx)(`a`,{href:`#/t/${encodeURIComponent(e.name)}`,className:`underline-offset-2 hover:underline`,onClick:()=>i(!1),children:e.name}),(0,z.jsx)(`span`,{className:`ml-auto font-sans text-[11px] ${e.inDb?`text-ok`:`text-warn`}`,children:e.inDb?Wc():tl()})]}),e.inDb&&(0,z.jsx)(`p`,{className:`mt-1 font-mono text-[11.5px] text-muted-foreground`,children:Object.keys(e.columns).join(`, `)}),e.problems.length>0&&(0,z.jsx)(`ul`,{className:`mt-1.5 list-disc pl-5 text-[11.5px] text-muted-foreground`,children:e.problems.map(e=>(0,z.jsx)(`li`,{children:e},e))})]},e.name))})]})]})]})}),(0,z.jsx)(`div`,{ref:c,className:`shrink-0 empty:hidden`})]})})}function Eue({items:e,onOpenRecord:t}){return e.length===0?null:(0,z.jsxs)(Lk,{children:[(0,z.jsx)(Rk,{asChild:!0,children:(0,z.jsxs)(V,{variant:`outline`,size:`sm`,className:`text-warn`,children:[(0,z.jsx)(kk,{className:`size-3.5`}),` `,Cd({count:e.length})]})}),(0,z.jsx)(zk,{align:`end`,className:`max-h-80 w-[min(440px,calc(100vw-2rem))] overflow-auto p-0`,children:(0,z.jsx)(`ul`,{"aria-label":bd(),className:`text-[12px] max-md:text-[13px]`,children:e.map((e,n)=>(0,z.jsxs)(`li`,{className:`border-b px-3 py-2 last:border-b-0`,children:[e.key!==null&&(0,z.jsx)(`button`,{type:`button`,className:`font-mono font-semibold text-tomato hover:underline`,onClick:()=>t(e.key),children:e.key}),e.view!==null&&(0,z.jsx)(`a`,{href:`#/t/${encodeURIComponent(e.view)}`,className:`font-mono font-semibold text-tomato hover:underline`,children:e.view}),(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:e.text})]},`${n}-${e.text}`))})})]})}var X9=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Due(e,t){return e.path.flatMap((n,r)=>{let i=t[e.identity[r+1]];return[n,typeof i==`number`?i:String(i)]})}function Z9(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&(typeof e==`number`||/^\d+$/.test(e)))n=n[Number(e)];else if(X9(n)&&typeof e==`string`&&Object.hasOwn(n,e))n=n[e];else return;return n}var Q9=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function Oue({view:e,rowKey:t,row:n,onClose:r,onOpenRecord:i}){let a=Sg(),o=oy(),{connected:s}=ay(),c=kX(),l=n?String(n[e.identity[0]]):void 0,{data:u,error:d}=V_({queryKey:[`record`,e.table,l],queryFn:()=>Uv.record(e.table,l),enabled:l!==void 0}),f=n?Due(e,n):[],p=u?Z9(u.row,f):void 0,m=p!==void 0&&!X9(p),h=Object.keys(e.columns).filter(t=>!e.identity.includes(t)),g=p===void 0?void 0:m?{value:p}:Object.fromEntries(h.map(e=>[e,Q9(p,e)??null])),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(new Set),[C,w]=(0,B.useState)(0),T=_!==null&&y!==null&&IJ(_,y).length>0,E=s&&!Yv()&&p!==void 0,D=g?JSON.stringify(g):void 0;(0,B.useEffect)(()=>{g&&!T&&(v(g),b(g),S(new Set),w(e=>e+1))},[D,T]);let O=H_({mutationFn:({detail:t,values:n})=>{let r=e.path[0],i=Z9(t.row,f),a=m?n.value:Object.fromEntries(Object.entries({...i,...n}).filter(([,e])=>e!=null)),o=RJ(t.row,f,a);return Uv.update(e.table,l,{[r]:o[r]},{[r]:t.row[r]})},onMutate:()=>o({type:`saved`,table:e.table,key:l,at:Date.now()}),onSuccess:()=>{v(y),a.invalidateQueries({queryKey:[`record`,e.table,l]})},onError:t=>{o({type:`cancelled`,table:e.table,key:l}),t instanceof Sv&&t.status===409&&a.invalidateQueries({queryKey:[`record`,e.table,l]})}}),k=()=>{if(!u||!_||!y||!T||x.size>0||!E||O.isPending)return;let e=Object.fromEntries(IJ(_,y).map(e=>[e,y[e]??null]));O.mutate({detail:u,values:e})};eQ(r,!T),(0,B.useEffect)(()=>{let e=e=>{e.key===`s`&&(e.metaKey||e.ctrlKey)&&!Yv()&&(e.preventDefault(),k())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)});let A=m?[`value`]:h,j=_&&y?IJ(_,y).length:0,M=n===void 0||u!==void 0&&p===void 0;return(0,z.jsxs)(eZ,{...QZ,resizeLabel:$a(),"aria-label":jd(),children:[(0,z.jsxs)(tZ,{onClose:r,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono font-bold`,title:t,children:t}),(0,z.jsxs)(V,{variant:`ghost`,size:`sm`,disabled:!n,onClick:i,children:[(0,z.jsx)(rO,{className:`size-3.5`}),` `,Fd({table:e.table})]})]}),(0,z.jsx)(`div`,{className:`truncate px-4 pt-3 font-mono text-[13px] text-muted-foreground`,children:u?`${u.file} › ${f.join(`.`)}`:ad({parent:e.parent})}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:[d&&(0,z.jsx)(`p`,{className:`mb-2 text-[11.5px] text-err`,children:d.message}),M&&(0,z.jsx)(`p`,{className:`mb-2 text-[11.5px] text-err`,children:Md()}),!s&&(0,z.jsx)(`p`,{className:`mb-2 text-[11.5px] text-err`,children:Ia()}),n&&e.identity.length>0&&(0,z.jsx)(`dl`,{className:`mb-3.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[12px] max-md:text-[13px]`,children:e.identity.map(e=>(0,z.jsxs)(`div`,{className:`contents`,children:[(0,z.jsx)(`dt`,{className:`font-semibold text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`truncate font-mono`,children:String(n[e]??``)})]},e))}),y&&(0,z.jsx)(`fieldset`,{disabled:!E,className:`m-0 min-w-0 border-0 p-0`,children:A.map(t=>{let n=e.references.find(e=>e.column===t),r=Q9(e.formats,t),i=Q9(e.columns,t),a=e.required.includes(t);return(0,z.jsx)(`div`,{className:`mb-3.5`,children:(0,z.jsx)(vY,{readOnly:!E,path:[t],label:(0,z.jsxs)(`div`,{className:`flex flex-1 justify-between text-[12px] font-semibold text-muted-foreground max-md:text-[13px]`,children:[(0,z.jsxs)(`span`,{className:a&&y[t]==null?`text-warn`:void 0,children:[t,a&&(0,z.jsx)(`span`,{"aria-label":Qa(),children:` *`})]}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] font-medium max-md:text-[11.5px]`,children:n?`→ ${n.table}`:r??i})]}),value:y[t],type:i,format:r,allowed:Q9(e.values,t),min:Q9(e.min,t),max:Q9(e.max,t),reference:n,onChange:e=>b({...y,[t]:e}),onValidity:(e,t)=>S(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})},`${t}:${C}`)},t)})})]}),!Yv()&&(0,z.jsxs)(nZ,{className:`max-md:flex-wrap`,children:[(0,z.jsxs)(`span`,{className:`mr-auto flex min-w-0 flex-col text-[13px] text-muted-foreground max-md:basis-full`,children:[j>0?Da({count:j}):l===void 0?null:(0,z.jsx)(UX,{table:e.table,recordKey:l}),O.isError&&(0,z.jsx)(`span`,{className:`text-err`,children:O.error instanceof Sv&&O.error.status===409?Id():O.error.message})]}),(0,z.jsx)(V,{variant:`outline`,size:c?`lg`:`sm`,disabled:!T,onClick:()=>{_&&(b(_),S(new Set),w(e=>e+1))},children:Fa()}),(0,z.jsx)(V,{size:c?`lg`:`sm`,className:`max-md:flex-1`,disabled:!T||x.size>0||O.isPending||!E,title:s?void 0:yt(),onClick:k,children:c?St():ro()})]})]})}var kue=100;function Aue(e){try{return new Set(JSON.parse(localStorage.getItem(`yamlite-hidden:${e}`)??`[]`))}catch{return new Set}}function jue(e,t){try{localStorage.setItem(`yamlite-hidden:${e}`,JSON.stringify([...t]))}catch{}}function Mue({drawer:e,headerActions:t}){let{table:n}=A$.useParams(),r=A$.useSearch(),i=Nh({from:A$.fullPath}),a=Nh(),{data:o}=ry(),{warnings:s}=ay(),c=o?.tables.find(e=>e.name===n),l=c?void 0:o?.views.find(e=>e.name===n),u=r.filter??[],[d,f]=(0,B.useState)(()=>Aue(n)),[p,m]=(0,B.useState)(!1),h=oue(n),g=U_({queryKey:l?[`rows`,l.table,l.name,{sort:r.sort,filters:u,search:r.q}]:[`rows`,n,{sort:r.sort,filters:u,search:r.q}],queryFn:({pageParam:e})=>Uv.rows(n,{limit:kue,offset:e,sort:r.sort,filters:u,search:r.q}),initialPageParam:0,getNextPageParam:(e,t)=>{let n=t.reduce((e,t)=>e+t.rows.length,0);return n<e.total?n:void 0},enabled:c!==void 0||l!==void 0}),_=(0,B.useMemo)(()=>g.data?.pages.flatMap(e=>e.rows)??[],[g.data]),v=u1(),y=c?.name,b=(0,B.useMemo)(()=>y?i1(v,y):void 0,[v,y]),x=(0,B.useMemo)(()=>{if(!b)return _;let e=[...b.values()].filter(e=>e.op===`insert`&&e.after).map(e=>e.after);return e.length>0?[...e,..._]:_},[b,_]),S=g.data?.pages[0]?.total??0,{hasNextPage:C,isFetchingNextPage:w,isFetchNextPageError:T,fetchNextPage:E}=g,D=(0,B.useCallback)(()=>{C&&!w&&!T&&E()},[C,w,T,E]),O=(0,B.useCallback)(e=>void i({search:t=>({...t,...e})}),[i]),k=(0,B.useCallback)(e=>O({filter:e.filters.length>0?e.filters:void 0,q:e.search}),[O]);if(!c&&!l)return null;let A=c?c.columns:l.columns,j=c?c.key:l?.identity[0]??``,M=c?[c.key]:l?.identity??[],N=Object.entries(A).filter(([e])=>M.includes(e)||!d.has(e)).sort(([e],[t])=>Number(t===j)-Number(e===j)).map(([e,t])=>{let n=c??l,r=n.references.find(t=>t.column===e);return{name:e,type:t,format:Object.hasOwn(n.formats,e)?n.formats[e]:void 0,note:r?`→ ${r.table}`:void 0,reference:r}}),P=l?e=>l.identity.map(t=>String(e[t])).join(`/`):void 0,F=e=>O({key:e}),ee=l&&r.key!==void 0?x.find(e=>P?.(e)===r.key):void 0,I=c?c.name:l.table,te=u7({[I]:s[I]??[]},new Set(o?.views.map(e=>e.name))),ne=te.filter(e=>e.view===(l?l.name:null)),re=e=>void a({to:`/t/$table`,params:{table:l?l.table:n},search:{key:e}}),ie=e=>{let[t,n]=(r.sort??``).split(`:`),i=t===e?n===`asc`?`${e}:desc`:void 0:`${e}:asc`;O({sort:i})},ae=c?c.mode===`files`?c.files:c.path:`from ${l?.parent}`;return(0,z.jsxs)(`div`,{className:`relative flex min-w-0 flex-1`,children:[(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2.5 border-b px-[18px] py-3 max-md:gap-2 max-md:px-3 max-md:py-2`,children:[(0,z.jsx)(`h1`,{title:n,className:`min-w-0 truncate text-lg font-semibold tracking-tight max-md:sr-only`,children:n}),c?(0,z.jsx)(`span`,{className:`min-w-0 shrink-[100] truncate rounded bg-panel px-1.5 font-mono text-[11px] text-muted-foreground max-md:hidden`,children:c.mode===`files`?c.files:c.path}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`min-w-0 shrink-[100] truncate rounded bg-panel px-1.5 font-mono text-[11px] text-muted-foreground max-md:hidden`,children:ad({parent:l?.parent??``})}),(0,z.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 text-[11px] whitespace-nowrap text-muted-foreground`,children:nd()})]}),(0,z.jsx)(`span`,{className:`shrink-0 text-[12px] whitespace-nowrap text-muted-foreground`,children:c?md({count:S}):_d({count:S})}),(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2.5 max-md:ml-0 max-md:w-full max-md:shrink max-md:overflow-x-auto max-md:pb-0.5`,children:[(0,z.jsx)(Eue,{items:ne,onOpenRecord:re}),(0,z.jsxs)(V,{variant:`outline`,size:`sm`,onClick:()=>m(!0),children:[(0,z.jsx)(CO,{className:`size-3.5`}),` `,vd()]}),(0,z.jsxs)(S5,{children:[(0,z.jsx)(C5,{asChild:!0,children:(0,z.jsxs)(V,{variant:`outline`,size:`sm`,children:[(0,z.jsx)(xO,{className:`size-3.5`}),` `,td()]})}),(0,z.jsx)(w5,{children:Object.keys(A).filter(e=>!M.includes(e)).map(e=>(0,z.jsx)(qoe,{checked:!d.has(e),onCheckedChange:t=>{let r=new Set(d);t?r.delete(e):r.add(e),f(r),jue(n,r)},children:e},e))})]}),c&&t?.(c)]})]}),(0,z.jsx)(cue,{columns:A,filters:u,search:r.q,onChange:k}),g.isError&&(0,z.jsx)(`div`,{role:`alert`,className:`border-b px-[18px] py-2 text-err`,children:g.error.message}),(!g.isError||_.length>0)&&(0,z.jsx)(f9.Provider,{value:r.q?.trim()??``,children:(0,z.jsx)(x9,{columns:N,rows:x,preview:b,keyCol:j,rowId:P,selectedKey:r.key,onSelect:F,onEndReached:D,flagged:c?ece(te):void 0,sort:r.sort,onSort:ie,widths:h.widths,onResize:h.setWidth,pinned:!h.unpinned,onTogglePin:h.togglePin})})]}),c&&r.key!==void 0&&e?.(c,r.key),l&&r.key!==void 0&&(0,z.jsx)(Oue,{view:l,rowKey:r.key,row:ee,onClose:()=>O({key:void 0}),onOpenRecord:()=>ee&&re(String(ee[j]))},r.key),p&&(0,z.jsx)(Tue,{table:n,view:l,path:ae,open:!0,onOpenChange:m})]})}function Nue(){let{data:e}=ry(),t=e?.tables[0];return e?t?(0,z.jsx)(Ph,{to:`/t/$table`,params:{table:t.name}}):(0,z.jsx)(bY,{title:xt()}):null}function Pue({table:e}){let[t,n]=(0,B.useState)(!1),{connected:r}=ay(),i=kX(),{filter:a}=A$.useSearch(),o=sce(e,a??[]),s=cce(e,a??[]);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(V,{size:i?`lg`:`sm`,disabled:!r,title:r?void 0:yt(),className:i?`fixed right-4 bottom-[calc(56px+env(safe-area-inset-bottom))] z-30 rounded-full shadow-lg`:void 0,onClick:()=>n(!0),children:hi()}),(0,z.jsx)(yY,{table:e,open:t,onOpenChange:n,initial:o,initialKey:s},JSON.stringify([o,s]))]})}function Fue({table:e,recordKey:t}){let[n,r]=(0,B.useState)(!1),{connected:i}=ay();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,"aria-label":yi(),disabled:!i,className:`shrink-0 whitespace-nowrap text-[11px] text-muted-foreground hover:text-foreground disabled:opacity-50 max-md:px-2 max-md:py-2 max-md:text-[13px]`,onClick:()=>r(!0),children:vi()}),n&&(0,z.jsx)(nQ,{table:e,recordKey:t,open:!0,onOpenChange:r})]})}function Iue(){let{table:e}=A$.useParams();return(0,z.jsx)(Mue,{headerActions:Yv()?void 0:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Kk,{table:e}),(0,z.jsx)(Pue,{table:e})]}),drawer:(e,t)=>(0,z.jsx)(tQ,{table:e,recordKey:t,headerActions:Yv()?void 0:(0,z.jsx)(Fue,{table:e,recordKey:t})},`${e.name}:${t}`)},e)}var $9=ng(()=>rY(()=>import(`./PageView-BZ2TyXNJ.js`),__vite__mapDeps([3,1,2,4]),import.meta.url),`PageView`);function Lue(){let{page:e}=P$.useParams();return(0,z.jsx)($9,{name:e},e)}function Rue(){let{page:e}=F$.useParams();return(0,z.jsx)($9,{name:e,app:!0},e)}k$.update({component:wce}),A$.update({component:Iue}),j$.update({component:$le}),I$.update({component:R$}),P$.update({component:Lue}),F$.update({component:Rue}),M$.update({component:()=>Yv()?(0,z.jsx)(Ph,{to:`/`}):(0,z.jsx)(iue,{})}),N$.update({component:ng(()=>rY(()=>import(`./ErdView-C-Kg8blN.js`),__vite__mapDeps([5,1,2,6]),import.meta.url),`ErdView`)});var zue=Qh({getParentRoute:()=>k$,path:`/`,component:Nue}),Bue=k$.addChildren([zue,A$,j$,M$,N$,P$,F$,I$]);function Vue(e){return gg({routeTree:Bue,history:e===void 0?Tp():Ep({initialEntries:[`/app/${encodeURIComponent(e)}`]}),context:{app:e}})}function Hue(e,t={}){let n=Vue(t.app);document.documentElement.lang=E();let r=(0,Ld.createRoot)(e);return r.render((0,z.jsx)(B.StrictMode,{children:(0,z.jsx)(bee,{children:(0,z.jsx)(yg,{router:n})})})),()=>r.unmount()}async function Uue(){let e=document.getElementById(`root`);if(Gv())try{let{loadStatic:e}=await rY(async()=>{let{loadStatic:e}=await import(`./load-iZmRMple.js`);return{loadStatic:e}},__vite__mapDeps([7,1,4]),import.meta.url),{api:t,snapshot:n}=await e();Hv(t),Kv(n)}catch(t){document.documentElement.lang=E(),(0,Ld.createRoot)(e).render((0,z.jsx)(Rd,{error:t}));return}Hue(e,{app:ZJ(location.href,document.baseURI)})}Uue();export{aV as $,I_ as $t,wX as A,xA as At,rG as B,ay as Bt,h$ as C,XA as Ct,kX as D,gA as Dt,tQ as E,_A as Et,XJ as F,NO as Ft,HB as G,Rv as Gt,sG as H,Yv as Ht,qJ as I,tO as It,ZB as J,V_ as Jt,BB as K,Lv as Kt,wJ as L,H as Lt,bX as M,kk as Mt,bY as N,xk as Nt,SX as O,Hte as Ot,rY as P,sk as Pt,RB as Q,P_ as Qt,cJ as R,V as Rt,a$ as S,oj as St,QQ as T,pA as Tt,_K as U,Sv as Ut,oG as V,ry as Vt,UV as W,Uv as Wt,FV as X,z_ as Xt,GB as Y,L_ as Yt,sV as Z,R_ as Zt,b0 as _,fne as _t,tce as a,Zg as an,QB as at,v1 as b,aj as bt,Y3 as c,Ig as cn,UB as ct,C2 as d,Nh as dn,G as dt,F_ as en,nre as et,w2 as f,Sh as fn,tN as ft,w0 as g,hne as gt,s2 as h,xt as hn,lj as ht,K7 as i,t_ as in,rV as it,TX as j,Wte as jt,EX as k,LA as kt,k2 as l,Sg as ln,X as lt,d2 as m,pi as mn,SN as mt,ble as n,A_ as nn,lV as nt,x5 as o,Tg as on,LB as ot,E2 as p,Cd as pn,CM as pt,qne as q,iv as qt,_le as r,h_ as rn,cV as rt,j8 as s,Fg as sn,zB as st,v9 as t,N_ as tn,uV as tt,$ as u,Yh as un,qR as ut,D1 as v,dj as vt,$Q as w,bA as wt,m$ as x,ZA as xt,E1 as y,W as yt,Qq as z,iy as zt};
|