sqlrooms 0.1.0__py3-none-any.whl
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.
- sqlrooms/cli.py +576 -0
- sqlrooms/web/__init__.py +0 -0
- sqlrooms/web/db_bridge/__init__.py +28 -0
- sqlrooms/web/db_bridge/connectors/__init__.py +9 -0
- sqlrooms/web/db_bridge/connectors/base.py +59 -0
- sqlrooms/web/db_bridge/connectors/postgres.py +118 -0
- sqlrooms/web/db_bridge/connectors/snowflake.py +161 -0
- sqlrooms/web/db_bridge/factory.py +91 -0
- sqlrooms/web/db_bridge/registry.py +113 -0
- sqlrooms/web/db_bridge/types.py +29 -0
- sqlrooms/web/db_bridge/utils.py +45 -0
- sqlrooms/web/launcher.py +1215 -0
- sqlrooms/web/static/assets/AiSlice-x2gVCmwI.js +137 -0
- sqlrooms/web/static/assets/CommandSlice-DPSuuiIV.js +23 -0
- sqlrooms/web/static/assets/DockLayout-DhgcIQET.js +1 -0
- sqlrooms/web/static/assets/GridLayout-CBVgs-6H.css +1 -0
- sqlrooms/web/static/assets/GridLayout-fXJZYHbE.js +253 -0
- sqlrooms/web/static/assets/LayoutRendererContext-BKO2wB-W.js +1 -0
- sqlrooms/web/static/assets/LeafLayout-DPFHUP6B.js +1 -0
- sqlrooms/web/static/assets/LeafLayout-ekhNDEEg.js +1 -0
- sqlrooms/web/static/assets/RenderNodeContext-BdrX8FaE.js +1 -0
- sqlrooms/web/static/assets/RendererSwitcher-DnVbhqg4.js +1 -0
- sqlrooms/web/static/assets/SplitLayout-fPLAPJN-.js +1 -0
- sqlrooms/web/static/assets/TabsLayout-C0N-7wmx.js +1 -0
- sqlrooms/web/static/assets/TabsLayout-T3iApyr5.js +41 -0
- sqlrooms/web/static/assets/chunk-jRWAZmH_.js +1 -0
- sqlrooms/web/static/assets/codicon-ngg6Pgfi.ttf +0 -0
- sqlrooms/web/static/assets/core.esm-DdCldPzV.js +5 -0
- sqlrooms/web/static/assets/css.worker-Wv5dxAWO.js +89 -0
- sqlrooms/web/static/assets/devtools-BNUn8Jb2.js +2 -0
- sqlrooms/web/static/assets/dist-dwKeDPoe.js +1 -0
- sqlrooms/web/static/assets/html.worker-CQP8QQsS.js +502 -0
- sqlrooms/web/static/assets/index-D9UP9D4f.js +316286 -0
- sqlrooms/web/static/assets/index-DioDnqnf.css +1 -0
- sqlrooms/web/static/assets/json.worker-DzV-CpCQ.js +58 -0
- sqlrooms/web/static/assets/loro_wasm_bg-DP4dC0x3.wasm +0 -0
- sqlrooms/web/static/assets/loro_wasm_bg-VQ4j4Qa9.js +9 -0
- sqlrooms/web/static/assets/loro_wasm_bg-oL0xMWtE.js +3630 -0
- sqlrooms/web/static/assets/maplibre-gl-C-a91wbz.js +748 -0
- sqlrooms/web/static/assets/node-sql-parser-ChfKIXD7.js +68 -0
- sqlrooms/web/static/assets/prop-types-DybOnnvg.js +1 -0
- sqlrooms/web/static/assets/react-dom-liMHu8hH.js +1 -0
- sqlrooms/web/static/assets/resizable-DYr7VLR3.js +1 -0
- sqlrooms/web/static/assets/scroll-area-ZmzNHGEm.js +1 -0
- sqlrooms/web/static/assets/tooltip-mgpsA9tW.js +1 -0
- sqlrooms/web/static/assets/ts.worker-Dth06zuC.js +67734 -0
- sqlrooms/web/static/assets/utils-yJ4l7ARz.js +1 -0
- sqlrooms/web/static/assets/webgl-device-CgQl7NRd.js +1 -0
- sqlrooms/web/static/assets/webgl-device-CtgDFnYR.js +13 -0
- sqlrooms/web/static/index.html +32 -0
- sqlrooms/web/static/logo.png +0 -0
- sqlrooms/web/ui.py +37 -0
- sqlrooms-0.1.0.dist-info/METADATA +274 -0
- sqlrooms-0.1.0.dist-info/RECORD +57 -0
- sqlrooms-0.1.0.dist-info/WHEEL +4 -0
- sqlrooms-0.1.0.dist-info/entry_points.txt +2 -0
- sqlrooms-0.1.0.dist-info/licenses/LICENSE +9 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import{o as e,r as t,t as n}from"./chunk-jRWAZmH_.js";import{A as r,B as i,D as a,E as o,F as s,G as c,H as l,J as u,K as d,L as f,M as p,O as m,P as h,Q as g,R as _,T as v,U as y,V as b,b as x,c as S,f as C,h as w,j as T,k as E,l as ee,q as D,v as O,w as te,z as k}from"./CommandSlice-DPSuuiIV.js";import{t as ne}from"./react-dom-liMHu8hH.js";import{d as re,i as ie,o as A,p as j,r as ae,s as oe}from"./dist-dwKeDPoe.js";import{A as se,D as ce,O as M,i as le,k as ue,n as de,t as fe,x as pe}from"./tooltip-mgpsA9tW.js";import{t as me}from"./utils-yJ4l7ARz.js";var he=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,D());else{var t=n(l);t!==null&&k(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function ee(){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&&k(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(ee)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=ee,D=function(){te.postMessage(null)}}else D=function(){_(ee,0)};function k(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,k(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),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}}}})),ge=n(((e,t)=>{t.exports=he()})),_e=n((e=>{var t=ge(),n=g(),r=ne();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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(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 s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.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 d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function te(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var k=Symbol.for(`react.client.reference`);function re(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===k?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case ee:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?re(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return re(e(t))}catch{}}return null}var ie=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae={pending:!1,data:null,method:null,action:null},oe=[],se=-1;function ce(e){return{current:e}}function M(e){0>se||(e.current=oe[se],oe[se]=null,se--)}function le(e,t){se++,oe[se]=e.current,e.current=t}var ue=ce(null),de=ce(null),fe=ce(null),pe=ce(null);function me(e,t){switch(le(fe,t),le(de,e),le(ue,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Qd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Qd(t),e=$d(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}M(ue),le(ue,e)}function he(){M(ue),M(de),M(fe)}function _e(e){e.memoizedState!==null&&le(pe,e);var t=ue.current,n=$d(t,e.type);t!==n&&(le(de,e),le(ue,n))}function ve(e){de.current===e&&(M(ue),M(de)),pe.current===e&&(M(pe),lp._currentValue=ae)}var N,ye;function be(e){if(N===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);N=t&&t[1]||``,ye=-1<e.stack.indexOf(`
|
|
2
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
+
`+N+e+ye}var xe=!1;function Se(e,t){if(!e||xe)return``;xe=!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}e.call(n.prototype)}}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(`
|
|
4
|
+
`),l=s.split(`
|
|
5
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{xe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?be(n):``}function Ce(e,t){switch(e.tag){case 26:case 27:case 5:return be(e.type);case 16:return be(`Lazy`);case 13:return e.child!==t&&t!==null?be(`Suspense Fallback`):be(`Suspense`);case 19:return be(`SuspenseList`);case 0:case 15:return Se(e.type,!1);case 11:return Se(e.type.render,!1);case 1:return Se(e.type,!0);case 31:return be(`Activity`);default:return``}}function we(e){try{var t=``,n=null;do t+=Ce(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}}var Te=Object.prototype.hasOwnProperty,Ee=t.unstable_scheduleCallback,De=t.unstable_cancelCallback,Oe=t.unstable_shouldYield,ke=t.unstable_requestPaint,Ae=t.unstable_now,je=t.unstable_getCurrentPriorityLevel,Me=t.unstable_ImmediatePriority,Ne=t.unstable_UserBlockingPriority,Pe=t.unstable_NormalPriority,Fe=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,Le=t.log,Re=t.unstable_setDisableYieldValue,ze=null,Be=null;function Ve(e){if(typeof Le==`function`&&Re(e),Be&&typeof Be.setStrictMode==`function`)try{Be.setStrictMode(ze,e)}catch{}}var He=Math.clz32?Math.clz32:Ge,Ue=Math.log,We=Math.LN2;function Ge(e){return e>>>=0,e===0?32:31-(Ue(e)/We|0)|0}var Ke=256,qe=262144,Je=4194304;function Ye(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Xe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ye(n))):i=Ye(o):i=Ye(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ye(n))):i=Ye(o)):i=Ye(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Qe(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $e(){var e=Je;return Je<<=1,!(Je&62914560)&&(Je=4194304),e}function et(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function tt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function nt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-He(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&rt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function rt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-He(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function it(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-He(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function at(e,t){var n=t&-t;return n=n&42?1:ot(n),(n&(e.suspendedLanes|t))===0?n:0}function ot(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function st(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ct(){var e=j.p;return e===0?(e=window.event,e===void 0?32:Tp(e.type)):e}function lt(e,t){var n=j.p;try{return j.p=e,t()}finally{j.p=n}}var ut=Math.random().toString(36).slice(2),dt=`__reactFiber$`+ut,ft=`__reactProps$`+ut,pt=`__reactContainer$`+ut,mt=`__reactEvents$`+ut,ht=`__reactListeners$`+ut,gt=`__reactHandles$`+ut,_t=`__reactResources$`+ut,vt=`__reactMarker$`+ut;function yt(e){delete e[dt],delete e[ft],delete e[mt],delete e[ht],delete e[gt]}function bt(e){var t=e[dt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[pt]||n[dt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Sf(e);e!==null;){if(n=e[dt])return n;e=Sf(e)}return t}e=n,n=e.parentNode}return null}function xt(e){if(e=e[dt]||e[pt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function St(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Ct(e){var t=e[_t];return t||=e[_t]={hoistableStyles:new Map,hoistableScripts:new Map},t}function wt(e){e[vt]=!0}var Tt=new Set,Et={};function Dt(e,t){Ot(e,t),Ot(e+`Capture`,t)}function Ot(e,t){for(Et[e]=t,e=0;e<t.length;e++)Tt.add(t[e])}var kt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),At={},jt={};function Mt(e){return Te.call(jt,e)?!0:Te.call(At,e)?!1:kt.test(e)?jt[e]=!0:(At[e]=!0,!1)}function P(e,t,n){if(Mt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Nt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Pt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function F(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Ft(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function It(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Lt(e){if(!e._valueTracker){var t=Ft(e)?`checked`:`value`;e._valueTracker=It(e,t,``+e[t])}}function Rt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Ft(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function zt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Bt=/[\n"\\]/g;function Vt(e){return e.replace(Bt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Ht(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+F(t)):e.value!==``+F(t)&&(e.value=``+F(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Wt(e,o,F(n)):Wt(e,o,F(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+F(s):e.removeAttribute(`name`)}function Ut(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Lt(e);return}n=n==null?``:``+F(n),t=t==null?n:``+F(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Lt(e)}function Wt(e,t,n){t===`number`&&zt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Gt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+F(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Kt(e,t,n){if(t!=null&&(t=``+F(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+F(n)}function qt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ie(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=F(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Lt(e)}function Jt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Yt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Xt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Yt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Zt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Xt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Xt(e,o,t[o])}function Qt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var $t=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`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`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`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`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`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`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),en=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function tn(e){return en.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function nn(){}var rn=null;function an(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var on=null,sn=null;function cn(e){var t=xt(e);if(t&&(e=t.stateNode)){var n=e[ft]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Ht(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Vt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[ft]||null;if(!a)throw Error(i(90));Ht(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Rt(r)}break a;case`textarea`:Kt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Gt(e,!!n.multiple,t,!1)}}}var I=!1;function ln(e,t,n){if(I)return e(t,n);I=!0;try{return e(t)}finally{if(I=!1,(on!==null||sn!==null)&&(ku(),on&&(t=on,e=sn,sn=on=null,cn(t),e)))for(t=0;t<e.length;t++)cn(e[t])}}function un(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ft]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var dn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),fn=!1;if(dn)try{var pn={};Object.defineProperty(pn,`passive`,{get:function(){fn=!0}}),window.addEventListener(`test`,pn,pn),window.removeEventListener(`test`,pn,pn)}catch{fn=!1}var mn=null,hn=null,gn=null;function _n(){if(gn)return gn;var e,t=hn,n=t.length,r,i=`value`in mn?mn.value:mn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return gn=i.slice(e,1<r?1-r:void 0)}function vn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function yn(){return!0}function bn(){return!1}function xn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?yn:bn,this.isPropagationStopped=bn,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=yn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=yn)},persist:function(){},isPersistent:yn}),t}var Sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cn=xn(Sn),wn=f({},Sn,{view:0,detail:0}),Tn=xn(wn),En,Dn,On,kn=f({},wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==On&&(On&&e.type===`mousemove`?(En=e.screenX-On.screenX,Dn=e.screenY-On.screenY):Dn=En=0,On=e),En)},movementY:function(e){return`movementY`in e?e.movementY:Dn}}),An=xn(kn),jn=xn(f({},kn,{dataTransfer:0})),Mn=xn(f({},wn,{relatedTarget:0})),Nn=xn(f({},Sn,{animationName:0,elapsedTime:0,pseudoElement:0})),Pn=xn(f({},Sn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Fn=xn(f({},Sn,{data:0})),In={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Ln={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Rn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function zn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Rn[e])?!!t[e]:!1}function Bn(){return zn}var Vn=xn(f({},wn,{key:function(e){if(e.key){var t=In[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=vn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Ln[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bn,charCode:function(e){return e.type===`keypress`?vn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?vn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Hn=xn(f({},kn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Un=xn(f({},wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bn})),Wn=xn(f({},Sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Gn=xn(f({},kn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Kn=xn(f({},Sn,{newState:0,oldState:0})),qn=[9,13,27,32],Jn=dn&&`CompositionEvent`in window,Yn=null;dn&&`documentMode`in document&&(Yn=document.documentMode);var Xn=dn&&`TextEvent`in window&&!Yn,Zn=dn&&(!Jn||Yn&&8<Yn&&11>=Yn),Qn=` `,$n=!1;function er(e,t){switch(e){case`keyup`:return qn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function tr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var nr=!1;function rr(e,t){switch(e){case`compositionend`:return tr(t);case`keypress`:return t.which===32?($n=!0,Qn):null;case`textInput`:return e=t.data,e===Qn&&$n?null:e;default:return null}}function ir(e,t){if(nr)return e===`compositionend`||!Jn&&er(e,t)?(e=_n(),gn=hn=mn=null,nr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Zn&&t.locale!==`ko`?null:t.data;default:return null}}var ar={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function or(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!ar[e.type]:t===`textarea`}function sr(e,t,n,r){on?sn?sn.push(r):sn=[r]:on=r,t=Id(t,`onChange`),0<t.length&&(n=new Cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var cr=null,lr=null;function ur(e){Od(e,0)}function dr(e){if(Rt(St(e)))return e}function fr(e,t){if(e===`change`)return t}var pr=!1;if(dn){var mr;if(dn){var hr=`oninput`in document;if(!hr){var gr=document.createElement(`div`);gr.setAttribute(`oninput`,`return;`),hr=typeof gr.oninput==`function`}mr=hr}else mr=!1;pr=mr&&(!document.documentMode||9<document.documentMode)}function _r(){cr&&(cr.detachEvent(`onpropertychange`,L),lr=cr=null)}function L(e){if(e.propertyName===`value`&&dr(lr)){var t=[];sr(t,lr,e,an(e)),ln(ur,t)}}function vr(e,t,n){e===`focusin`?(_r(),cr=t,lr=n,cr.attachEvent(`onpropertychange`,L)):e===`focusout`&&_r()}function yr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return dr(lr)}function br(e,t){if(e===`click`)return dr(t)}function xr(e,t){if(e===`input`||e===`change`)return dr(t)}function Sr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Cr=typeof Object.is==`function`?Object.is:Sr;function wr(e,t){if(Cr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Te.call(t,i)||!Cr(e[i],t[i]))return!1}return!0}function Tr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function R(e,t){var n=Tr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Tr(n)}}function Er(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Er(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Dr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=zt(e.document)}return t}function Or(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var kr=dn&&`documentMode`in document&&11>=document.documentMode,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==zt(r)||(r=Ar,`selectionStart`in r&&Or(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Mr&&wr(Mr,r)||(Mr=r,r=Id(jr,`onSelect`),0<r.length&&(t=new Cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Ar)))}function Fr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Ir={animationend:Fr(`Animation`,`AnimationEnd`),animationiteration:Fr(`Animation`,`AnimationIteration`),animationstart:Fr(`Animation`,`AnimationStart`),transitionrun:Fr(`Transition`,`TransitionRun`),transitionstart:Fr(`Transition`,`TransitionStart`),transitioncancel:Fr(`Transition`,`TransitionCancel`),transitionend:Fr(`Transition`,`TransitionEnd`)},Lr={},Rr={};dn&&(Rr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Ir.animationend.animation,delete Ir.animationiteration.animation,delete Ir.animationstart.animation),`TransitionEvent`in window||delete Ir.transitionend.transition);function zr(e){if(Lr[e])return Lr[e];if(!Ir[e])return e;var t=Ir[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Rr)return Lr[e]=t[n];return e}var Br=zr(`animationend`),Vr=zr(`animationiteration`),Hr=zr(`animationstart`),Ur=zr(`transitionrun`),Wr=zr(`transitionstart`),Gr=zr(`transitioncancel`),Kr=zr(`transitionend`),qr=new Map,Jr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Jr.push(`scrollEnd`);function Yr(e,t){qr.set(e,t),Dt(t,[e])}var Xr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Zr=[],Qr=0,$r=0;function ei(){for(var e=Qr,t=$r=Qr=0;t<e;){var n=Zr[t];Zr[t++]=null;var r=Zr[t];Zr[t++]=null;var i=Zr[t];Zr[t++]=null;var a=Zr[t];if(Zr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ii(n,i,a)}}function ti(e,t,n,r){Zr[Qr++]=e,Zr[Qr++]=t,Zr[Qr++]=n,Zr[Qr++]=r,$r|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ni(e,t,n,r){return ti(e,t,n,r),ai(e)}function ri(e,t){return ti(e,null,null,t),ai(e)}function ii(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-He(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ai(e){if(50<xu)throw xu=0,Su=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var oi={};function si(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ci(e,t,n,r){return new si(e,t,n,r)}function li(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ui(e,t){var n=e.alternate;return n===null?(n=ci(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function di(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function fi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)li(e)&&(s=1);else if(typeof e==`string`)s=ep(e,n,ue.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case ee:return e=ci(31,n,t,a),e.elementType=ee,e.lanes=o,e;case _:return pi(n.children,a,o,t);case v:s=8,a|=24;break;case y:return e=ci(12,n,t,a|2),e.elementType=y,e.lanes=o,e;case C:return e=ci(13,n,t,a),e.elementType=C,e.lanes=o,e;case w:return e=ci(19,n,t,a),e.elementType=w,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case x:s=10;break a;case b:s=9;break a;case S:s=11;break a;case T:s=14;break a;case E:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=ci(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function pi(e,t,n,r){return e=ci(7,e,r,t),e.lanes=n,e}function mi(e,t,n){return e=ci(6,e,null,t),e.lanes=n,e}function hi(e){var t=ci(18,null,null,0);return t.stateNode=e,t}function gi(e,t,n){return t=ci(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var _i=new WeakMap;function vi(e,t){if(typeof e==`object`&&e){var n=_i.get(e);return n===void 0?(t={value:e,source:t,stack:we(t)},_i.set(e,t),t):n}return{value:e,source:t,stack:we(t)}}var yi=[],bi=0,xi=null,Si=0,Ci=[],wi=0,Ti=null,Ei=1,Di=``;function Oi(e,t){yi[bi++]=Si,yi[bi++]=xi,xi=e,Si=t}function ki(e,t,n){Ci[wi++]=Ei,Ci[wi++]=Di,Ci[wi++]=Ti,Ti=e;var r=Ei;e=Di;var i=32-He(r)-1;r&=~(1<<i),n+=1;var a=32-He(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ei=1<<32-He(t)+i|n<<i|r,Di=a+e}else Ei=1<<a|n<<i|r,Di=e}function Ai(e){e.return!==null&&(Oi(e,1),ki(e,1,0))}function ji(e){for(;e===xi;)xi=yi[--bi],yi[bi]=null,Si=yi[--bi],yi[bi]=null;for(;e===Ti;)Ti=Ci[--wi],Ci[wi]=null,Di=Ci[--wi],Ci[wi]=null,Ei=Ci[--wi],Ci[wi]=null}function Mi(e,t){Ci[wi++]=Ei,Ci[wi++]=Di,Ci[wi++]=Ti,Ei=t.id,Di=t.overflow,Ti=e}var Ni=null,Pi=null,Fi=!1,Ii=null,Li=!1,Ri=Error(i(519));function zi(e){throw Gi(vi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ri}function Bi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[dt]=e,t[ft]=r,n){case`dialog`:kd(`cancel`,t),kd(`close`,t);break;case`iframe`:case`object`:case`embed`:kd(`load`,t);break;case`video`:case`audio`:for(n=0;n<Ed.length;n++)kd(Ed[n],t);break;case`source`:kd(`error`,t);break;case`img`:case`image`:case`link`:kd(`error`,t),kd(`load`,t);break;case`details`:kd(`toggle`,t);break;case`input`:kd(`invalid`,t),Ut(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:kd(`invalid`,t);break;case`textarea`:kd(`invalid`,t),qt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Hd(t.textContent,n)?(r.popover!=null&&(kd(`beforetoggle`,t),kd(`toggle`,t)),r.onScroll!=null&&kd(`scroll`,t),r.onScrollEnd!=null&&kd(`scrollend`,t),r.onClick!=null&&(t.onclick=nn),t=!0):t=!1,t||zi(e,!0)}function Vi(e){for(Ni=e.return;Ni;)switch(Ni.tag){case 5:case 31:case 13:Li=!1;return;case 27:case 3:Li=!0;return;default:Ni=Ni.return}}function Hi(e){if(e!==Ni)return!1;if(!Fi)return Vi(e),Fi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||ef(e.type,e.memoizedProps)),n=!n),n&&Pi&&zi(e),Vi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Pi=xf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Pi=xf(e)}else t===27?(t=Pi,lf(e.type)?(e=bf,bf=null,Pi=e):Pi=t):Pi=Ni?yf(e.stateNode.nextSibling):null;return!0}function Ui(){Pi=Ni=null,Fi=!1}function Wi(){var e=Ii;return e!==null&&(su===null?su=e:su.push.apply(su,e),Ii=null),e}function Gi(e){Ii===null?Ii=[e]:Ii.push(e)}var Ki=ce(null),qi=null,Ji=null;function Yi(e,t,n){le(Ki,t._currentValue),t._currentValue=n}function Xi(e){e._currentValue=Ki.current,M(Ki)}function Zi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Qi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Zi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Zi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function $i(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Cr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===pe.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[lp]:e.push(lp))}a=a.return}e!==null&&Qi(t,e,n,r),t.flags|=262144}function ea(e){for(e=e.firstContext;e!==null;){if(!Cr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ta(e){qi=e,Ji=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function na(e){return ia(qi,e)}function ra(e,t){return qi===null&&ta(e),ia(e,t)}function ia(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ji===null){if(e===null)throw Error(i(308));Ji=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ji=Ji.next=t;return n}var aa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},oa=t.unstable_scheduleCallback,sa=t.unstable_NormalPriority,ca={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function la(){return{controller:new aa,data:new Map,refCount:0}}function ua(e){e.refCount--,e.refCount===0&&oa(sa,function(){e.controller.abort()})}var da=null,fa=0,pa=0,ma=null;function ha(e,t){if(da===null){var n=da=[];fa=0,pa=bd(),ma={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return fa++,t.then(ga,ga),t}function ga(){if(--fa===0&&da!==null){ma!==null&&(ma.status=`fulfilled`);var e=da;da=null,pa=0,ma=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function _a(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var va=A.S;A.S=function(e,t){uu=Ae(),typeof t==`object`&&t&&typeof t.then==`function`&&ha(e,t),va!==null&&va(e,t)};var ya=ce(null);function ba(){var e=ya.current;return e===null?Gl.pooledCache:e}function xa(e,t){t===null?le(ya,ya.current):le(ya,t.pool)}function Sa(){var e=ba();return e===null?null:{parent:ca._currentValue,pool:e}}var Ca=Error(i(460)),wa=Error(i(474)),Ta=Error(i(542)),Ea={then:function(){}};function Da(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Oa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(nn,nn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ma(e),e;default:if(typeof t.status==`string`)t.then(nn,nn);else{if(e=Gl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ma(e),e}throw Aa=t,Ca}}function ka(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Aa=e,Ca):e}}var Aa=null;function ja(){if(Aa===null)throw Error(i(459));var e=Aa;return Aa=null,e}function Ma(e){if(e===Ca||e===Ta)throw Error(i(483))}var Na=null,Pa=0;function Fa(e){var t=Pa;return Pa+=1,Na===null&&(Na=[]),Oa(Na,e,t)}function Ia(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function La(e,t){throw t.$$typeof===p?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ra(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=ui(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=mi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===E&&ka(i)===t.type)?(t=a(t,n.props),Ia(t,n),t.return=e,t):(t=fi(n.type,n.key,n.props,null,e.mode,r),Ia(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=gi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=pi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=mi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case m:return n=fi(t.type,t.key,t.props,null,e.mode,n),Ia(n,t),n.return=e,n;case h:return t=gi(t,e.mode,n),t.return=e,t;case E:return t=ka(t),f(e,t,n)}if(ie(t)||te(t))return t=pi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Fa(t),n);if(t.$$typeof===x)return f(e,ra(e,t),n);La(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case m:return n.key===i?l(e,t,n,r):null;case h:return n.key===i?u(e,t,n,r):null;case E:return n=ka(n),p(e,t,n,r)}if(ie(n)||te(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Fa(n),r);if(n.$$typeof===x)return p(e,t,ra(e,n),r);La(e,n)}return null}function g(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case m:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case h:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case E:return r=ka(r),g(e,t,n,r,i)}if(ie(r)||te(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return g(e,t,n,Fa(r),i);if(r.$$typeof===x)return g(e,t,n,ra(t,r),i);La(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,m=a=0,h=null;d!==null&&m<s.length;m++){d.index>m?(h=d,d=null):h=d.sibling;var _=p(i,d,s[m],c);if(_===null){d===null&&(d=h);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,m),u===null?l=_:u.sibling=_,u=_,d=h}if(m===s.length)return n(i,d),Fi&&Oi(i,m),l;if(d===null){for(;m<s.length;m++)d=f(i,s[m],c),d!==null&&(a=o(d,a,m),u===null?l=d:u.sibling=d,u=d);return Fi&&Oi(i,m),l}for(d=r(d);m<s.length;m++)h=g(d,i,m,s[m],c),h!==null&&(e&&h.alternate!==null&&d.delete(h.key===null?m:h.key),a=o(h,a,m),u===null?l=h:u.sibling=h,u=h);return e&&d.forEach(function(e){return t(i,e)}),Fi&&Oi(i,m),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,m=s,h=s=0,_=null,v=c.next();m!==null&&!v.done;h++,v=c.next()){m.index>h?(_=m,m=null):_=m.sibling;var y=p(a,m,v.value,l);if(y===null){m===null&&(m=_);break}e&&m&&y.alternate===null&&t(a,m),s=o(y,s,h),d===null?u=y:d.sibling=y,d=y,m=_}if(v.done)return n(a,m),Fi&&Oi(a,h),u;if(m===null){for(;!v.done;h++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return Fi&&Oi(a,h),u}for(m=r(m);!v.done;h++,v=c.next())v=g(m,a,h,v.value,l),v!==null&&(e&&v.alternate!==null&&m.delete(v.key===null?h:v.key),s=o(v,s,h),d===null?u=v:d.sibling=v,d=v);return e&&m.forEach(function(e){return t(a,e)}),Fi&&Oi(a,h),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case m:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===E&&ka(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ia(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===_?(c=pi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=fi(o.type,o.key,o.props,null,e.mode,c),Ia(c,o),c.return=e,e=c)}return s(e);case h:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=gi(o,e.mode,c),c.return=e,e=c}return s(e);case E:return o=ka(o),b(e,r,o,c)}if(ie(o))return v(e,r,o,c);if(te(o)){if(l=te(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Fa(o),c);if(o.$$typeof===x)return b(e,r,ra(e,o),c);La(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=mi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Pa=0;var i=b(e,t,n,r);return Na=null,i}catch(t){if(t===Ca||t===Ta)throw t;var a=ci(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var za=Ra(!0),Ba=Ra(!1),Va=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ua(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Wa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ga(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Wl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ai(e),ii(e,null,n),t}return ti(e,r,t,n),ai(e)}function Ka(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}function qa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ja=!1;function Ya(){if(Ja){var e=ma;if(e!==null)throw e}}function Xa(e,t,n,r){Ja=!1;var i=e.updateQueue;Va=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(ql&p)===p:(r&p)===p){p!==0&&p===pa&&(Ja=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Va=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),tu|=o,e.lanes=o,e.memoizedState=d}}function Za(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Qa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Za(n[e],t)}var $a=ce(null),eo=ce(0);function to(e,t){e=$l,le(eo,e),le($a,t),$l=e|t.baseLanes}function no(){le(eo,$l),le($a,$a.current)}function ro(){$l=eo.current,M($a),M(eo)}var io=ce(null),ao=null;function oo(e){var t=e.alternate;le(fo,fo.current&1),le(io,e),ao===null&&(t===null||$a.current!==null||t.memoizedState!==null)&&(ao=e)}function so(e){le(fo,fo.current),le(io,e),ao===null&&(ao=e)}function co(e){e.tag===22?(le(fo,fo.current),le(io,e),ao===null&&(ao=e)):lo(e)}function lo(){le(fo,fo.current),le(io,io.current)}function uo(e){M(io),ao===e&&(ao=null),M(fo)}var fo=ce(0);function po(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||gf(n)||_f(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var mo=0,ho=null,go=null,_o=null,vo=!1,yo=!1,bo=!1,xo=0,So=0,Co=null,wo=0;function To(){throw Error(i(321))}function Eo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Cr(e[n],t[n]))return!1;return!0}function Do(e,t,n,r,i,a){return mo=a,ho=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,A.H=e===null||e.memoizedState===null?Ws:Gs,bo=!1,a=n(r,i),bo=!1,yo&&(a=ko(t,n,r,i)),Oo(e),a}function Oo(e){A.H=Us;var t=go!==null&&go.next!==null;if(mo=0,_o=go=ho=null,vo=!1,So=0,Co=null,t)throw Error(i(300));e===null||sc||(e=e.dependencies,e!==null&&ea(e)&&(sc=!0))}function ko(e,t,n,r){ho=e;var a=0;do{if(yo&&(Co=null),So=0,yo=!1,25<=a)throw Error(i(301));if(a+=1,_o=go=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}A.H=Ks,o=t(n,r)}while(yo);return o}function Ao(){var e=A.H,t=e.useState()[0];return t=typeof t.then==`function`?Lo(t):t,e=e.useState()[0],(go===null?null:go.memoizedState)!==e&&(ho.flags|=1024),t}function jo(){var e=xo!==0;return xo=0,e}function Mo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function No(e){if(vo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}vo=!1}mo=0,_o=go=ho=null,yo=!1,So=xo=0,Co=null}function Po(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _o===null?ho.memoizedState=_o=e:_o=_o.next=e,_o}function Fo(){if(go===null){var e=ho.alternate;e=e===null?null:e.memoizedState}else e=go.next;var t=_o===null?ho.memoizedState:_o.next;if(t!==null)_o=t,go=e;else{if(e===null)throw ho.alternate===null?Error(i(467)):Error(i(310));go=e,e={memoizedState:go.memoizedState,baseState:go.baseState,baseQueue:go.baseQueue,queue:go.queue,next:null},_o===null?ho.memoizedState=_o=e:_o=_o.next=e}return _o}function Io(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Lo(e){var t=So;return So+=1,Co===null&&(Co=[]),e=Oa(Co,e,t),t=ho,(_o===null?t.memoizedState:_o.next)===null&&(t=t.alternate,A.H=t===null||t.memoizedState===null?Ws:Gs),e}function Ro(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Lo(e);if(e.$$typeof===x)return na(e)}throw Error(i(438,String(e)))}function zo(e){var t=null,n=ho.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=ho.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Io(),ho.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=D;return t.index++,n}function Bo(e,t){return typeof t==`function`?t(e):t}function Vo(e){return Ho(Fo(),go,e)}function Ho(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(mo&f)===f:(ql&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===pa&&(d=!0);else if((mo&p)===p){u=u.next,p===pa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,ho.lanes|=p,tu|=p;f=u.action,bo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,ho.lanes|=f,tu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Cr(o,e.memoizedState)&&(sc=!0,d&&(n=ma,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Uo(e){var t=Fo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Cr(o,t.memoizedState)||(sc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Wo(e,t,n){var r=ho,a=Fo(),o=Fi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Cr((go||a).memoizedState,n);if(s&&(a.memoizedState=n,sc=!0),a=a.queue,hs(qo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||_o!==null&&_o.memoizedState.tag&1){if(r.flags|=2048,us(9,{destroy:void 0},Ko.bind(null,r,a,n,t),null),Gl===null)throw Error(i(349));o||mo&127||Go(r,t,n)}return n}function Go(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ho.updateQueue,t===null?(t=Io(),ho.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Ko(e,t,n,r){t.value=n,t.getSnapshot=r,Jo(t)&&Yo(e)}function qo(e,t,n){return n(function(){Jo(t)&&Yo(e)})}function Jo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Cr(e,n)}catch{return!0}}function Yo(e){var t=ri(e,2);t!==null&&Tu(t,e,2)}function Xo(e){var t=Po();if(typeof e==`function`){var n=e;if(e=n(),bo){Ve(!0);try{n()}finally{Ve(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bo,lastRenderedState:e},t}function Zo(e,t,n,r){return e.baseState=n,Ho(e,go,typeof r==`function`?r:Bo)}function Qo(e,t,n,r,a){if(Bs(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};A.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,$o(t,o)):(o.next=n.next,t.pending=n.next=o)}}function $o(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=A.T,o={};A.T=o;try{var s=n(i,r),c=A.S;c!==null&&c(o,s),es(e,t,s)}catch(n){ns(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),A.T=a}}else try{a=n(i,r),es(e,t,a)}catch(n){ns(e,t,n)}}function es(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ts(e,t,n)},function(n){return ns(e,t,n)}):ts(e,t,n)}function ts(e,t,n){t.status=`fulfilled`,t.value=n,rs(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,$o(e,n)))}function ns(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,rs(t),t=t.next;while(t!==r)}e.action=null}function rs(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function is(e,t){return t}function as(e,t){if(Fi){var n=Gl.formState;if(n!==null){a:{var r=ho;if(Fi){if(Pi){b:{for(var i=Pi,a=Li;i.nodeType!==8;){if(!a){i=null;break b}if(i=yf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Pi=yf(i.nextSibling),r=i.data===`F!`;break a}}zi(r)}r=!1}r&&(t=n[0])}}return n=Po(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:is,lastRenderedState:t},n.queue=r,n=Ls.bind(null,ho,r),r.dispatch=n,r=Xo(!1),a=zs.bind(null,ho,!1,r.queue),r=Po(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Qo.bind(null,ho,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function os(e){return ss(Fo(),go,e)}function ss(e,t,n){if(t=Ho(e,t,is)[0],e=Vo(Bo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Lo(t)}catch(e){throw e===Ca?Ta:e}else r=t;t=Fo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(ho.flags|=2048,us(9,{destroy:void 0},cs.bind(null,i,n),null)),[r,a,e]}function cs(e,t){e.action=t}function ls(e){var t=Fo(),n=go;if(n!==null)return ss(t,n,e);Fo(),t=t.memoizedState,n=Fo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function us(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=ho.updateQueue,t===null&&(t=Io(),ho.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ds(){return Fo().memoizedState}function fs(e,t,n,r){var i=Po();ho.flags|=e,i.memoizedState=us(1|t,{destroy:void 0},n,r===void 0?null:r)}function ps(e,t,n,r){var i=Fo();r=r===void 0?null:r;var a=i.memoizedState.inst;go!==null&&r!==null&&Eo(r,go.memoizedState.deps)?i.memoizedState=us(t,a,n,r):(ho.flags|=e,i.memoizedState=us(1|t,a,n,r))}function ms(e,t){fs(8390656,8,e,t)}function hs(e,t){ps(2048,8,e,t)}function gs(e){ho.flags|=4;var t=ho.updateQueue;if(t===null)t=Io(),ho.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function _s(e){var t=Fo().memoizedState;return gs({ref:t,nextImpl:e}),function(){if(Wl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function vs(e,t){return ps(4,2,e,t)}function ys(e,t){return ps(4,4,e,t)}function bs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function xs(e,t,n){n=n==null?null:n.concat([e]),ps(4,4,bs.bind(null,t,e),n)}function Ss(){}function Cs(e,t){var n=Fo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Eo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ws(e,t){var n=Fo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Eo(t,r[1]))return r[0];if(r=e(),bo){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r}function Ts(e,t,n){return n===void 0||mo&1073741824&&!(ql&261930)?e.memoizedState=t:(e.memoizedState=n,e=wu(),ho.lanes|=e,tu|=e,n)}function Es(e,t,n,r){return Cr(n,t)?n:$a.current===null?!(mo&42)||mo&1073741824&&!(ql&261930)?(sc=!0,e.memoizedState=n):(e=wu(),ho.lanes|=e,tu|=e,t):(e=Ts(e,n,r),Cr(e,t)||(sc=!0),e)}function Ds(e,t,n,r,i){var a=j.p;j.p=a!==0&&8>a?a:8;var o=A.T,s={};A.T=s,zs(e,!1,t,n);try{var c=i(),l=A.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Rs(e,t,_a(c,r),Cu(e)):Rs(e,t,r,Cu(e))}catch(n){Rs(e,t,{then:function(){},status:`rejected`,reason:n},Cu())}finally{j.p=a,o!==null&&s.types!==null&&(o.types=s.types),A.T=o}}function Os(){}function ks(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=As(e).queue;Ds(e,a,t,ae,n===null?Os:function(){return js(e),n(r)})}function As(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bo,lastRenderedState:ae},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function js(e){var t=As(e);t.next===null&&(t=e.alternate.memoizedState),Rs(e,t.next.queue,{},Cu())}function Ms(){return na(lp)}function Ns(){return Fo().memoizedState}function Ps(){return Fo().memoizedState}function Fs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Cu();e=Wa(n);var r=Ga(t,e,n);r!==null&&(Tu(r,t,n),Ka(r,t,n)),t={cache:la()},e.payload=t;return}t=t.return}}function Is(e,t,n){var r=Cu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Bs(e)?Vs(t,n):(n=ni(e,t,n,r),n!==null&&(Tu(n,e,r),Hs(n,t,r)))}function Ls(e,t,n){Rs(e,t,n,Cu())}function Rs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Bs(e))Vs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Cr(s,o))return ti(e,t,i,0),Gl===null&&ei(),!1}catch{}if(n=ni(e,t,i,r),n!==null)return Tu(n,e,r),Hs(n,t,r),!0}return!1}function zs(e,t,n,r){if(r={lane:2,revertLane:bd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Bs(e)){if(t)throw Error(i(479))}else t=ni(e,n,r,2),t!==null&&Tu(t,e,2)}function Bs(e){var t=e.alternate;return e===ho||t!==null&&t===ho}function Vs(e,t){yo=vo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Hs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,it(e,n)}}var Us={readContext:na,use:Ro,useCallback:To,useContext:To,useEffect:To,useImperativeHandle:To,useLayoutEffect:To,useInsertionEffect:To,useMemo:To,useReducer:To,useRef:To,useState:To,useDebugValue:To,useDeferredValue:To,useTransition:To,useSyncExternalStore:To,useId:To,useHostTransitionStatus:To,useFormState:To,useActionState:To,useOptimistic:To,useMemoCache:To,useCacheRefresh:To};Us.useEffectEvent=To;var Ws={readContext:na,use:Ro,useCallback:function(e,t){return Po().memoizedState=[e,t===void 0?null:t],e},useContext:na,useEffect:ms,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),fs(4194308,4,bs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return fs(4194308,4,e,t)},useInsertionEffect:function(e,t){fs(4,2,e,t)},useMemo:function(e,t){var n=Po();t=t===void 0?null:t;var r=e();if(bo){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Po();if(n!==void 0){var i=n(t);if(bo){Ve(!0);try{n(t)}finally{Ve(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Is.bind(null,ho,e),[r.memoizedState,e]},useRef:function(e){var t=Po();return e={current:e},t.memoizedState=e},useState:function(e){e=Xo(e);var t=e.queue,n=Ls.bind(null,ho,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ss,useDeferredValue:function(e,t){return Ts(Po(),e,t)},useTransition:function(){var e=Xo(!1);return e=Ds.bind(null,ho,e.queue,!0,!1),Po().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=ho,a=Po();if(Fi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Gl===null)throw Error(i(349));ql&127||Go(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ms(qo.bind(null,r,o,e),[e]),r.flags|=2048,us(9,{destroy:void 0},Ko.bind(null,r,o,n,t),null),n},useId:function(){var e=Po(),t=Gl.identifierPrefix;if(Fi){var n=Di,r=Ei;n=(r&~(1<<32-He(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=xo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=wo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Ms,useFormState:as,useActionState:as,useOptimistic:function(e){var t=Po();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=zs.bind(null,ho,!0,n),n.dispatch=t,[e,t]},useMemoCache:zo,useCacheRefresh:function(){return Po().memoizedState=Fs.bind(null,ho)},useEffectEvent:function(e){var t=Po(),n={impl:e};return t.memoizedState=n,function(){if(Wl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Gs={readContext:na,use:Ro,useCallback:Cs,useContext:na,useEffect:hs,useImperativeHandle:xs,useInsertionEffect:vs,useLayoutEffect:ys,useMemo:ws,useReducer:Vo,useRef:ds,useState:function(){return Vo(Bo)},useDebugValue:Ss,useDeferredValue:function(e,t){return Es(Fo(),go.memoizedState,e,t)},useTransition:function(){var e=Vo(Bo)[0],t=Fo().memoizedState;return[typeof e==`boolean`?e:Lo(e),t]},useSyncExternalStore:Wo,useId:Ns,useHostTransitionStatus:Ms,useFormState:os,useActionState:os,useOptimistic:function(e,t){return Zo(Fo(),go,e,t)},useMemoCache:zo,useCacheRefresh:Ps};Gs.useEffectEvent=_s;var Ks={readContext:na,use:Ro,useCallback:Cs,useContext:na,useEffect:hs,useImperativeHandle:xs,useInsertionEffect:vs,useLayoutEffect:ys,useMemo:ws,useReducer:Uo,useRef:ds,useState:function(){return Uo(Bo)},useDebugValue:Ss,useDeferredValue:function(e,t){var n=Fo();return go===null?Ts(n,e,t):Es(n,go.memoizedState,e,t)},useTransition:function(){var e=Uo(Bo)[0],t=Fo().memoizedState;return[typeof e==`boolean`?e:Lo(e),t]},useSyncExternalStore:Wo,useId:Ns,useHostTransitionStatus:Ms,useFormState:ls,useActionState:ls,useOptimistic:function(e,t){var n=Fo();return go===null?(n.baseState=e,[e,n.queue.dispatch]):Zo(n,go,e,t)},useMemoCache:zo,useCacheRefresh:Ps};Ks.useEffectEvent=_s;function qs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Js={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Cu(),i=Wa(r);i.payload=t,n!=null&&(i.callback=n),t=Ga(e,i,r),t!==null&&(Tu(t,e,r),Ka(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Cu(),i=Wa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ga(e,i,r),t!==null&&(Tu(t,e,r),Ka(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Cu(),r=Wa(n);r.tag=2,t!=null&&(r.callback=t),t=Ga(e,r,n),t!==null&&(Tu(t,e,n),Ka(t,e,n))}};function Ys(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!wr(n,r)||!wr(i,a):!0}function Xs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Js.enqueueReplaceState(t,t.state,null)}function Zs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Qs(e){Xr(e)}function $s(e){console.error(e)}function ec(e){Xr(e)}function tc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function z(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function nc(e,t,n){return n=Wa(n),n.tag=3,n.payload={element:null},n.callback=function(){tc(e,t)},n}function rc(e){return e=Wa(e),e.tag=3,e}function ic(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){z(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){z(t,n,r),typeof i!=`function`&&(pu===null?pu=new Set([this]):pu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function ac(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&$i(t,n,a,!0),n=io.current,n!==null){switch(n.tag){case 31:case 13:return ao===null?Iu():n.alternate===null&&eu===0&&(eu=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Ea?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ed(e,r,a)),!1;case 22:return n.flags|=65536,r===Ea?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),ed(e,r,a)),!1}throw Error(i(435,n.tag))}return ed(e,r,a),Iu(),!1}if(Fi)return t=io.current,t===null?(r!==Ri&&(t=Error(i(423),{cause:r}),Gi(vi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=vi(r,n),a=nc(e.stateNode,r,a),qa(e,a),eu!==4&&(eu=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ri&&(e=Error(i(422),{cause:r}),Gi(vi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=vi(o,n),ou===null?ou=[o]:ou.push(o),eu!==4&&(eu=2),t===null)return!0;r=vi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=nc(n.stateNode,r,e),qa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(pu===null||!pu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=rc(a),ic(a,e,n,r),qa(n,a),!1}n=n.return}while(n!==null);return!1}var oc=Error(i(461)),sc=!1;function cc(e,t,n,r){t.child=e===null?Ba(t,null,n,r):za(t,e.child,n,r)}function lc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return ta(t),r=Do(e,t,n,o,a,i),s=jo(),e!==null&&!sc?(Mo(e,t,i),Nc(e,t,i)):(Fi&&s&&Ai(t),t.flags|=1,cc(e,t,r,i),t.child)}function uc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!li(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,dc(e,t,a,r,i)):(e=fi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Pc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?wr:n,n(o,r)&&e.ref===t.ref)return Nc(e,t,i)}return t.flags|=1,e=ui(a,r),e.ref=t.ref,e.return=t,t.child=e}function dc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(wr(a,r)&&e.ref===t.ref)if(sc=!1,t.pendingProps=r=a,Pc(e,i))e.flags&131072&&(sc=!0);else return t.lanes=e.lanes,Nc(e,t,i)}return yc(e,t,n,r,i)}function fc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return mc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&xa(t,a===null?null:a.cachePool),a===null?no():to(t,a),co(t);else return r=t.lanes=536870912,mc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&xa(t,null),no(),lo(t)):(xa(t,a.cachePool),to(t,a),lo(t),t.memoizedState=null);return cc(e,t,i,n),t.child}function pc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function mc(e,t,n,r,i){var a=ba();return a=a===null?null:{parent:ca._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&xa(t,null),no(),co(t),e!==null&&$i(e,t,r,!0),t.childLanes=i,null}function hc(e,t){return t=Oc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function gc(e,t,n){return za(t,e.child,null,n),e=hc(t,t.pendingProps),e.flags|=2,uo(t),t.memoizedState=null,e}function _c(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Fi){if(r.mode===`hidden`)return e=hc(t,r),t.lanes=536870912,pc(null,e);if(so(t),(e=Pi)?(e=hf(e,Li),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ti===null?null:{id:Ei,overflow:Di},retryLane:536870912,hydrationErrors:null},n=hi(e),n.return=t,t.child=n,Ni=t,Pi=null)):e=null,e===null)throw zi(t);return t.lanes=536870912,null}return hc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(so(t),a)if(t.flags&256)t.flags&=-257,t=gc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(sc||$i(e,t,n,!1),a=(n&e.childLanes)!==0,sc||a){if(r=Gl,r!==null&&(s=at(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ri(e,s),Tu(r,e,s),oc;Iu(),t=gc(e,t,n)}else e=o.treeContext,Pi=yf(s.nextSibling),Ni=t,Fi=!0,Ii=null,Li=!1,e!==null&&Mi(t,e),t=hc(t,r),t.flags|=4096;return t}return e=ui(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function vc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function yc(e,t,n,r,i){return ta(t),n=Do(e,t,n,r,void 0,i),r=jo(),e!==null&&!sc?(Mo(e,t,i),Nc(e,t,i)):(Fi&&r&&Ai(t),t.flags|=1,cc(e,t,n,i),t.child)}function bc(e,t,n,r,i,a){return ta(t),t.updateQueue=null,n=ko(t,r,n,i),Oo(e),r=jo(),e!==null&&!sc?(Mo(e,t,a),Nc(e,t,a)):(Fi&&r&&Ai(t),t.flags|=1,cc(e,t,n,a),t.child)}function xc(e,t,n,r,i){if(ta(t),t.stateNode===null){var a=oi,o=n.contextType;typeof o==`object`&&o&&(a=na(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Js,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ha(t),o=n.contextType,a.context=typeof o==`object`&&o?na(o):oi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(qs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Js.enqueueReplaceState(a,a.state,null),Xa(t,r,a,i),Ya(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Zs(n,s);a.props=c;var l=a.context,u=n.contextType;o=oi,typeof u==`object`&&u&&(o=na(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Xs(t,a,r,o),Va=!1;var f=t.memoizedState;a.state=f,Xa(t,r,a,i),Ya(),l=t.memoizedState,s||f!==l||Va?(typeof d==`function`&&(qs(t,n,d,r),l=t.memoizedState),(c=Va||Ys(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ua(e,t),o=t.memoizedProps,u=Zs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=oi,typeof l==`object`&&l&&(c=na(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Xs(t,a,r,c),Va=!1,f=t.memoizedState,a.state=f,Xa(t,r,a,i),Ya();var p=t.memoizedState;o!==d||f!==p||Va||e!==null&&e.dependencies!==null&&ea(e.dependencies)?(typeof s==`function`&&(qs(t,n,s,r),p=t.memoizedState),(u=Va||Ys(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ea(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,vc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=za(t,e.child,null,i),t.child=za(t,null,n,i)):cc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Nc(e,t,i),e}function Sc(e,t,n,r){return Ui(),t.flags|=256,cc(e,t,n,r),t.child}var Cc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function wc(e){return{baseLanes:e,cachePool:Sa()}}function Tc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=iu),e}function Ec(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(fo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Fi){if(a?oo(t):lo(t),(e=Pi)?(e=hf(e,Li),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ti===null?null:{id:Ei,overflow:Di},retryLane:536870912,hydrationErrors:null},n=hi(e),n.return=t,t.child=n,Ni=t,Pi=null)):e=null,e===null)throw zi(t);return _f(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(lo(t),a=t.mode,c=Oc({mode:`hidden`,children:c},a),r=pi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=wc(n),r.childLanes=Tc(e,s,n),t.memoizedState=Cc,pc(null,r)):(oo(t),Dc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(oo(t),t.flags&=-257,t=kc(e,t,n)):t.memoizedState===null?(lo(t),c=r.fallback,a=t.mode,r=Oc({mode:`visible`,children:r.children},a),c=pi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,za(t,e.child,null,n),r=t.child,r.memoizedState=wc(n),r.childLanes=Tc(e,s,n),t.memoizedState=Cc,t=pc(null,r)):(lo(t),t.child=e.child,t.flags|=128,t=null);else if(oo(t),_f(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Gi({value:r,source:null,stack:null}),t=kc(e,t,n)}else if(sc||$i(e,t,n,!1),s=(n&e.childLanes)!==0,sc||s){if(s=Gl,s!==null&&(r=at(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ri(e,r),Tu(s,e,r),oc;gf(c)||Iu(),t=kc(e,t,n)}else gf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Pi=yf(c.nextSibling),Ni=t,Fi=!0,Ii=null,Li=!1,e!==null&&Mi(t,e),t=Dc(t,r.children),t.flags|=4096);return t}return a?(lo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=ui(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=pi(c,a,n,null),c.flags|=2):c=ui(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,pc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=wc(n):(a=c.cachePool,a===null?a=Sa():(l=ca._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=Tc(e,s,n),t.memoizedState=Cc,pc(e.child,r)):(oo(t),n=e.child,e=n.sibling,n=ui(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Dc(e,t){return t=Oc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Oc(e,t){return e=ci(22,e,null,t),e.lanes=0,e}function kc(e,t,n){return za(t,e.child,null,n),e=Dc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ac(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Zi(e.return,t,n)}function jc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Mc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=fo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,le(fo,o),cc(e,t,r,n),r=Fi?Si:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ac(e,n,t);else if(e.tag===19)Ac(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&po(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),jc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&po(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}jc(t,!0,n,null,a,r);break;case`together`:jc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Nc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),tu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if($i(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=ui(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ui(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Pc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&ea(e))):!0}function Fc(e,t,n){switch(t.tag){case 3:me(t,t.stateNode.containerInfo),Yi(t,ca,e.memoizedState.cache),Ui();break;case 27:case 5:_e(t);break;case 4:me(t,t.stateNode.containerInfo);break;case 10:Yi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,so(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(oo(t),e=Nc(e,t,n),e===null?null:e.sibling):Ec(e,t,n):(oo(t),t.flags|=128,null);oo(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=($i(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Mc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),le(fo,fo.current),r)break;return null;case 22:return t.lanes=0,fc(e,t,n,t.pendingProps);case 24:Yi(t,ca,e.memoizedState.cache)}return Nc(e,t,n)}function Ic(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)sc=!0;else{if(!Pc(e,n)&&!(t.flags&128))return sc=!1,Fc(e,t,n);sc=!!(e.flags&131072)}else sc=!1,Fi&&t.flags&1048576&&ki(t,Si,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ka(t.elementType),t.type=e,typeof e==`function`)li(e)?(r=Zs(e,r),t.tag=1,t=xc(null,t,e,r,n)):(t.tag=0,t=yc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===S){t.tag=11,t=lc(null,t,e,r,n);break a}else if(a===T){t.tag=14,t=uc(null,t,e,r,n);break a}}throw t=re(e)||e,Error(i(306,t,``))}}return t;case 0:return yc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Zs(r,t.pendingProps),xc(e,t,r,a,n);case 3:a:{if(me(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ua(e,t),Xa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Yi(t,ca,r),r!==o.cache&&Qi(t,[ca],n,!0),Ya(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Sc(e,t,r,n);break a}else if(r!==a){a=vi(Error(i(424)),t),Gi(a),t=Sc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Pi=yf(e.firstChild),Ni=t,Fi=!0,Ii=null,Li=!0,n=Ba(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ui(),r===a){t=Nc(e,t,n);break a}cc(e,t,r,n)}t=t.child}return t;case 26:return vc(e,t),e===null?(n=Bf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Fi||(n=t.type,e=t.pendingProps,r=Zd(fe.current).createElement(n),r[dt]=t,r[ft]=e,Gd(r,n,e),wt(r),t.stateNode=r):t.memoizedState=Bf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return _e(t),e===null&&Fi&&(r=t.stateNode=Cf(t.type,t.pendingProps,fe.current),Ni=t,Li=!0,a=Pi,lf(t.type)?(bf=a,Pi=yf(r.firstChild)):Pi=a),cc(e,t,t.pendingProps.children,n),vc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Fi&&((a=r=Pi)&&(r=pf(r,t.type,t.pendingProps,Li),r===null?a=!1:(t.stateNode=r,Ni=t,Pi=yf(r.firstChild),Li=!1,a=!0)),a||zi(t)),_e(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,ef(a,o)?r=null:s!==null&&ef(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Do(e,t,Ao,null,null,n),lp._currentValue=a),vc(e,t),cc(e,t,r,n),t.child;case 6:return e===null&&Fi&&((e=n=Pi)&&(n=mf(n,t.pendingProps,Li),n===null?e=!1:(t.stateNode=n,Ni=t,Pi=null,e=!0)),e||zi(t)),null;case 13:return Ec(e,t,n);case 4:return me(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=za(t,null,r,n):cc(e,t,r,n),t.child;case 11:return lc(e,t,t.type,t.pendingProps,n);case 7:return cc(e,t,t.pendingProps,n),t.child;case 8:return cc(e,t,t.pendingProps.children,n),t.child;case 12:return cc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Yi(t,t.type,r.value),cc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,ta(t),a=na(a),r=r(a),t.flags|=1,cc(e,t,r,n),t.child;case 14:return uc(e,t,t.type,t.pendingProps,n);case 15:return dc(e,t,t.type,t.pendingProps,n);case 19:return Mc(e,t,n);case 31:return _c(e,t,n);case 22:return fc(e,t,n,t.pendingProps);case 24:return ta(t),r=na(ca),e===null?(a=ba(),a===null&&(a=Gl,o=la(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ha(t),Yi(t,ca,a)):((e.lanes&n)!==0&&(Ua(e,t),Xa(t,null,null,n),Ya()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Yi(t,ca,r),r!==a.cache&&Qi(t,[ca],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Yi(t,ca,r))),cc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Lc(e){e.flags|=4}function Rc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Nu())e.flags|=8192;else throw Aa=Ea,wa}else e.flags&=-16777217}function zc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!tp(t))if(Nu())e.flags|=8192;else throw Aa=Ea,wa}function Bc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:$e(),e.lanes|=t,au|=t)}function Vc(e,t){if(!Fi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Hc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Uc(e,t,n){var r=t.pendingProps;switch(ji(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Hc(t),null;case 1:return Hc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Xi(ca),he(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Hi(t)?Lc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Wi())),Hc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Lc(t),o===null?(Hc(t),Rc(t,a,null,r,n)):(Hc(t),zc(t,o))):o?o===e.memoizedState?(Hc(t),t.flags&=-16777217):(Lc(t),Hc(t),zc(t,o)):(e=e.memoizedProps,e!==r&&Lc(t),Hc(t),Rc(t,a,e,r,n)),null;case 27:if(ve(t),n=fe.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Lc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Hc(t),null}e=ue.current,Hi(t)?Bi(t,e):(e=Cf(a,r,n),t.stateNode=e,Lc(t))}return Hc(t),null;case 5:if(ve(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Lc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Hc(t),null}if(o=ue.current,Hi(t))Bi(t,o);else{var s=Zd(fe.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[dt]=t,o[ft]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Gd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Lc(t)}}return Hc(t),Rc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Lc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=fe.current,Hi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ni,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Hd(e.nodeValue,n)),e||zi(t,!0)}else e=Zd(e).createTextNode(r),e[dt]=t,t.stateNode=e}return Hc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Hi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[dt]=t}else Ui(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Hc(t),e=!1}else n=Wi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(uo(t),t):(uo(t),null);if(t.flags&128)throw Error(i(558))}return Hc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Hi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[dt]=t}else Ui(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Hc(t),a=!1}else a=Wi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(uo(t),t):(uo(t),null)}return uo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Bc(t,t.updateQueue),Hc(t),null);case 4:return he(),e===null&&Md(t.stateNode.containerInfo),Hc(t),null;case 10:return Xi(t.type),Hc(t),null;case 19:if(M(fo),r=t.memoizedState,r===null)return Hc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Vc(r,!1);else{if(eu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=po(e),o!==null){for(t.flags|=128,Vc(r,!1),e=o.updateQueue,t.updateQueue=e,Bc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)di(n,e),n=n.sibling;return le(fo,fo.current&1|2),Fi&&Oi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ae()>du&&(t.flags|=128,a=!0,Vc(r,!1),t.lanes=4194304)}else{if(!a)if(e=po(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Bc(t,e),Vc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Fi)return Hc(t),null}else 2*Ae()-r.renderingStartTime>du&&n!==536870912&&(t.flags|=128,a=!0,Vc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Hc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ae(),e.sibling=null,n=fo.current,le(fo,a?n&1|2:n&1),Fi&&Oi(t,r.treeForkCount),e);case 22:case 23:return uo(t),ro(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Hc(t),t.subtreeFlags&6&&(t.flags|=8192)):Hc(t),n=t.updateQueue,n!==null&&Bc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&M(ya),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Xi(ca),Hc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Wc(e,t){switch(ji(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Xi(ca),he(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ve(t),null;case 31:if(t.memoizedState!==null){if(uo(t),t.alternate===null)throw Error(i(340));Ui()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(uo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ui()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return M(fo),null;case 4:return he(),null;case 10:return Xi(t.type),null;case 22:case 23:return uo(t),ro(),e!==null&&M(ya),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Xi(ca),null;case 25:return null;default:return null}}function Gc(e,t){switch(ji(t),t.tag){case 3:Xi(ca),he();break;case 26:case 27:case 5:ve(t);break;case 4:he();break;case 31:t.memoizedState!==null&&uo(t);break;case 13:uo(t);break;case 19:M(fo);break;case 10:Xi(t.type);break;case 22:case 23:uo(t),ro(),e!==null&&M(ya);break;case 24:Xi(ca)}}function Kc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){$u(t,t.return,e)}}function qc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){$u(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){$u(t,t.return,e)}}function Jc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Qa(t,n)}catch(t){$u(e,e.return,t)}}}function Yc(e,t,n){n.props=Zs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){$u(e,t,n)}}function Xc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){$u(e,t,n)}}function Zc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){$u(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){$u(e,t,n)}else n.current=null}function Qc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){$u(e,e.return,t)}}function $c(e,t,n){try{var r=e.stateNode;Kd(r,e.type,n,t),r[ft]=t}catch(t){$u(e,e.return,t)}}function el(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&lf(e.type)||e.tag===4}function tl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||el(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&lf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function nl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nn));else if(r!==4&&(r===27&&lf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(nl(e,t,n),e=e.sibling;e!==null;)nl(e,t,n),e=e.sibling}function rl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&lf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(rl(e,t,n),e=e.sibling;e!==null;)rl(e,t,n),e=e.sibling}function il(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Gd(t,r,n),t[dt]=e,t[ft]=n}catch(t){$u(e,e.return,t)}}var al=!1,ol=!1,sl=!1,cl=typeof WeakSet==`function`?WeakSet:Set,ll=null;function ul(e,t){if(e=e.containerInfo,Yd=vp,e=Dr(e),Or(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Xd={focusedElem:e,selectionRange:n},vp=!1,ll=t;ll!==null;)if(t=ll,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,ll=e;else for(;ll!==null;){switch(t=ll,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Zs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){$u(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ff(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ff(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,ll=e;break}ll=t.return}}function dl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Tl(e,n),r&4&&Kc(5,n);break;case 1:if(Tl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){$u(n,n.return,e)}else{var i=Zs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){$u(n,n.return,e)}}r&64&&Jc(n),r&512&&Xc(n,n.return);break;case 3:if(Tl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Qa(e,t)}catch(e){$u(n,n.return,e)}}break;case 27:t===null&&r&4&&il(n);case 26:case 5:Tl(e,n),t===null&&r&4&&Qc(n),r&512&&Xc(n,n.return);break;case 12:Tl(e,n);break;case 31:Tl(e,n),r&4&&_l(e,n);break;case 13:Tl(e,n),r&4&&vl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=rd.bind(null,n),vf(e,n))));break;case 22:if(r=n.memoizedState!==null||al,!r){t=t!==null&&t.memoizedState!==null||ol,i=al;var a=ol;al=r,(ol=t)&&!a?Dl(e,n,(n.subtreeFlags&8772)!=0):Tl(e,n),al=i,ol=a}break;case 30:break;default:Tl(e,n)}}function fl(e){var t=e.alternate;t!==null&&(e.alternate=null,fl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&yt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var pl=null,ml=!1;function hl(e,t,n){for(n=n.child;n!==null;)gl(e,t,n),n=n.sibling}function gl(e,t,n){if(Be&&typeof Be.onCommitFiberUnmount==`function`)try{Be.onCommitFiberUnmount(ze,n)}catch{}switch(n.tag){case 26:ol||Zc(n,t),hl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:ol||Zc(n,t);var r=pl,i=ml;lf(n.type)&&(pl=n.stateNode,ml=!1),hl(e,t,n),wf(n.stateNode),pl=r,ml=i;break;case 5:ol||Zc(n,t);case 6:if(r=pl,i=ml,pl=null,hl(e,t,n),pl=r,ml=i,pl!==null)if(ml)try{(pl.nodeType===9?pl.body:pl.nodeName===`HTML`?pl.ownerDocument.body:pl).removeChild(n.stateNode)}catch(e){$u(n,t,e)}else try{pl.removeChild(n.stateNode)}catch(e){$u(n,t,e)}break;case 18:pl!==null&&(ml?(e=pl,uf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Wp(e)):uf(pl,n.stateNode));break;case 4:r=pl,i=ml,pl=n.stateNode.containerInfo,ml=!0,hl(e,t,n),pl=r,ml=i;break;case 0:case 11:case 14:case 15:qc(2,n,t),ol||qc(4,n,t),hl(e,t,n);break;case 1:ol||(Zc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Yc(n,t,r)),hl(e,t,n);break;case 21:hl(e,t,n);break;case 22:ol=(r=ol)||n.memoizedState!==null,hl(e,t,n),ol=r;break;default:hl(e,t,n)}}function _l(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wp(e)}catch(e){$u(t,t.return,e)}}}function vl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wp(e)}catch(e){$u(t,t.return,e)}}function yl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new cl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new cl),t;default:throw Error(i(435,e.tag))}}function bl(e,t){var n=yl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=id.bind(null,e,t);t.then(r,r)}})}function xl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(lf(c.type)){pl=c.stateNode,ml=!1;break a}break;case 5:pl=c.stateNode,ml=!1;break a;case 3:case 4:pl=c.stateNode.containerInfo,ml=!0;break a}c=c.return}if(pl===null)throw Error(i(160));gl(o,s,a),pl=null,ml=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Cl(t,e),t=t.sibling}var Sl=null;function Cl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:xl(t,e),B(e),r&4&&(qc(3,e,e.return),Kc(3,e),qc(5,e,e.return));break;case 1:xl(t,e),B(e),r&512&&(ol||n===null||Zc(n,n.return)),r&64&&al&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=Sl;if(xl(t,e),B(e),r&512&&(ol||n===null||Zc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[vt]||o[dt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Gd(o,r,n),o[dt]=e,wt(o),r=o;break a;case`link`:var s=Qf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Gd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Qf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Gd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[dt]=e,wt(o),r=o}e.stateNode=r}else $f(a,e.type,e.stateNode);else e.stateNode=qf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&$c(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?$f(a,e.type,e.stateNode):qf(a,r,e.memoizedProps))}break;case 27:xl(t,e),B(e),r&512&&(ol||n===null||Zc(n,n.return)),n!==null&&r&4&&$c(e,e.memoizedProps,n.memoizedProps);break;case 5:if(xl(t,e),B(e),r&512&&(ol||n===null||Zc(n,n.return)),e.flags&32){a=e.stateNode;try{Jt(a,``)}catch(t){$u(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,$c(e,a,n===null?a:n.memoizedProps)),r&1024&&(sl=!0);break;case 6:if(xl(t,e),B(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){$u(e,e.return,t)}}break;case 3:if(Zf=null,a=Sl,Sl=Df(t.containerInfo),xl(t,e),Sl=a,B(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Wp(t.containerInfo)}catch(t){$u(e,e.return,t)}sl&&(sl=!1,wl(e));break;case 4:r=Sl,Sl=Df(e.stateNode.containerInfo),xl(t,e),B(e),Sl=r;break;case 12:xl(t,e),B(e);break;case 31:xl(t,e),B(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,bl(e,r)));break;case 13:xl(t,e),B(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(lu=Ae()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,bl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=al,d=ol;if(al=u||a,ol=d||l,xl(t,e),ol=d,al=u,B(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||al||ol||El(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){$u(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){$u(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?df(m,!0):df(l.stateNode,!1)}catch(e){$u(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,bl(e,n))));break;case 19:xl(t,e),B(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,bl(e,r)));break;case 30:break;case 21:break;default:xl(t,e),B(e)}}function B(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(el(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;rl(e,tl(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Jt(o,``),n.flags&=-33),rl(e,tl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;nl(e,tl(e),s);break;default:throw Error(i(161))}}catch(t){$u(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;wl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Tl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)dl(e,t.alternate,t),t=t.sibling}function El(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:qc(4,t,t.return),El(t);break;case 1:Zc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Yc(t,t.return,n),El(t);break;case 27:wf(t.stateNode);case 26:case 5:Zc(t,t.return),El(t);break;case 22:t.memoizedState===null&&El(t);break;case 30:El(t);break;default:El(t)}e=e.sibling}}function Dl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Dl(i,a,n),Kc(4,a);break;case 1:if(Dl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){$u(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Za(c[i],s)}catch(e){$u(r,r.return,e)}}n&&o&64&&Jc(a),Xc(a,a.return);break;case 27:il(a);case 26:case 5:Dl(i,a,n),n&&r===null&&o&4&&Qc(a),Xc(a,a.return);break;case 12:Dl(i,a,n);break;case 31:Dl(i,a,n),n&&o&4&&_l(i,a);break;case 13:Dl(i,a,n),n&&o&4&&vl(i,a);break;case 22:a.memoizedState===null&&Dl(i,a,n),Xc(a,a.return);break;case 30:break;default:Dl(i,a,n)}t=t.sibling}}function Ol(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ua(n))}function kl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ua(e))}function Al(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)jl(e,t,n,r),t=t.sibling}function jl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Al(e,t,n,r),i&2048&&Kc(9,t);break;case 1:Al(e,t,n,r);break;case 3:Al(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ua(e)));break;case 12:if(i&2048){Al(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){$u(t,t.return,e)}}else Al(e,t,n,r);break;case 31:Al(e,t,n,r);break;case 13:Al(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Al(e,t,n,r):(a._visibility|=2,Ml(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Al(e,t,n,r):Nl(e,t),i&2048&&Ol(o,t);break;case 24:Al(e,t,n,r),i&2048&&kl(t.alternate,t);break;default:Al(e,t,n,r)}}function Ml(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ml(a,o,s,c,i),Kc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ml(a,o,s,c,i)):u._visibility&2?Ml(a,o,s,c,i):Nl(a,o),i&&l&2048&&Ol(o.alternate,o);break;case 24:Ml(a,o,s,c,i),i&&l&2048&&kl(o.alternate,o);break;default:Ml(a,o,s,c,i)}t=t.sibling}}function Nl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Nl(n,r),i&2048&&Ol(r.alternate,r);break;case 24:Nl(n,r),i&2048&&kl(r.alternate,r);break;default:Nl(n,r)}t=t.sibling}}var Pl=8192;function Fl(e,t,n){if(e.subtreeFlags&Pl)for(e=e.child;e!==null;)Il(e,t,n),e=e.sibling}function Il(e,t,n){switch(e.tag){case 26:Fl(e,t,n),e.flags&Pl&&e.memoizedState!==null&&np(n,Sl,e.memoizedState,e.memoizedProps);break;case 5:Fl(e,t,n);break;case 3:case 4:var r=Sl;Sl=Df(e.stateNode.containerInfo),Fl(e,t,n),Sl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Pl,Pl=16777216,Fl(e,t,n),Pl=r):Fl(e,t,n));break;default:Fl(e,t,n)}}function Ll(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Rl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ll=r,Vl(r,e)}Ll(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)zl(e),e=e.sibling}function zl(e){switch(e.tag){case 0:case 11:case 15:Rl(e),e.flags&2048&&qc(9,e,e.return);break;case 3:Rl(e);break;case 12:Rl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Bl(e)):Rl(e);break;default:Rl(e)}}function Bl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ll=r,Vl(r,e)}Ll(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:qc(8,t,t.return),Bl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Bl(t));break;default:Bl(t)}e=e.sibling}}function Vl(e,t){for(;ll!==null;){var n=ll;switch(n.tag){case 0:case 11:case 15:qc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ua(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,ll=r;else a:for(n=e;ll!==null;){r=ll;var i=r.sibling,a=r.return;if(fl(r),r===n){ll=null;break a}if(i!==null){i.return=a,ll=i;break a}ll=a}}}var Hl={getCacheForType:function(e){var t=na(ca),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return na(ca).controller.signal}},Ul=typeof WeakMap==`function`?WeakMap:Map,Wl=0,Gl=null,Kl=null,ql=0,Jl=0,Yl=null,Xl=!1,Zl=!1,Ql=!1,$l=0,eu=0,tu=0,nu=0,ru=0,iu=0,au=0,ou=null,su=null,cu=!1,lu=0,uu=0,du=1/0,fu=null,pu=null,mu=0,hu=null,gu=null,_u=0,vu=0,yu=null,bu=null,xu=0,Su=null;function Cu(){return Wl&2&&ql!==0?ql&-ql:A.T===null?ct():bd()}function wu(){if(iu===0)if(!(ql&536870912)||Fi){var e=qe;qe<<=1,!(qe&3932160)&&(qe=262144),iu=e}else iu=536870912;return e=io.current,e!==null&&(e.flags|=32),iu}function Tu(e,t,n){(e===Gl&&(Jl===2||Jl===9)||e.cancelPendingCommit!==null)&&(ju(e,0),V(e,ql,iu,!1)),tt(e,n),(!(Wl&2)||e!==Gl)&&(e===Gl&&(!(Wl&2)&&(nu|=n),eu===4&&V(e,ql,iu,!1)),fd(e))}function Eu(e,t,n){if(Wl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Ze(e,t),a=r?zu(e,t):Lu(e,t,!0),o=r;do{if(a===0){Zl&&!r&&V(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Ou(n)){a=Lu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ou;var l=c.current.memoizedState.isDehydrated;if(l&&(ju(c,s).flags|=256),s=Lu(c,s,!1),s!==2){if(Ql&&!l){c.errorRecoveryDisabledLanes|=o,nu|=o,a=4;break a}o=su,su=a,o!==null&&(su===null?su=o:su.push.apply(su,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){ju(e,0),V(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:V(r,t,iu,!Xl);break a;case 2:su=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=lu+300-Ae(),10<a)){if(V(r,t,iu,!Xl),Xe(r,0,!0)!==0)break a;_u=t,r.timeoutHandle=rf(Du.bind(null,r,n,su,fu,cu,t,iu,nu,au,Xl,o,`Throttled`,-0,0),a);break a}Du(r,n,su,fu,cu,t,iu,nu,au,Xl,o,null,-0,0)}}break}while(1);fd(e)}function Du(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:nn},Il(t,a,d);var m=(a&62914560)===a?lu-Ae():(a&4194048)===a?uu-Ae():0;if(m=ip(d,m),m!==null){_u=a,e.cancelPendingCommit=m(Gu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),V(e,a,o,!l);return}}Gu(e,t,a,n,r,i,o,s,c)}function Ou(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Cr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function V(e,t,n,r){t&=~ru,t&=~nu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-He(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&rt(e,n,t)}function ku(){return Wl&6?!0:(pd(0,!1),!1)}function Au(){if(Kl!==null){if(Jl===0)var e=Kl.return;else e=Kl,Ji=qi=null,No(e),Na=null,Pa=0,e=Kl;for(;e!==null;)Gc(e.alternate,e),e=e.return;Kl=null}}function ju(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,af(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),_u=0,Au(),Gl=e,Kl=n=ui(e.current,null),ql=t,Jl=0,Yl=null,Xl=!1,Zl=Ze(e,t),Ql=!1,au=iu=ru=nu=tu=eu=0,su=ou=null,cu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-He(r),a=1<<i;t|=e[i],r&=~a}return $l=t,ei(),n}function Mu(e,t){ho=null,A.H=Us,t===Ca||t===Ta?(t=ja(),Jl=3):t===wa?(t=ja(),Jl=4):Jl=t===oc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Yl=t,Kl===null&&(eu=1,tc(e,vi(t,e.current)))}function Nu(){var e=io.current;return e===null?!0:(ql&4194048)===ql?ao===null:(ql&62914560)===ql||ql&536870912?e===ao:!1}function Pu(){var e=A.H;return A.H=Us,e===null?Us:e}function Fu(){var e=A.A;return A.A=Hl,e}function Iu(){eu=4,Xl||(ql&4194048)!==ql&&io.current!==null||(Zl=!0),!(tu&134217727)&&!(nu&134217727)||Gl===null||V(Gl,ql,iu,!1)}function Lu(e,t,n){var r=Wl;Wl|=2;var i=Pu(),a=Fu();(Gl!==e||ql!==t)&&(fu=null,ju(e,t)),t=!1;var o=eu;a:do try{if(Jl!==0&&Kl!==null){var s=Kl,c=Yl;switch(Jl){case 8:Au(),o=6;break a;case 3:case 2:case 9:case 6:io.current===null&&(t=!0);var l=Jl;if(Jl=0,Yl=null,H(e,s,c,l),n&&Zl){o=0;break a}break;default:l=Jl,Jl=0,Yl=null,H(e,s,c,l)}}Ru(),o=eu;break}catch(t){Mu(e,t)}while(1);return t&&e.shellSuspendCounter++,Ji=qi=null,Wl=r,A.H=i,A.A=a,Kl===null&&(Gl=null,ql=0,ei()),o}function Ru(){for(;Kl!==null;)Vu(Kl)}function zu(e,t){var n=Wl;Wl|=2;var r=Pu(),a=Fu();Gl!==e||ql!==t?(fu=null,du=Ae()+500,ju(e,t)):Zl=Ze(e,t);a:do try{if(Jl!==0&&Kl!==null){t=Kl;var o=Yl;b:switch(Jl){case 1:Jl=0,Yl=null,H(e,t,o,1);break;case 2:case 9:if(Da(o)){Jl=0,Yl=null,Hu(t);break}t=function(){Jl!==2&&Jl!==9||Gl!==e||(Jl=7),fd(e)},o.then(t,t);break a;case 3:Jl=7;break a;case 4:Jl=5;break a;case 7:Da(o)?(Jl=0,Yl=null,Hu(t)):(Jl=0,Yl=null,H(e,t,o,7));break;case 5:var s=null;switch(Kl.tag){case 26:s=Kl.memoizedState;case 5:case 27:var c=Kl;if(s?tp(s):c.stateNode.complete){Jl=0,Yl=null;var l=c.sibling;if(l!==null)Kl=l;else{var u=c.return;u===null?Kl=null:(Kl=u,Uu(u))}break b}}Jl=0,Yl=null,H(e,t,o,5);break;case 6:Jl=0,Yl=null,H(e,t,o,6);break;case 8:Au(),eu=6;break a;default:throw Error(i(462))}}Bu();break}catch(t){Mu(e,t)}while(1);return Ji=qi=null,A.H=r,A.A=a,Wl=n,Kl===null?(Gl=null,ql=0,ei(),eu):0}function Bu(){for(;Kl!==null&&!Oe();)Vu(Kl)}function Vu(e){var t=Ic(e.alternate,e,$l);e.memoizedProps=e.pendingProps,t===null?Uu(e):Kl=t}function Hu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=bc(n,t,t.pendingProps,t.type,void 0,ql);break;case 11:t=bc(n,t,t.pendingProps,t.type.render,t.ref,ql);break;case 5:No(t);default:Gc(n,t),t=Kl=di(t,$l),t=Ic(n,t,$l)}e.memoizedProps=e.pendingProps,t===null?Uu(e):Kl=t}function H(e,t,n,r){Ji=qi=null,No(t),Na=null,Pa=0;var i=t.return;try{if(ac(e,i,t,n,ql)){eu=1,tc(e,vi(n,e.current)),Kl=null;return}}catch(t){if(i!==null)throw Kl=i,t;eu=1,tc(e,vi(n,e.current)),Kl=null;return}t.flags&32768?(Fi||r===1?e=!0:Zl||ql&536870912?e=!1:(Xl=e=!0,(r===2||r===9||r===3||r===6)&&(r=io.current,r!==null&&r.tag===13&&(r.flags|=16384))),Wu(t,e)):Uu(t)}function Uu(e){var t=e;do{if(t.flags&32768){Wu(t,Xl);return}e=t.return;var n=Uc(t.alternate,t,$l);if(n!==null){Kl=n;return}if(t=t.sibling,t!==null){Kl=t;return}Kl=t=e}while(t!==null);eu===0&&(eu=5)}function Wu(e,t){do{var n=Wc(e.alternate,e);if(n!==null){n.flags&=32767,Kl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Kl=e;return}Kl=e=n}while(e!==null);eu=6,Kl=null}function Gu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Xu();while(mu!==0);if(Wl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=$r,nt(e,n,o,s,c,l),e===Gl&&(Kl=Gl=null,ql=0),gu=t,hu=e,_u=n,vu=o,yu=a,bu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ad(Pe,function(){return Zu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=A.T,A.T=null,a=j.p,j.p=2,s=Wl,Wl|=4;try{ul(e,t,n)}finally{Wl=s,j.p=a,A.T=r}}mu=1,Ku(),qu(),Ju()}}function Ku(){if(mu===1){mu=0;var e=hu,t=gu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=A.T,A.T=null;var r=j.p;j.p=2;var i=Wl;Wl|=4;try{Cl(t,e);var a=Xd,o=Dr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Er(s.ownerDocument.documentElement,s)){if(c!==null&&Or(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=R(s,h),v=R(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vp=!!Yd,Xd=Yd=null}finally{Wl=i,j.p=r,A.T=n}}e.current=t,mu=2}}function qu(){if(mu===2){mu=0;var e=hu,t=gu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=A.T,A.T=null;var r=j.p;j.p=2;var i=Wl;Wl|=4;try{dl(e,t.alternate,t)}finally{Wl=i,j.p=r,A.T=n}}mu=3}}function Ju(){if(mu===4||mu===3){mu=0,ke();var e=hu,t=gu,n=_u,r=bu;t.subtreeFlags&10256||t.flags&10256?mu=5:(mu=0,gu=hu=null,Yu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(pu=null),st(n),t=t.stateNode,Be&&typeof Be.onCommitFiberRoot==`function`)try{Be.onCommitFiberRoot(ze,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=A.T,i=j.p,j.p=2,A.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{A.T=t,j.p=i}}_u&3&&Xu(),fd(e),i=e.pendingLanes,n&261930&&i&42?e===Su?xu++:(xu=0,Su=e):xu=0,pd(0,!1)}}function Yu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ua(t)))}function Xu(){return Ku(),qu(),Ju(),Zu()}function Zu(){if(mu!==5)return!1;var e=hu,t=vu;vu=0;var n=st(_u),r=A.T,a=j.p;try{j.p=32>n?32:n,A.T=null,n=yu,yu=null;var o=hu,s=_u;if(mu=0,gu=hu=null,_u=0,Wl&6)throw Error(i(331));var c=Wl;if(Wl|=4,zl(o.current),jl(o,o.current,s,n),Wl=c,pd(0,!1),Be&&typeof Be.onPostCommitFiberRoot==`function`)try{Be.onPostCommitFiberRoot(ze,o)}catch{}return!0}finally{j.p=a,A.T=r,Yu(e,t)}}function Qu(e,t,n){t=vi(n,t),t=nc(e.stateNode,t,2),e=Ga(e,t,2),e!==null&&(tt(e,2),fd(e))}function $u(e,t,n){if(e.tag===3)Qu(e,e,n);else for(;t!==null;){if(t.tag===3){Qu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(pu===null||!pu.has(r))){e=vi(n,e),n=rc(2),r=Ga(t,n,2),r!==null&&(ic(n,r,t,e),tt(r,2),fd(r));break}}t=t.return}}function ed(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ul;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ql=!0,i.add(n),e=td.bind(null,e,t,n),t.then(e,e))}function td(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Gl===e&&(ql&n)===n&&(eu===4||eu===3&&(ql&62914560)===ql&&300>Ae()-lu?!(Wl&2)&&ju(e,0):ru|=n,au===ql&&(au=0)),fd(e)}function nd(e,t){t===0&&(t=$e()),e=ri(e,t),e!==null&&(tt(e,t),fd(e))}function rd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),nd(e,n)}function id(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),nd(e,n)}function ad(e,t){return Ee(e,t)}var od=null,sd=null,cd=!1,ld=!1,ud=!1,dd=0;function fd(e){e!==sd&&e.next===null&&(sd===null?od=sd=e:sd=sd.next=e),ld=!0,cd||(cd=!0,yd())}function pd(e,t){if(!ud&&ld){ud=!0;do for(var n=!1,r=od;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-He(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,vd(r,a))}else a=ql,a=Xe(r,r===Gl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ze(r,a)||(n=!0,vd(r,a));r=r.next}while(n);ud=!1}}function md(){hd()}function hd(){ld=cd=!1;var e=0;dd!==0&&nf()&&(e=dd);for(var t=Ae(),n=null,r=od;r!==null;){var i=r.next,a=gd(r,t);a===0?(r.next=null,n===null?od=i:n.next=i,i===null&&(sd=n)):(n=r,(e!==0||a&3)&&(ld=!0)),r=i}mu!==0&&mu!==5||pd(e,!1),dd!==0&&(dd=0)}function gd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-He(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Qe(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Gl,n=ql,n=Xe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Jl===2||Jl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&De(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&De(r),st(n)){case 2:case 8:n=Ne;break;case 32:n=Pe;break;case 268435456:n=Ie;break;default:n=Pe}return r=_d.bind(null,e),n=Ee(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&De(r),e.callbackPriority=2,e.callbackNode=null,2}function _d(e,t){if(mu!==0&&mu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Xu()&&e.callbackNode!==n)return null;var r=ql;return r=Xe(e,e===Gl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Eu(e,r,t),gd(e,Ae()),e.callbackNode!=null&&e.callbackNode===n?_d.bind(null,e):null)}function vd(e,t){if(Xu())return null;Eu(e,t,!0)}function yd(){sf(function(){Wl&6?Ee(Me,md):hd()})}function bd(){if(dd===0){var e=pa;e===0&&(e=Ke,Ke<<=1,!(Ke&261888)&&(Ke=256)),dd=e}return dd}function xd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:tn(``+e)}function Sd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Cd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=xd((i[ft]||null).action),o=r.submitter;o&&(t=(t=o[ft]||null)?xd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(dd!==0){var e=o?Sd(i,o):new FormData(i);ks(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?Sd(i,o):new FormData(i),ks(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var wd=0;wd<Jr.length;wd++){var Td=Jr[wd];Yr(Td.toLowerCase(),`on`+(Td[0].toUpperCase()+Td.slice(1)))}Yr(Br,`onAnimationEnd`),Yr(Vr,`onAnimationIteration`),Yr(Hr,`onAnimationStart`),Yr(`dblclick`,`onDoubleClick`),Yr(`focusin`,`onFocus`),Yr(`focusout`,`onBlur`),Yr(Ur,`onTransitionRun`),Yr(Wr,`onTransitionStart`),Yr(Gr,`onTransitionCancel`),Yr(Kr,`onTransitionEnd`),Ot(`onMouseEnter`,[`mouseout`,`mouseover`]),Ot(`onMouseLeave`,[`mouseout`,`mouseover`]),Ot(`onPointerEnter`,[`pointerout`,`pointerover`]),Ot(`onPointerLeave`,[`pointerout`,`pointerover`]),Dt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Dt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Dt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Dt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Dt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Dt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Ed=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Dd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Ed));function Od(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Xr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Xr(e)}i.currentTarget=null,a=c}}}}function kd(e,t){var n=t[mt];n===void 0&&(n=t[mt]=new Set);var r=e+`__bubble`;n.has(r)||(Nd(t,e,2,!1),n.add(r))}function Ad(e,t,n){var r=0;t&&(r|=4),Nd(n,e,r,t)}var jd=`_reactListening`+Math.random().toString(36).slice(2);function Md(e){if(!e[jd]){e[jd]=!0,Tt.forEach(function(t){t!==`selectionchange`&&(Dd.has(t)||Ad(t,!1,e),Ad(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[jd]||(t[jd]=!0,Ad(`selectionchange`,!1,t))}}function Nd(e,t,n,r){switch(Tp(t)){case 2:var i=yp;break;case 8:i=bp;break;default:i=xp}n=i.bind(null,t,n,e),i=void 0,!fn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Pd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=bt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}ln(function(){var r=a,i=an(n),s=[];a:{var c=qr.get(e);if(c!==void 0){var l=Cn,u=e;switch(e){case`keypress`:if(vn(n)===0)break a;case`keydown`:case`keyup`:l=Vn;break;case`focusin`:u=`focus`,l=Mn;break;case`focusout`:u=`blur`,l=Mn;break;case`beforeblur`:case`afterblur`:l=Mn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=An;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=jn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Un;break;case Br:case Vr:case Hr:l=Nn;break;case Kr:l=Wn;break;case`scroll`:case`scrollend`:l=Tn;break;case`wheel`:l=Gn;break;case`copy`:case`cut`:case`paste`:l=Pn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Hn;break;case`toggle`:case`beforetoggle`:l=Kn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=un(m,p),g!=null&&d.push(Fd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==rn&&(u=n.relatedTarget||n.fromElement)&&(bt(u)||u[pt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?bt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=An,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Hn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:St(l),h=u==null?c:St(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,bt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ld,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Rd(s,c,l,d,!1),u!==null&&f!==null&&Rd(s,f,u,d,!0)}}a:{if(c=r?St(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=fr;else if(or(c))if(pr)v=xr;else{v=yr;var y=vr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Qt(r.elementType)&&(v=fr):v=br;if(v&&=v(e,r)){sr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Wt(c,`number`,c.value)}switch(y=r?St(r):window,e){case`focusin`:(or(y)||y.contentEditable===`true`)&&(Ar=y,jr=r,Mr=null);break;case`focusout`:Mr=jr=Ar=null;break;case`mousedown`:Nr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Nr=!1,Pr(s,n,i);break;case`selectionchange`:if(kr)break;case`keydown`:case`keyup`:Pr(s,n,i)}var b;if(Jn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else nr?er(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Zn&&n.locale!==`ko`&&(nr||x!==`onCompositionStart`?x===`onCompositionEnd`&&nr&&(b=_n()):(mn=i,hn=`value`in mn?mn.value:mn.textContent,nr=!0)),y=Id(r,x),0<y.length&&(x=new Fn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=tr(n),b!==null&&(x.data=b)))),(b=Xn?rr(e,n):ir(e,n))&&(x=Id(r,`onBeforeInput`),0<x.length&&(y=new Fn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Cd(s,e,r,n,i)}Od(s,t)})}function Fd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Id(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=un(e,n),i!=null&&r.unshift(Fd(e,i,a)),i=un(e,t),i!=null&&r.push(Fd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ld(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Rd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=un(n,a),l!=null&&o.unshift(Fd(n,l,c))):i||(l=un(n,a),l!=null&&o.push(Fd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var zd=/\r\n?/g,Bd=/\u0000|\uFFFD/g;function Vd(e){return(typeof e==`string`?e:``+e).replace(zd,`
|
|
9
|
+
`).replace(Bd,``)}function Hd(e,t){return t=Vd(t),Vd(e)===t}function Ud(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Jt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Jt(e,``+r);break;case`className`:Nt(e,`class`,r);break;case`tabIndex`:Nt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Nt(e,n,r);break;case`style`:Zt(e,r,o);break;case`data`:if(t!==`object`){Nt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=tn(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Ud(e,t,`name`,a.name,a,null),Ud(e,t,`formEncType`,a.formEncType,a,null),Ud(e,t,`formMethod`,a.formMethod,a,null),Ud(e,t,`formTarget`,a.formTarget,a,null)):(Ud(e,t,`encType`,a.encType,a,null),Ud(e,t,`method`,a.method,a,null),Ud(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=tn(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=nn);break;case`onScroll`:r!=null&&kd(`scroll`,e);break;case`onScrollEnd`:r!=null&&kd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=tn(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:kd(`beforetoggle`,e),kd(`toggle`,e),P(e,`popover`,r);break;case`xlinkActuate`:Pt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Pt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Pt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Pt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Pt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Pt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Pt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Pt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Pt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:P(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=$t.get(n)||n,P(e,n,r))}}function Wd(e,t,n,r,a,o){switch(n){case`style`:Zt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Jt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Jt(e,``+r);break;case`onScroll`:r!=null&&kd(`scroll`,e);break;case`onScrollEnd`:r!=null&&kd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=nn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Et.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[ft]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):P(e,n,r)}}}function Gd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:kd(`error`,e),kd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Ud(e,t,o,s,n,null)}}a&&Ud(e,t,`srcSet`,n.srcSet,n,null),r&&Ud(e,t,`src`,n.src,n,null);return;case`input`:kd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Ud(e,t,r,d,n,null)}}Ut(e,o,c,l,u,s,a,!1);return;case`select`:for(a in kd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Ud(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Gt(e,!!r,n,!0):Gt(e,!!r,t,!1);return;case`textarea`:for(s in kd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Ud(e,t,s,c,n,null)}qt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Ud(e,t,l,r,n,null)}return;case`dialog`:kd(`beforetoggle`,e),kd(`toggle`,e),kd(`cancel`,e),kd(`close`,e);break;case`iframe`:case`object`:kd(`load`,e);break;case`video`:case`audio`:for(r=0;r<Ed.length;r++)kd(Ed[r],e);break;case`image`:kd(`error`,e),kd(`load`,e);break;case`details`:kd(`toggle`,e);break;case`embed`:case`source`:case`link`:kd(`error`,e),kd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Ud(e,t,u,r,n,null)}return;default:if(Qt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Wd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Ud(e,t,c,r,n,null))}function Kd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Ud(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Ud(e,t,p,m,r,f)}}Ht(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Ud(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Ud(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Gt(e,!!n,n?[]:``,!1):Gt(e,!!n,t,!0)):Gt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Ud(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Ud(e,t,s,a,r,o)}Kt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Ud(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Ud(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Ud(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Ud(e,t,u,p,r,m)}return;default:if(Qt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Wd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Wd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Ud(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Ud(e,t,f,p,r,m)}function qd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Jd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&qd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&qd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Yd=null,Xd=null;function Zd(e){return e.nodeType===9?e:e.ownerDocument}function Qd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function $d(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function ef(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var tf=null;function nf(){var e=window.event;return e&&e.type===`popstate`?e===tf?!1:(tf=e,!0):(tf=null,!1)}var rf=typeof setTimeout==`function`?setTimeout:void 0,af=typeof clearTimeout==`function`?clearTimeout:void 0,of=typeof Promise==`function`?Promise:void 0,sf=typeof queueMicrotask==`function`?queueMicrotask:of===void 0?rf:function(e){return of.resolve(null).then(e).catch(cf)};function cf(e){setTimeout(function(){throw e})}function lf(e){return e===`head`}function uf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)wf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,wf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[vt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&wf(e.ownerDocument.body);n=i}while(n);Wp(t)}function df(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ff(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ff(n),yt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function pf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[vt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=yf(e.nextSibling),e===null)break}return null}function mf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=yf(e.nextSibling),e===null))return null;return e}function hf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=yf(e.nextSibling),e===null))return null;return e}function gf(e){return e.data===`$?`||e.data===`$~`}function _f(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function vf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function yf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var bf=null;function xf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return yf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Sf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Cf(e,t,n){switch(t=Zd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function wf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);yt(e)}var Tf=new Map,Ef=new Set;function Df(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Of=j.d;j.d={f:kf,r:Af,D:Nf,C:Pf,L:Ff,m:If,X:Rf,S:Lf,M:zf};function kf(){var e=Of.f(),t=ku();return e||t}function Af(e){var t=xt(e);t!==null&&t.tag===5&&t.type===`form`?js(t):Of.r(e)}var jf=typeof document>`u`?null:document;function Mf(e,t,n){var r=jf;if(r&&typeof t==`string`&&t){var i=Vt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Ef.has(i)||(Ef.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Gd(t,`link`,e),wt(t),r.head.appendChild(t)))}}function Nf(e){Of.D(e),Mf(`dns-prefetch`,e,null)}function Pf(e,t){Of.C(e,t),Mf(`preconnect`,e,t)}function Ff(e,t,n){Of.L(e,t,n);var r=jf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Vt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Vt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Vt(n.imageSizes)+`"]`)):i+=`[href="`+Vt(e)+`"]`;var a=i;switch(t){case`style`:a=Vf(e);break;case`script`:a=Gf(e)}Tf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Tf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Hf(a))||t===`script`&&r.querySelector(Kf(a))||(t=r.createElement(`link`),Gd(t,`link`,e),wt(t),r.head.appendChild(t)))}}function If(e,t){Of.m(e,t);var n=jf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Vt(r)+`"][href="`+Vt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Gf(e)}if(!Tf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),Tf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Kf(a)))return}r=n.createElement(`link`),Gd(r,`link`,e),wt(r),n.head.appendChild(r)}}}function Lf(e,t,n){Of.S(e,t,n);var r=jf;if(r&&e){var i=Ct(r).hoistableStyles,a=Vf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Hf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Tf.get(a))&&Yf(e,n);var c=o=r.createElement(`link`);wt(c),Gd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Jf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Rf(e,t){Of.X(e,t);var n=jf;if(n&&e){var r=Ct(n).hoistableScripts,i=Gf(e),a=r.get(i);a||(a=n.querySelector(Kf(i)),a||(e=f({src:e,async:!0},t),(t=Tf.get(i))&&Xf(e,t),a=n.createElement(`script`),wt(a),Gd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function zf(e,t){Of.M(e,t);var n=jf;if(n&&e){var r=Ct(n).hoistableScripts,i=Gf(e),a=r.get(i);a||(a=n.querySelector(Kf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=Tf.get(i))&&Xf(e,t),a=n.createElement(`script`),wt(a),Gd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Bf(e,t,n,r){var a=(a=fe.current)?Df(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Vf(n.href),n=Ct(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Vf(n.href);var o=Ct(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Hf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Tf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Tf.set(e,n),o||Wf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Gf(n),n=Ct(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Vf(e){return`href="`+Vt(e)+`"`}function Hf(e){return`link[rel="stylesheet"][`+e+`]`}function Uf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Wf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Gd(t,`link`,n),wt(t),e.head.appendChild(t))}function Gf(e){return`[src="`+Vt(e)+`"]`}function Kf(e){return`script[async]`+e}function qf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Vt(n.href)+`"]`);if(r)return t.instance=r,wt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),wt(r),Gd(r,`style`,a),Jf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Vf(n.href);var o=e.querySelector(Hf(a));if(o)return t.state.loading|=4,t.instance=o,wt(o),o;r=Uf(n),(a=Tf.get(a))&&Yf(r,a),o=(e.ownerDocument||e).createElement(`link`),wt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Gd(o,`link`,r),t.state.loading|=4,Jf(o,n.precedence,e),t.instance=o;case`script`:return o=Gf(n.src),(a=e.querySelector(Kf(o)))?(t.instance=a,wt(a),a):(r=n,(a=Tf.get(o))&&(r=f({},n),Xf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),wt(a),Gd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Jf(r,n.precedence,e));return t.instance}function Jf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Yf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Xf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Zf=null;function Qf(e,t,n){if(Zf===null){var r=new Map,i=Zf=new Map;i.set(n,r)}else i=Zf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[vt]||a[dt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function $f(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function ep(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function tp(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function np(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Vf(r.href),a=t.querySelector(Hf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ap.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,wt(a);return}a=t.ownerDocument||t,r=Uf(r),(i=Tf.get(i))&&Yf(r,i),a=a.createElement(`link`),wt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Gd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ap.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var rp=0;function ip(e,t){return e.stylesheets&&e.count===0&&sp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&rp===0&&(rp=62500*Jd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>rp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function ap(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)sp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var op=null;function sp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,op=new Map,t.forEach(cp,e),op=null,ap.call(e))}function cp(e,t){if(!(t.state.loading&4)){var n=op.get(e);if(n)var r=n.get(null);else{n=new Map,op.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ap.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lp={$$typeof:x,Provider:null,Consumer:null,_currentValue:ae,_currentValue2:ae,_threadCount:0};function up(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0),this.hiddenUpdates=et(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function dp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new up(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ci(3,null,null,t),e.current=a,a.stateNode=e,t=la(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ha(a),e}function fp(e){return e?(e=oi,e):oi}function pp(e,t,n,r,i,a){i=fp(i),r.context===null?r.context=i:r.pendingContext=i,r=Wa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ga(e,r,t),n!==null&&(Tu(n,e,t),Ka(n,e,t))}function mp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hp(e,t){mp(e,t),(e=e.alternate)&&mp(e,t)}function gp(e){if(e.tag===13||e.tag===31){var t=ri(e,67108864);t!==null&&Tu(t,e,67108864),hp(e,67108864)}}function _p(e){if(e.tag===13||e.tag===31){var t=Cu();t=ot(t);var n=ri(e,t);n!==null&&Tu(n,e,t),hp(e,t)}}var vp=!0;function yp(e,t,n,r){var i=A.T;A.T=null;var a=j.p;try{j.p=2,xp(e,t,n,r)}finally{j.p=a,A.T=i}}function bp(e,t,n,r){var i=A.T;A.T=null;var a=j.p;try{j.p=8,xp(e,t,n,r)}finally{j.p=a,A.T=i}}function xp(e,t,n,r){if(vp){var i=Sp(r);if(i===null)Pd(e,t,r,Cp,n),Pp(e,r);else if(Ip(i,e,t,n,r))r.stopPropagation();else if(Pp(e,r),t&4&&-1<Np.indexOf(e)){for(;i!==null;){var a=xt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ye(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-He(o);s.entanglements[1]|=c,o&=~c}fd(a),!(Wl&6)&&(du=Ae()+500,pd(0,!1))}}break;case 31:case 13:s=ri(a,2),s!==null&&Tu(s,a,2),ku(),hp(a,2)}if(a=Sp(r),a===null&&Pd(e,t,r,Cp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Pd(e,t,r,null,n)}}function Sp(e){return e=an(e),wp(e)}var Cp=null;function wp(e){if(Cp=null,e=bt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Cp=e,null}function Tp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(je()){case Me:return 2;case Ne:return 8;case Pe:case Fe:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var Ep=!1,Dp=null,Op=null,kp=null,Ap=new Map,jp=new Map,Mp=[],Np=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Pp(e,t){switch(e){case`focusin`:case`focusout`:Dp=null;break;case`dragenter`:case`dragleave`:Op=null;break;case`mouseover`:case`mouseout`:kp=null;break;case`pointerover`:case`pointerout`:Ap.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jp.delete(t.pointerId)}}function Fp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=xt(t),t!==null&&gp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ip(e,t,n,r,i){switch(t){case`focusin`:return Dp=Fp(Dp,e,t,n,r,i),!0;case`dragenter`:return Op=Fp(Op,e,t,n,r,i),!0;case`mouseover`:return kp=Fp(kp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ap.set(a,Fp(Ap.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jp.set(a,Fp(jp.get(a)||null,e,t,n,r,i)),!0}return!1}function Lp(e){var t=bt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,lt(e.priority,function(){_p(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,lt(e.priority,function(){_p(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);rn=r,n.target.dispatchEvent(r),rn=null}else return t=xt(n),t!==null&&gp(t),e.blockedOn=n,!1;t.shift()}return!0}function zp(e,t,n){Rp(e)&&n.delete(t)}function Bp(){Ep=!1,Dp!==null&&Rp(Dp)&&(Dp=null),Op!==null&&Rp(Op)&&(Op=null),kp!==null&&Rp(kp)&&(kp=null),Ap.forEach(zp),jp.forEach(zp)}function Vp(e,n){e.blockedOn===n&&(e.blockedOn=null,Ep||(Ep=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bp)))}var Hp=null;function Up(e){Hp!==e&&(Hp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hp===e&&(Hp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wp(r||n)===null)continue;break}var a=xt(n);a!==null&&(e.splice(t,3),t-=3,ks(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wp(e){function t(t){return Vp(t,e)}Dp!==null&&Vp(Dp,e),Op!==null&&Vp(Op,e),kp!==null&&Vp(kp,e),Ap.forEach(t),jp.forEach(t);for(var n=0;n<Mp.length;n++){var r=Mp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mp.length&&(n=Mp[0],n.blockedOn===null);)Lp(n),n.blockedOn===null&&Mp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ft]||null;if(typeof a==`function`)o||Up(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ft]||null)s=o.formAction;else if(wp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Up(n)}}}function Gp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kp(e){this._internalRoot=e}qp.prototype.render=Kp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;pp(n,Cu(),e,t,null,null)},qp.prototype.unmount=Kp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;pp(e.current,2,null,e,null,null),ku(),t[pt]=null}};function qp(e){this._internalRoot=e}qp.prototype.unstable_scheduleHydration=function(e){if(e){var t=ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mp.length&&t!==0&&t<Mp[n].priority;n++);Mp.splice(n,0,e),n===0&&Lp(e)}};var Jp=n.version;if(Jp!==`19.2.1`)throw Error(i(527,Jp,`19.2.1`));j.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var Yp={bundleType:0,version:`19.2.1`,rendererPackageName:`react-dom`,currentDispatcherRef:A,reconcilerVersion:`19.2.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xp.isDisabled&&Xp.supportsFiber)try{ze=Xp.inject(Yp),Be=Xp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Qs,s=$s,c=ec;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=dp(e,1,!1,null,null,n,r,null,o,s,c,Gp),e[pt]=t.current,Md(e),new Kp(t)}})),ve=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=_e()})),N=e(g(),1),ye=x(),be=`Collapsible`,[xe,Se]=j(be),[Ce,we]=xe(be),Te=N.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=se({prop:r,defaultProp:i??!1,onChange:o,caller:be});return(0,ye.jsx)(Ce,{scope:n,disabled:a,contentId:ue(),open:c,onOpenToggle:N.useCallback(()=>l(e=>!e),[l]),children:(0,ye.jsx)(ie.div,{"data-state":je(c),"data-disabled":a?``:void 0,...s,ref:t})})});Te.displayName=be;var Ee=`CollapsibleTrigger`,De=N.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=we(Ee,n);return(0,ye.jsx)(ie.button,{type:`button`,"aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":je(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:oe(e.onClick,i.onOpenToggle)})});De.displayName=Ee;var Oe=`CollapsibleContent`,ke=N.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=we(Oe,e.__scopeCollapsible);return(0,ye.jsx)(ae,{present:n||i.open,children:({present:e})=>(0,ye.jsx)(Ae,{...r,ref:t,present:e})})});ke.displayName=Oe;var Ae=N.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=we(Oe,n),[s,c]=N.useState(r),l=N.useRef(null),u=re(t,l),d=N.useRef(0),f=d.current,p=N.useRef(0),m=p.current,h=o.open||s,g=N.useRef(h),_=N.useRef(void 0);return N.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),A(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,ye.jsx)(ie.div,{"data-state":je(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})});function je(e){return e?`open`:`closed`}var Me=Te,Ne=M(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Pe=M(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Fe=`system`,Ie=`sqlrooms-ui-theme`,Le=(0,N.createContext)({theme:Fe,resolvedTheme:Be(Fe),setTheme:()=>null});function Re(e){return e===`light`||e===`dark`||e===`system`}function ze({defaultTheme:e=Fe,storageKey:t=Ie}={}){if(typeof window>`u`)return e;try{let n=window.localStorage.getItem(t);return Re(n)?n:e}catch{return e}}function Be(e){return e===`system`?typeof window>`u`||typeof window.matchMedia!=`function`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}function Ve(e={}){return Be(ze(e))}function He({children:e,defaultTheme:t=Fe,storageKey:n=Ie,...r}){let[i,a]=(0,N.useState)(()=>ze({defaultTheme:t,storageKey:n})),[o,s]=(0,N.useState)(()=>Be(i));(typeof window<`u`?N.useLayoutEffect:N.useEffect)(()=>{if(typeof window>`u`)return;let e=window.document.documentElement,t=Be(i);if(e.classList.remove(`light`,`dark`),e.classList.add(t),s(t),i===`system`&&typeof window.matchMedia==`function`){let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{let t=Be(i);e.classList.remove(`light`,`dark`),e.classList.add(t),s(t)};return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)}},[i]);let c={theme:i,resolvedTheme:o,setTheme:e=>{if(typeof window<`u`)try{window.localStorage.setItem(n,e)}catch{}a(e)}};return(0,ye.jsx)(Le.Provider,{...r,value:c,children:e})}var Ue=()=>{let e=(0,N.useContext)(Le);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},We=({text:e,variant:t=`ghost`,size:n=`icon`,className:r,tooltipLabel:i=`Copy to clipboard`,ariaLabel:a,durationMs:o=1500,disabled:s=!1,onCopied:c})=>{let l=a??i,[u,d]=N.useState(!1),f=N.useRef(null);return N.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]),(0,ye.jsxs)(fe,{children:[(0,ye.jsx)(le,{asChild:!0,children:(0,ye.jsx)(pe,{variant:t,size:n,className:me(`text-muted-foreground hover:text-foreground transition-text h-8 w-8 duration-200`,r),"aria-label":l,type:`button`,disabled:s,onClick:async()=>{try{let t=typeof e==`function`?e():e;await navigator.clipboard.writeText(t),d(!0),typeof c==`function`&&c(),f.current=window.setTimeout(()=>d(!1),o)}catch{}},children:(0,ye.jsx)(`span`,{className:me(`inline-flex items-center justify-center transition-all duration-150`,u?`scale-110 opacity-100`:`opacity-90`),children:u?(0,ye.jsx)(ce,{className:`h-4 w-4 text-green-500`}):(0,ye.jsx)(Ne,{className:`h-4 w-4`})})})}),(0,ye.jsx)(de,{children:i})]})},Ge=e(ne(),1),Ke=ve(),qe=[],Je=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?Je:qe).push(n+=e[t])})();function Ye(e){if(e<768)return!1;for(let t=0,n=qe.length;;){let r=t+n>>1;if(e<qe[r])n=r;else if(e>=Je[r])t=r+1;else return!0;if(t==n)return!1}}function Xe(e){return e>=127462&&e<=127487}var Ze=8205;function Qe(e,t,n=!0,r=!0){return(n?$e:et)(e,t,r)}function $e(e,t,n){if(t==e.length)return t;t&&nt(e.charCodeAt(t))&&rt(e.charCodeAt(t-1))&&t--;let r=tt(e,t);for(t+=it(r);t<e.length;){let i=tt(e,t);if(r==Ze||i==Ze||n&&Ye(i))t+=it(i),r=i;else if(Xe(i)){let n=0,r=t-2;for(;r>=0&&Xe(tt(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function et(e,t,n){for(;t>0;){let r=$e(e,t-2,n);if(r<t)return r;t--}return 0}function tt(e,t){let n=e.charCodeAt(t);if(!rt(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return nt(r)?(n-55296<<10)+(r-56320)+65536:n}function nt(e){return e>=56320&&e<57344}function rt(e){return e>=55296&&e<56320}function it(e){return e<65536?1:2}var at=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ht(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),st.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ht(this,e,t);let n=[];return this.decompose(e,t,n,0),st.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new dt(this),i=new dt(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new dt(this,e)}iterRange(e,t=this.length){return new ft(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new pt(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new ot(t):st.from(ot.split(t,[]))}},ot=class e extends at{constructor(e,t=ct(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new mt(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(ut(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=lt(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=ht(this,t,n);let i=lt(this.text,lt(r.text,ut(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):st.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
10
|
+
`){[e,t]=ht(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},st=class e extends at{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=ht(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
11
|
+
`){[e,t]=ht(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new ot(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof ot&&c&&(n=u[u.length-1])instanceof ot&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new ot(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};at.empty=new ot([``],0);function ct(e){let t=-1;for(let n of e)t+=n.length+1;return t}function lt(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function ut(e,t,n){return lt(e,[``],t,n)}var dt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof ot?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof ot?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
12
|
+
`,this;e--}else if(r instanceof ot){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof ot?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},ft=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new dt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},pt=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(at.prototype[Symbol.iterator]=function(){return this.iter()},dt.prototype[Symbol.iterator]=ft.prototype[Symbol.iterator]=pt.prototype[Symbol.iterator]=function(){return this});var mt=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function ht(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function gt(e,t,n=!0,r=!0){return Qe(e,t,n,r)}function _t(e){return e>=56320&&e<57344}function vt(e){return e>=55296&&e<56320}function yt(e,t){let n=e.charCodeAt(t);if(!vt(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return _t(r)?(n-55296<<10)+(r-56320)+65536:n}function bt(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function xt(e){return e<65536?1:2}var St=/\r\n?|\n/,Ct=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(Ct||={}),wt=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){Ot(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:At(this,e)}mapDesc(e,t=!1){return e.empty?this:kt(this,e,t)}mapPos(e,t=-1,n=Ct.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=Ct.Simple&&c>=e&&(n==Ct.TrackDel&&r<e&&c>e||n==Ct.TrackBefore&&r<e||n==Ct.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},Tt=class e extends wt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Ot(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return kt(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(at.empty);r.push(a?t.slice(i,i+a):at.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:At(this,e,!0)}map(e,t=!1){return e.empty?this:kt(this,e,t,!0)}iterChanges(e,t=!1){Ot(this,e,t)}get desc(){return wt.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new jt(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);Et(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;Et(n,e,t),t>0&&Dt(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);Et(n,e,-1),Et(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:wt.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&Et(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?at.of(l.split(r||St)):l:at.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&Et(i,e-o,-1),Et(i,s-e,d),Dt(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(at.empty);r[e]=at.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function Et(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Dt(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(at.empty);e.push(n)}}function Ot(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=at.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function kt(e,t,n,r=!1){let i=[],a=r?[]:null,o=new jt(e),s=new jt(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);Et(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(Et(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(Et(i,0,o.ins),a&&Dt(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;Et(i,t,e<o.i?o.ins:0),a&&e<o.i&&Dt(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?Tt.createSet(i,a):wt.create(i);else throw Error(`Mismatched change set lengths`)}function At(e,t,n=!1){let r=[],i=n?[]:null,a=new jt(e),o=new jt(t);for(let e=!1;;)if(a.done&&o.done)return i?Tt.createSet(r,i):wt.create(r);else if(a.ins==0)Et(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)Et(r,0,o.ins,e),i&&Dt(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;Et(r,t,n,e),i&&n&&Dt(i,r,o.text)}else o.ins==-1?(Et(r,a.off?0:a.len,t,e),i&&Dt(i,r,a.textBit(t))):(Et(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&Dt(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var jt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?at.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?at.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Mt=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return P.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return P.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return P.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},P=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Mt.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Mt.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?Mt.create(t,e,48|a):Mt.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Nt(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Pt=0,F=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Pt++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Ft),!!t.static,t.enables)}of(e){return new It([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new It(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new It(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Ft(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var It=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Pt++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Rt(e,c)){let r=t(e);if(a?!Lt(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Zt(o,c);if(this.dependencies.every(t=>t instanceof F?o.facet(t)===e.facet(t):t instanceof Vt?o.field(t,!1)==e.field(t,!1):!0)||(a?Lt(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Lt(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Rt(e,t){let n=!1;for(let r of t)Xt(e,r)&1&&(n=!0);return n}function zt(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Zt(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Xt(e,t);return e.values[o]=s(e),1},update(e,n){if(!Rt(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=Rt(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Ft(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Bt=F.define({static:!0}),Vt=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(Pt++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Bt).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Bt),i=n.facet(Bt),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Bt.of({field:this,create:e})]}get extension(){return this}},Ht={lowest:4,low:3,default:2,high:1,highest:0};function Ut(e){return t=>new Gt(t,e)}var Wt={highest:Ut(Ht.highest),high:Ut(Ht.high),default:Ut(Ht.default),low:Ut(Ht.low),lowest:Ut(Ht.lowest)},Gt=class{constructor(e,t){this.inner=e,this.prec=t}},Kt=class e{of(e){return new qt(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},qt=class{constructor(e,t){this.compartment=e,this.inner=t}},Jt=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Yt(t,n,o))e instanceof Vt?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,Ft(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>zt(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function Yt(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof qt&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof qt){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Gt)a(e.inner,e.prec);else if(e instanceof Vt)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof It)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Ht.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Ht.default),r.reduce((e,t)=>e.concat(t))}function Xt(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Zt(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Qt=F.define(),$t=F.define({combine:e=>e.some(e=>e),static:!0}),en=F.define({combine:e=>e.length?e[0]:void 0,static:!0}),tn=F.define(),nn=F.define(),rn=F.define(),an=F.define({combine:e=>e.length?e[0]:!1}),on=class{constructor(e,t){this.type=e,this.value=t}static define(){return new sn}},sn=class{of(e){return new on(this,e)}},cn=class{constructor(e){this.map=e}of(e){return new I(this,e)}},I=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new cn(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};I.reconfigure=I.define(),I.appendConfig=I.define();var ln=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Nt(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};ln.time=on.define(),ln.userEvent=on.define(),ln.addToHistory=on.define(),ln.remote=on.define();function un(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function dn(e,t,n){let r,i,a;return n?(r=t.changes,i=Tt.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:I.mapEffects(e.effects,r).concat(I.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function fn(e,t,n){let r=t.selection,i=_n(t.annotations);return t.userEvent&&(i=i.concat(ln.userEvent.of(t.userEvent))),{changes:t.changes instanceof Tt?t.changes:Tt.of(t.changes||[],n,e.facet(en)),selection:r&&(r instanceof P?r:P.single(r.anchor,r.head)),effects:_n(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function pn(e,t,n){let r=fn(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=dn(r,fn(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=ln.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return hn(n?mn(i):i)}function mn(e){let t=e.startState,n=!0;for(let r of t.facet(tn)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:un(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=Tt.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=ln.create(t,r,e.selection&&e.selection.map(i),I.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(nn);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof ln?i:Array.isArray(i)&&i.length==1&&i[0]instanceof ln?i[0]:pn(t,_n(i),!1)}return e}function hn(e){let t=e.startState,n=t.facet(rn),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=dn(r,fn(t,a,e.changes.newLength),!0))}return r==e?e:ln.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var gn=[];function _n(e){return e==null?gn:Array.isArray(e)?e:[e]}var vn=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(vn||={}),yn=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,bn;try{bn=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function xn(e){if(bn)return bn.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||yn.test(n)))return!0}return!1}function Sn(e){return t=>{if(!/\S/.test(t))return vn.Space;if(xn(t))return vn.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return vn.Word;return vn.Other}}var Cn=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Xt(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Xt(this,n),Zt(this,n)}update(...e){return pn(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Kt.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(I.reconfigure)?(n=null,r=e.value):e.is(I.appendConfig)&&(n=null,r=_n(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Jt.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet($t)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:P.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=_n(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=I.mapEffects(a,c).concat(I.mapEffects(_n(o.effects),l))}return{changes:r,selection:P.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof Tt?t:Tt.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return at.of(t.split(this.facet(e.lineSeparator)||St))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Xt(this,t),Zt(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Vt&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:P.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Jt.resolve(t.extensions||[],new Map),r=t.doc instanceof at?t.doc:at.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||St)),i=t.selection?t.selection instanceof P?t.selection:P.single(t.selection.anchor,t.selection.head):P.single(0);return Nt(i,r.length),n.staticFacet($t)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
13
|
+
`}get readOnly(){return this.facet(an)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(Qt))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return Sn(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=gt(t,a,!1);if(i(t.slice(e,a))!=vn.Word)break;a=e}for(;o<r;){let e=gt(t,o);if(i(t.slice(o,e))!=vn.Word)break;o=e}return a==o?null:P.range(a+n,o+n)}};Cn.allowMultipleSelections=$t,Cn.tabSize=F.define({combine:e=>e.length?e[0]:4}),Cn.lineSeparator=en,Cn.readOnly=an,Cn.phrases=F.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),Cn.languageData=Qt,Cn.changeFilter=tn,Cn.transactionFilter=nn,Cn.transactionExtender=rn,Kt.reconfigure=I.define();function wn(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(!(a===i||i===void 0))if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var Tn=class{eq(e){return this==e}range(e,t=e){return Dn.create(e,t,this)}};Tn.prototype.startSide=Tn.prototype.endSide=0,Tn.prototype.point=!1,Tn.prototype.mapMode=Ct.TrackDel;function En(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var Dn=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function On(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var kn=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},An=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(On)),this.isEmpty)return n.length?e.of(n):this;let s=new Pn(this,null,-1).goto(0),c=0,l=[],u=new Mn;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(Dn.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Fn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Fn.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=Nn(a,o,n),c=new Ln(a,s,i),l=new Ln(o,s,i);n.iterGaps((e,t,n)=>Rn(c,e,l,t,n,r)),n.empty&&n.length==0&&Rn(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=999999999;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=Nn(i,a),s=new Ln(i,o,0).goto(n),c=new Ln(a,o,0).goto(n);for(;;){if(s.to!=c.to||!zn(s.active,c.active)||s.point&&(!c.point||!En(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new Ln(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new Mn;for(let r of e instanceof Dn?[e]:t?jn(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};An.empty=new An([],[],null,-1);function jn(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(On(t,r)>0)return e.slice().sort(On);t=r}return e}An.empty.nextLayer=An.empty;var Mn=class e{finishChunk(e){this.chunks.push(new kn(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(An.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=An.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Nn(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var Pn=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Fn=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new Pn(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)In(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)In(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),In(this.heap,0)}}};function In(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var Ln=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Fn.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Bn(this.active,e),Bn(this.activeTo,e),Bn(this.activeRank,e),this.minActive=Hn(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Vn(this.active,t,n),Vn(this.activeTo,t,r),Vn(this.activeRank,t,i),e&&Vn(e,t,this.cursor.from),this.minActive=Hn(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Bn(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function Rn(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&En(e.point,n.point)&&zn(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!zn(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function zn(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!En(e[n],t[n]))return!1;return!0}function Bn(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Vn(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function Hn(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Un(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=gt(e,i));return r}function Wn(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=gt(e,r)}return r===!0?-1:e.length}for(var Gn=`ͼ`,Kn=typeof Symbol>`u`?`__`+Gn:Symbol.for(Gn),qn=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),Jn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},Yn=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
|
|
14
|
+
`)}static newName(){let e=Jn[Kn]||1;return Jn[Kn]=e+1,Gn+e.toString(36)}static mount(e,t,n){let r=e[qn],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Zn(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Xn=new Map,Zn=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Xn.get(n);if(t)return e[qn]=t;this.sheet=new r.CSSStyleSheet,Xn.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[qn]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
|
|
15
|
+
`;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},Qn={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},$n={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},er=typeof navigator<`u`&&/Mac/.test(navigator.platform),tr=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),nr=0;nr<10;nr++)Qn[48+nr]=Qn[96+nr]=String(nr);for(var nr=1;nr<=24;nr++)Qn[nr+111]=`F`+nr;for(var nr=65;nr<=90;nr++)Qn[nr]=String.fromCharCode(nr+32),$n[nr]=String.fromCharCode(nr);for(var rr in Qn)$n.hasOwnProperty(rr)||($n[rr]=Qn[rr]);function ir(e){var t=!(er&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||tr&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?$n:Qn)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function ar(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)or(e,arguments[t]);return e}function or(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)or(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}var sr=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},cr=typeof document<`u`?document:{documentElement:{style:{}}},lr=/Edge\/(\d+)/.exec(sr.userAgent),ur=/MSIE \d/.test(sr.userAgent),dr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(sr.userAgent),fr=!!(ur||dr||lr),pr=!fr&&/gecko\/(\d+)/i.test(sr.userAgent),mr=!fr&&/Chrome\/(\d+)/.exec(sr.userAgent),hr=`webkitFontSmoothing`in cr.documentElement.style,gr=!fr&&/Apple Computer/.test(sr.vendor),_r=gr&&(/Mobile\/\w+/.test(sr.userAgent)||sr.maxTouchPoints>2),L={mac:_r||/Mac/.test(sr.platform),windows:/Win/.test(sr.platform),linux:/Linux|X11/.test(sr.platform),ie:fr,ie_version:ur?cr.documentMode||6:dr?+dr[1]:lr?+lr[1]:0,gecko:pr,gecko_version:pr?+(/Firefox\/(\d+)/.exec(sr.userAgent)||[0,0])[1]:0,chrome:!!mr,chrome_version:mr?+mr[1]:0,ios:_r,android:/Android\b/.test(sr.userAgent),webkit:hr,webkit_version:hr?+(/\bAppleWebKit\/(\d+)/.exec(sr.userAgent)||[0,0])[1]:0,safari:gr,safari_version:gr?+(/\bVersion\/(\d+(\.\d+)?)/.exec(sr.userAgent)||[0,0])[1]:0,tabSize:cr.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function vr(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var yr=Object.create(null);function br(e,t,n){if(e==t)return!0;e||=yr,t||=yr;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function xr(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function Sr(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function Cr(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var wr=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Tr=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(Tr||={}),R=class extends Tn{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Er(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Or(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=kr(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new Or(e,n,r,t,e.widget||null,!0)}static line(e){return new Dr(e)}static set(e,t=!1){return An.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};R.none=An.empty;var Er=class e extends R{constructor(e){let{start:t,end:n}=kr(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?vr(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||yr}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&br(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};Er.prototype.point=!1;var Dr=class e extends R{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&br(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};Dr.prototype.mapMode=Ct.TrackBefore,Dr.prototype.point=!0;var Or=class e extends R{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?Ct.TrackBefore:Ct.TrackAfter:Ct.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?Tr.WidgetBefore:Tr.WidgetAfter:Tr.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&Ar(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};Or.prototype.point=!0;function kr(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function Ar(e,t){return e==t||!!(e&&t&&e.compare(t))}function jr(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var Mr=class e extends Tn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&br(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||yr)}static set(e,t=!1){return An.of(e,t)}};Mr.prototype.startSide=Mr.prototype.endSide=-1;function Nr(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Pr(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function Fr(e,t){if(!t.anchorNode)return!1;try{return Pr(e,t.anchorNode)}catch{return!1}}function Ir(e){return e.nodeType==3?Zr(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Lr(e,t,n,r){return n?Br(e,t,n,r,-1)||Br(e,t,n,r,1):!1}function Rr(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function zr(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Br(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Vr(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=Rr(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?Vr(e):0}else return!1}}function Vr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Hr(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Ur(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Wr(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Gr(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=Ur(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=Wr(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Kr(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var qr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Vr(t):0),n,Math.min(e.focusOffset,n?Vr(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},Jr=null;L.safari&&L.safari_version>=26&&(Jr=!1);function Yr(e){if(e.setActive)return e.setActive();if(Jr)return e.focus(Jr);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(Jr==null?{get preventScroll(){return Jr={preventScroll:!0},!0}}:void 0),!Jr){Jr=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var Xr;function Zr(e,t,n=t){let r=Xr||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function Qr(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function $r(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function ei(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Vr(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=Vr(n))}else if(n==e)return!0;else r=Rr(n),n=n.parentNode}function ti(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function ni(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=Vr(n)}else if(n.parentNode&&!zr(n))r=Rr(n),n=n.parentNode;else return null}function ri(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!zr(n))r=Rr(n)+1,n=n.parentNode;else return null}var ii=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,Rr(t),n)}static after(t,n){return new e(t.parentNode,Rr(t)+1,n)}},ai=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(ai||={}),oi=ai.LTR,si=ai.RTL;function ci(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var li=ci(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),ui=ci(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),di=Object.create(null),fi=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);di[t]=n,di[n]=-t}function pi(e){return e<=247?li[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?ui[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var mi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,hi=class{get dir(){return this.level%2?si:oi}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function gi(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.direction!=i.direction||!gi(r.inner,i.inner))return!1}return!0}var _i=[];function vi(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=pi(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),_i[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=_i[e];if(i==128)e<s-1&&t==_i[e+1]&&t&24?i=_i[e]=t:_i[e]=256;else if(i==64){let i=e+1;for(;i<s&&_i[i]==64;)i++;let a=e&&t==8||i<n&&_i[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)_i[t]=a;e=i-1}else i==8&&r==1&&(_i[e]=1);t=i,i&7&&(r=i)}}}function yi(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=di[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(fi[e+1]==-r){let n=fi[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(_i[t]=_i[fi[e]]=r),s=e;break}}else if(fi.length==189)break;else fi[s++]=t,fi[s++]=n,fi[s++]=c;else if((o=_i[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=fi[t+2];if(n&2)break;if(e)fi[t+2]|=2;else{if(n&4)break;fi[t+2]|=4}}}}}function bi(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=_i[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(_i[o]==256)o++;else break;let l=a==1,u=l==((o<t?_i[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),_i[--t]=u;c=o}else a=o,c++}}}function xi(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=_i[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(_i[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new hi(c,m.from,f)),Si(e,m.direction==oi==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?_i[p]!=s:_i[p]==s))break;else p++;d?xi(e,c,p,r+1,i,d,o):c<p&&o.push(new hi(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=_i[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(_i[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new hi(m.to,c,f)),Si(e,m.direction==oi==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?_i[p-1]!=s:_i[p-1]==s))break;else p--;d?xi(e,p,c,r+1,i,d,o):p<c&&o.push(new hi(p,c,f)),c=p}}function Si(e,t,n,r,i,a,o){let s=t%2?2:1;vi(e,i,a,r,s),yi(e,i,a,r,s),bi(i,a,r,s),xi(e,i,a,t,n,r,o)}function Ci(e,t,n){if(!e)return[new hi(0,0,+(t==si))];if(t==oi&&!n.length&&!mi.test(e))return wi(e.length);if(n.length)for(;e.length>_i.length;)_i[_i.length]=256;let r=[],i=t==oi?0:1;return Si(e,i,i,n,0,e.length,r),r}function wi(e){return[new hi(0,e,0)]}var Ti=``;function Ei(e,t,n,r,i){let a=r.head-e.from,o=hi.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=gt(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),Ti=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?P.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):P.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function Di(e,t,n){for(let r=t;r<n;r++){let t=pi(e.charCodeAt(r));if(t==1)return oi;if(t==2||t==4)return si}return oi}var Oi=F.define(),ki=F.define(),Ai=F.define(),ji=F.define(),Mi=F.define(),Ni=F.define(),Pi=F.define(),Fi=F.define(),Ii=F.define(),Li=F.define({combine:e=>e.some(e=>e)}),Ri=F.define({combine:e=>e.some(e=>e)}),zi=F.define(),Bi=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(P.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Vi=I.define({map:(e,t)=>e.map(t)}),Hi=I.define();function Ui(e,t,n){let r=e.facet(ji);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var Wi=F.define({combine:e=>e.length?e[0]:!0}),Gi=0,Ki=F.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),qi=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Ki.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ki.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(Gi++,t,r,i,e=>{let t=[];return o&&t.push(Zi.of(t=>{let n=t.plugin(e);return n?o(n):R.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Ji=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Ui(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Ui(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){Ui(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},Yi=F.define(),Xi=F.define(),Zi=F.define(),Qi=F.define(),$i=F.define(),ea=F.define(),ta=F.define();function na(e,t){let n=e.state.facet(ta);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return An.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=Di(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var ra=F.define();function ia(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(ra)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var aa=F.define(),oa=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},sa=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Tt.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new oa(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ca=[],la=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return ca}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&xr(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Rr(this.dom),r=this.length?e>0:t>0;return new ii(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fa)return e;return null}static get(e){return e.cmTile}},ua=class extends la{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=da(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=da(r);this.length=a}};function da(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var fa=class extends ua{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=la.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof pa)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},pa=class e extends ua{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},ma=class e extends ua{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&ga(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):ha(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new ii(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new ii(e.dom,0);e==n.tile&&(a=!0)}}return new ii(this.dom,0)}};function ha(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Ir(t);return n[n.length-1]||null}function ga(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var _a=class e extends ua{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},va=class e extends la{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?L.chrome||L.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=Zr(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return L.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?Hr(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},ya=class e extends la{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Hr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return Hr(n,!r)}}get overrideDOMText(){if(!this.length)return at.empty;let{root:e}=this;if(!e)return at.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},ba=class extends la{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return at.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},xa=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Sa=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},Ca=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new va(a.dom,a.text+e);t.parent=i}else i.append(r||va.of(e,this.cache.find(va)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?Na(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof _a&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(Na(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=la.get(n.dom);e&&e.setDOM(Na(n.dom))}let e=_a.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=la.get(e.text);i&&this.cache.reused.set(i,2);let a=new va(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=Aa;let n=ma.start(e,t||this.cache.find(ma)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof _a&&a.mark.eq(i))n=a,t--;else{let e=_a.of(i,this.cache.find(_a,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Oa(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(L.ios&&Oa(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Fa,0,32)||new ya(Fa.toDOM(),0,Fa,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Sa(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof pa&&n.wrapper.eq(t.wrapper))e=n;else{let n=pa.of(t.wrapper,this.cache.find(pa,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(ba,void 0,1);return n&&(n.flags=t),n||new ba(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},wa=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},Ta=[ya,ma,va,_a,ba,pa,fa];for(let e=0;e<Ta.length;e++)Ta[e].bucket=e;var Ea=class{constructor(e){this.view=e,this.buckets=Ta.map(()=>[]),this.index=Ta.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new ya(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},Da=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new Ea(e),this.text=new wa(e.state.doc),this.builder=new Ca(this.cache,new fa(e,e.contentDOM),An.iter(n)),this.cache.reused.set(t,2),this.old=new xa(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=Ma(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?ya.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof ba)this.cache.add(e);else if(e instanceof _a)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof _a&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof _a&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=An.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof Or){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?Pa.block:Pa.inline),c=ka(a),l=this.cache.findWidget(i,t-e,c)||ya.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=ja(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=la.get(r);if(r==this.view.contentDOM)break;e instanceof _a?t.push(e):e?.isLine()?n=e:e instanceof pa||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new ma(r,Aa):n||t.push(_a.of(new Er({tagName:r.nodeName.toLowerCase(),attributes:Cr(r)}),r)))}return{line:n,marks:t}}};function Oa(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function ka(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var Aa={class:`cm-line`};function ja(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&vr(n,e),r&&(e.class+=` `+r),e)}function Ma(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof _a&&t.push(r.mark)}return t}function Na(e){let t=la.get(e);return t&&t.setDOM(e.cloneNode()),e}var Pa=class extends wr{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Pa.inline=new Pa(`span`),Pa.block=new Pa(`div`);var Fa=new class extends wr{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},Ia=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=R.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fa(e,e.contentDOM),this.updateInner([new oa(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!qa(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Ba(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new oa(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(L.ie||L.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Ua(i,this.decorations,e.changes);o.length&&(t=oa.extendWithRanges(t,o));let s=Ga(a,this.blockWrappers,e.changes);return s.length&&(t=oa.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new Da(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&la.get(t.text)&&r.cache.reused.set(la.get(t.text),2),this.tile=r.run(e,t),La(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=L.chrome||L.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof Ja&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(Hi)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(Wi)||n.tabIndex>-1)&&Fr(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),L.gecko&&s.empty&&!this.hasComposition&&Ra(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new ii(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!Lr(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Lr(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{L.android&&L.chrome&&n.contains(u.focusNode)&&Ka(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=Nr(this.view.root);if(e)if(s.empty){if(L.gecko){let e=Va(c.node,c.offset);if(e&&e!=3){let t=(e==1?ni:ri)(c.node,c.offset);t&&(c=new ii(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new ii(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new ii(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Lr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Nr(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=Vr(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!la.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Ja?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=gt(e.text,t);if(n==t)return null;let r=Zr(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==ai.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof pa)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?Ir(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?ai.RTL:ai.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Ir(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=Ir(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(R.replace({widget:new Ja(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return R.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Zi).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet($i).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(An.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Qi).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(zi))try{if(t(this.view,e.range,e))return!0}catch(e){Ui(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=ia(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(Gr(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==ai.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){La(this.tile)}};function La(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)La(n,t)}}function Ra(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function za(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=ni(n.focusNode,n.focusOffset),i=ri(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=la.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=la.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Ba(e,t,n){let r=za(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new oa(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Va(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var Ha=class{constructor(){this.changes=[]}compareRange(e,t){jr(e,t,this.changes)}comparePoint(e,t){jr(e,t,this.changes)}boundChange(e){jr(e,e,this.changes)}};function Ua(e,t,n){let r=new Ha;return An.compare(e,t,n,r),r.changes}var Wa=class{constructor(){this.changes=[]}compareRange(e,t){jr(e,t,this.changes)}comparePoint(){}boundChange(e){jr(e,e,this.changes)}};function Ga(e,t,n){let r=new Wa;return An.compare(e,t,n,r),r.changes}function Ka(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function qa(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var Ja=class extends wr{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Ya(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return P.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=gt(i.text,a,!1):s=gt(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=gt(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=gt(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return P.range(o+i.from,s+i.from)}function Xa(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Wn(o,a,e.state.tabSize)}function Za(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==Tr.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function Qa(e,t,n,r){let i=Za(e,t.head,t.assoc||-1),a=!r||i.type!=Tr.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==ai.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return P.cursor(o,n?-1:1)}return P.cursor(n?i.to:i.from,n?-1:1)}function $a(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=Ei(i,a,o,s,n),l=Ti;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
|
|
16
|
+
`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function eo(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==vn.Space&&(i=t),i==t}}function to(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return P.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=oo(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return P.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 P.cursor(i.pos,i.assoc,void 0,o)}}function no(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 ro(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=no(e,i.from,0);t!=i.from&&(a=P.cursor(t,-1))}else{let t=no(e,i.from,-1),n=no(e,i.to,1);(t!=i.from||n!=i.to)&&(a=P.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?P.create(n,t.mainIndex):t}function io(e,t,n){let r=no(e.state.facet(ea).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:P.cursor(r,r<n.from?1:-1)}var ao=class{constructor(e,t){this.pos=e,this.assoc=t}};function oo(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 ao(0,1);if(c>e.viewState.docHeight)return new ao(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==Tr.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==Tr.Text){let t=Xa(e,i,l,o,s);return new ao(t,t==l.from?1:-1)}}if(l.type!=Tr.Text)return c<(l.top+l.bottom)/2?new ao(l.from,1):new ao(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 so(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var so=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[hi.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[hi.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)){let e=r+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!a.has(e)){f=e;break adjust}e++,e==i&&(e=r)}break search}a.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let n=p[t],a=0;if(!(n.width==0&&p.length>1)){if(n.bottom<this.y)(!s||s.bottom<n.bottom)&&(s=n),a=1;else if(n.top>this.y)(!c||c.top>n.top)&&(c=n),a=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(l=f,u=t,d=n),e&&(a=e<0==(this.baseDir==ai.LTR)?-1:1)}a==-1&&(!o||this.baseDirAt(e[f],1))?i=f:a==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}}}if(!d){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)==ai.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=gt(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 Zr(e.dom,i,a).getClientRects()});return r.after?new ao(n[r.i+1],-1):new ao(n[r.i],1)}scanTile(e,t){if(!e.length)return new ao(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:(n.dom.nodeType==1?n.dom:Zr(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 ao(n[r.i+1],-1):new ao(a,1)}},co=``,lo=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(Cn.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=co}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=la.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=la.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:zr(r))||zr(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!fo(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=la.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 e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&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)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(uo(e,n.node,n.offset)?t:0))}};function uo(e,t,n){for(;;){if(!t||n<Vr(t))return!1;if(t==e)return!0;n=Rr(t)+1,t=t.parentNode}}function fo(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=la.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 po=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},mo=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=ho(e.docView.tile,t,n,0))){let t=i||a?[]:bo(e),n=new lo(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=xo(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Pr(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!Pr(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((L.ios||L.chrome)&&o.main.empty&&n!=r&&(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(P.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=P.create([P.cursor(n,r)])}else this.newSel=P.single(r,n)}}};function ho(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 ho(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}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function go(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||L.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,co),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:at.of(t.text.slice(a.from-e,u).split(co))}:(d=yo(l,t.text,s-e,c))&&(L.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==co+co&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:at.of(t.text.slice(d.from,d.toB).split(co))})}else r&&(!e.hasFocus&&i.facet(Wi)||So(r,a))&&(r=null);if(!n&&!r)return!1;if((L.mac||L.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=P.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:at.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)}:L.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
17
|
+
`&&e.lineWrapping&&(r&&=P.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:at.of([` `])}),n)return _o(e,n,r,o);if(r&&!So(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=ro(i.facet(ea).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function _o(e,t,n,r=-1){if(L.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(L.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&&Qr(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)&&Qr(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Qr(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=vo(e,t,n);return e.state.facet(Ni).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function vo(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=no(i.facet(ea).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:P.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&&za(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?P.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 yo(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 bo(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 po(n,r)),(i!=n||a!=r)&&t.push(new po(i,a))),t}function xo(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?P.single(n+t,r+t):null}function So(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var Co=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,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.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,L.safari&&e.contentDOM.addEventListener(`input`,()=>null),L.gecko&&as(e.contentDOM.ownerDocument)}handleEvent(e){!Io(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=To(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&&Oo.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),L.android&&L.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return L.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=Eo.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Do.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Qr(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:L.safari&&!L.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 wo(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){Ui(n.state,e)}}}function To(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(wo(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(wo(t.value,r))}}for(let e in Lo)n(e).handlers.push(Lo[e]);for(let e in Ro)n(e).observers.push(Ro[e]);return t}var Eo=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],Do=`dthko`,Oo=[16,17,18,20,91,92,224,225],ko=6;function Ao(e){return Math.max(0,e)*.7+8}function jo(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var Mo=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=Kr(e.contentDOM),this.atoms=e.state.facet(ea).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(Cn.allowMultipleSelections)&&No(e,t),this.dragging=Fo(e,t)&&Jo(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&&jo(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=ia(this.view);e.clientX-s.left<=r+ko?t=-Ao(r-e.clientX):e.clientX+s.right>=a-ko&&(t=Ao(e.clientX-a)),e.clientY-s.top<=i+ko?n=-Ao(i-e.clientY):e.clientY+s.bottom>=o-ko&&(n=Ao(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=ro(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 No(e,t){let n=e.state.facet(Oi);return n.length?n[0](t):L.mac?t.metaKey:t.ctrlKey}function Po(e,t){let n=e.state.facet(ki);return n.length?n[0](t):L.mac?!t.altKey:!t.ctrlKey}function Fo(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Nr(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 Io(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=la.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var Lo=Object.create(null),Ro=Object.create(null),zo=L.ie&&L.ie_version<15||L.ios&&L.webkit_version<604;function Bo(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(),Ho(e,n.value)},50)}function Vo(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Ho(e,t){t=Vo(e.state,Fi,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(es!=null&&n.selection.ranges.every(e=>e.empty)&&es==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:P.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:P.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}Ro.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},Ro.wheel=Ro.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Lo.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Ro.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},Ro.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},Lo.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(Ai))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=Yo(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Mo(e,t,n,r)),r&&e.observer.ignore(()=>{Yr(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 Uo(e,t,n,r){if(r==1)return P.cursor(t,n);if(r==2)return Ya(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++,P.range(a,o)}}var Wo=L.ie&&L.ie_version<=11,Go=null,Ko=0,qo=0;function Jo(e){if(!Wo)return e.detail;let t=Go,n=qo;return Go=e,qo=Date.now(),Ko=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Ko+1)%3:1}function Yo(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Jo(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=Uo(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=Uo(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?P.range(i,a,l.assoc):P.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=Xo(i,s.pos))?c:o?i.addRange(l):P.create([l])}}}function Xo(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 P.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}Lo.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=P.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,Vo(e.state,Ii,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},Lo.dragend=e=>(e.inputState.draggedContent=null,!1);function Zo(e,t,n,r){if(n=Vo(e.state,Fi,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&Po(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}Lo.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&&Zo(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}else{let n=t.dataTransfer.getData(`Text`);if(n)return Zo(e,t,n,!0),!0}return!1},Lo.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=zo?null:t.clipboardData;return n?(Ho(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(Bo(e),!1)};function Qo(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 $o(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:Vo(e,Ii,t.join(e.lineBreak)),ranges:n,linewise:r}}var es=null;Lo.copy=Lo.cut=(e,t)=>{if(!Fr(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=$o(e.state);if(!n&&!i)return!1;es=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=zo?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Qo(e,n),!1)};var ts=on.define();function ns(e,t){let n=[];for(let r of e.facet(Pi)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:ts.of(!0)}):null}function rs(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=ns(e.state,t);n?e.dispatch(n):e.update([])}},10)}Ro.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),rs(e)},Ro.blur=e=>{e.observer.clearSelectionRange(),rs(e)},Ro.compositionstart=Ro.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Ro.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,L.chrome&&L.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Ro.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Lo.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 _o(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(L.chrome&&L.android&&(n=Eo.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 L.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),L.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>Ro.compositionend(e,t),20),!1};var is=new Set;function as(e){is.has(e)||(is.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var os=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],ss=!1;function cs(){ss=!1}var ls=class{constructor(e){this.lineWrapping=e,this.doc=at.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 os.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=os.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}},us=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},ds=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`?Tr.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 Or?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)}},fs=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(fs||={}),ps=.001,ms=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)>ps&&(ss=!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,fs.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,fs.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,fs.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=Cs.build(n.setDoc(a),e,l,u);i=hs(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new vs(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=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new bs(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function hs(e,t){return e==t?e:(e.constructor!=t.constructor&&(ss=!0),t)}ms.prototype.size=1;var gs=R.replace({}),_s=class extends ms{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new ds(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 ds(r,0,n,this.spaceAbove,gs):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,fs.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})`}},vs=class e extends _s{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 ds(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 ys&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ys?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):ms.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:``})`}},ys=class e extends ms{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 ds(a.from,a.length,l,c,0)}else{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 ds(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==fs.ByHeight)return this.blockAt(e,n,r,i);if(t==fs.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new ds(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 ds(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 ds(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 ms.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)>=ps&&(s=-2);let c=new vs(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=ms.of(r);return(s<0||Math.abs(c.height-this.height)>=ps||Math.abs(s-this.heightMetrics(t,n).perLine)>=ps)&&(ss=!0),hs(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},bs=class extends ms{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==fs.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==fs.ByPosNoHeight?fs.ByPosNoHeight:fs.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,fs.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(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&&xs(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),xs(i,e)}return ms.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?ms.of(this.break?[e,null,t]:[e,t]):(this.left=hs(this.left,e),this.right=hs(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 xs(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof ys&&(r=e[t+1])instanceof ys&&e.splice(t-1,3,new ys(n.length+1+r.length))}var Ss=5,Cs=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 vs?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new vs(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 _s(a,r,n)):(a||i||r>=Ss)&&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 vs(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new ys(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 vs)return e;let t=new vs(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 vs)&&!this.isCovered?this.nodes.push(new vs(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 vs&&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 An.spans(n,r,i,a,0),a.finish(r)}};function ws(e,t,n){let r=new Ts;return An.compare(e,t,n,r,0),r.changes}var Ts=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&jr(e,t,this.changes,5)}};function Es(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(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.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 Ds(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 Os(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var ks=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 R.replace({widget:new As(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},As=class extends wr{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}},js=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=Ls,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ai.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Xi).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new ls(n),this.stateDeco=Rs(t),this.heightMap=ms.empty().applyChanges(this.stateDeco,at.empty,this.heightOracle.setDoc(t.doc),[new oa(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=R.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 Ms(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?Ls:new zs(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(Bs(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Rs(this.state);let r=e.changedRanges,i=oa.extendWithRanges(r,ws(n,this.stateDeco,e?e.changes:Tt.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);cs(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||ss)&&(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(Ri)&&(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`?ai.RTL:ai.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}=Wr(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=Kr(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=ti(this.scrollParent||e.win);let m=(this.printing?Os:Es)(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&&!Ds(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)),cs();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?ms.empty().applyChanges(this.stateDeco,at.empty,this.heightOracle,[new oa(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new us(n.from,i))}ss&&(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 Ms(r.lineAt(a-n*1e3,fs.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,fs.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,fs.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 Ms(r.lineAt(o-1e3/2,fs.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,fs.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 Ms(this.heightMap.lineAt(n,fs.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,fs.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,fs.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,fs.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-2*1e3&&i<o+2*1e3}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 ks(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!=ai.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=Is(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(P.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new ks(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=Tr.Text)return;let i=Ns(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=Fs(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=Ps(i,n),l=Ps(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=Fs(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=Ps(i,f),l=Ps(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=Fs(r,n)-Fs(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){ks.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=R.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=[];An.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)||Bs(this.heightMap.lineAt(e,fs.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)||Bs(this.heightMap.lineAt(this.scaler.fromDOM(e),fs.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}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 Bs(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}},Ms=class{constructor(e,t){this.from=e,this.to=t}};function Ns(e,t,n){let r=[],i=e,a=0;return An.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 Ps({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 Fs(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 Is(e,t){for(let n of e)if(t(n))return n}var Ls={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function Rs(e){let t=e.facet(Zi).filter(e=>typeof e!=`function`),n=e.facet($i).filter(e=>typeof e!=`function`);return n.length&&t.push(An.join(n)),t}var zs=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,fs.ByPos,e,0,0).top,o=t.lineAt(i,fs.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):!1}};function Bs(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new ds(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Bs(e,t)):e._content)}var Vs=F.define({combine:e=>e.join(` `)}),Hs=F.define({combine:e=>e.indexOf(!0)>-1}),Us=Yn.newName(),Ws=Yn.newName(),Gs=Yn.newName(),Ks={"&light":`.`+Ws,"&dark":`.`+Gs};function qs(e,t,n){return new Yn(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 Js=qs(`.`+Us,{"&":{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":{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`},"&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:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`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`}},Ks),Ys={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Xs=L.ie&&L.ie_version<=11,Zs=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new qr,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);(L.ie&&L.ie_version<=11||L.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&&L.android&&e.constructor.EDIT_CONTEXT!==!1&&!(L.chrome&&L.chrome_version<126)&&(this.editContext=new tc(e),e.state.facet(Wi)&&(e.contentDOM.editContext=this.editContext.editContext)),Xs&&(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(Wi)?n.root.activeElement!=this.dom:!Fr(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(L.ie&&L.ie_version<=11||L.android&&L.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Lr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Nr(e.root);if(!t)return!1;let n=L.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&ec(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Fr(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&ei(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(n.nodeType==1)!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,Ys),Xs&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Xs&&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&&Qr(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&&Fr(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 mo(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.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=go(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!So(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}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=Qs(t,e.previousSibling||e.target.previousSibling,-1),r=Qs(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return 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(Wi)!=e.state.facet(Wi)&&(e.view.contentDOM.editContext=e.state.facet(Wi)?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 Qs(e,t,n){for(;t;){let r=la.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 $s(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 Lr(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function ec(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return $s(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?$s(e,n):null}var tc=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=yo(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=P.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));So(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:at.of(n.text.slice(l.from,l.toB).split(`
|
|
18
|
+
`))};if((L.mac||L.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:at.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);_o(e,u,P.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(R.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:Hi.of(R.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=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=Nr(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}else 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>1e4*3)}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])}},z=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.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||$r(e.parent)||document,this.viewState=new js(this,e.state||Cn.create(e)),e.scrollTo&&e.scrollTo.is(Vi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ki).map(e=>new Ji(e));for(let e of this.plugins)e.update(this);this.observer=new Zs(this),this.inputState=new Co(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ia(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 ln?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(ts))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=ns(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(Cn.phrases)!=this.state.facet(Cn.phrases))return this.setState(a);i=sa.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 Bi(t.empty?t:P.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Vi)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=ic.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(aa)!=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(Vs)!=i.state.facet(Vs)&&(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(Mi))try{e(i)}catch(e){Ui(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!go(this,u)&&l.force&&Qr(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 js(this,e),this.plugins=e.facet(Ki).map(e=>new Ji(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Ia(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(Ki),n=e.state.facet(Ki);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Ji(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){Ui(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}=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(ti(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!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 s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return Ui(this.state,e),rc}}),l=sa.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=rc)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){Ui(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.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}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?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(Mi))e(t)}get themeClasses(){return Us+` `+(this.state.facet(Hs)?Gs:Ws)+` `+this.state.facet(Vs)}updateAttrs(){let e=ac(this,Yi,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Wi)?`true`:`false`,class:`cm-content`,style:`${L.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),ac(this,Xi,t);let n=this.observer.ignore(()=>{let n=Sr(this.contentDOM,this.contentAttrs,t),r=Sr(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=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(aa);let t=this.state.facet(e.cspNonce);Yn.mount(this.root,this.styleModules.concat(Js).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 io(this,e,$a(this,e,t,n))}moveByGroup(e,t){return io(this,e,$a(this,e,t,t=>eo(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return P.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Qa(this,e,t,n)}moveVertically(e,t,n){return io(this,e,to(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=oo(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),oo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[hi.find(i,e-r.from,-1,t)];return Hr(n,a.dir==ai.LTR==t>0)}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(Li)||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>nc)return wi(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||gi(r.isolates,n=na(this,e))))return r.order;n||=na(this,e);let r=Ci(e.text,t,n);return this.bidiCache.push(new ic(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||L.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Yr(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.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Vi.of(new Bi(typeof e==`number`?P.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 Vi.of(new Bi(P.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 qi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return qi.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Yn.newName(),r=[Vs.of(n),aa.of(qs(`.${n}`,e))];return t&&t.dark&&r.push(Hs.of(!0)),r}static baseTheme(e){return Wt.lowest(aa.of(qs(`.`+Us,e,Ks)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&la.get(t)||la.get(e))?.root?.view||null}};z.styleModule=aa,z.inputHandler=Ni,z.clipboardInputFilter=Fi,z.clipboardOutputFilter=Ii,z.scrollHandler=zi,z.focusChangeEffect=Pi,z.perLineTextDirection=Li,z.exceptionSink=ji,z.updateListener=Mi,z.editable=Wi,z.mouseSelectionStyle=Ai,z.dragMovesSelection=ki,z.clickAddsSelectionRange=Oi,z.decorations=Zi,z.blockWrappers=Qi,z.outerDecorations=$i,z.atomicRanges=ea,z.bidiIsolatedRanges=ta,z.cursorScrollMargin=F.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}}}),z.scrollMargins=ra,z.darkTheme=Hs,z.cspNonce=F.define({combine:e=>e.length?e[0]:``}),z.contentAttributes=Xi,z.editorAttributes=Yi,z.lineWrapping=z.contentAttributes.of({class:`cm-lineWrapping`}),z.announce=I.define();var nc=4096,rc={},ic=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:ai.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 ac(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&&vr(a,n)}return n}var oc=L.mac?`mac`:L.windows?`win`:L.linux?`linux`:`key`;function sc(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 cc(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 lc=Wt.default(z.domEventHandlers({keydown(e,t){return vc(fc(t.state),e,t,`editor`)}})),uc=F.define({enables:lc}),dc=new WeakMap;function fc(e){let t=e.facet(uc),n=dc.get(t);return n||dc.set(t,n=gc(t.reduce((e,t)=>e.concat(t),[]))),n}function pc(e,t,n){return vc(fc(e.state),t,e,n)}var mc=null,hc=4e3;function gc(e,t=oc){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=>sc(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=mc={view:t,prefix:n,scope:e};return setTimeout(()=>{mc==r&&(mc=null)},hc),!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,_c))}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 _c=null;function vc(e,t,n,r){_c=t;let i=ir(t),a=xt(yt(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;mc&&mc.view==n&&mc.scope==r&&(o=mc.prefix+` `,Oo.indexOf(t.keyCode)<0&&(c=!0,mc=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+cc(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(L.windows&&t.ctrlKey&&t.altKey)&&!(L.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Qn[t.keyCode])&&p!=i?(d(f[o+cc(p,t,!0)])||t.shiftKey&&(m=$n[t.keyCode])!=i&&m!=p&&d(f[o+cc(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+cc(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),_c=null,s}/x/.unicode;var yc=`-10000px`,bc=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 xc(e={}){return Cc.of(e)}function Sc(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var Cc=F.define({combine:e=>({position:L.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Sc})}),wc=new WeakMap,Tc=qi.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(Cc);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 bc(e,kc,(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(Cc);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=yc,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;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(L.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);let r=this.view.scrollDOM.getBoundingClientRect(),i=ia(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((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(Cc).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}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=yc;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=wc.get(c)??d.bottom-d.top,g=c.offset||Oc,_=this.view.textDirection==ai.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=yc;continue}wc.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`,Ec(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,Ec(l,v/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=yc}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ec(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Dc=z.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`}}}),Oc={x:0,y:0},kc=F.define({enables:[Tc,Dc]}),Ac=F.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),jc=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 bc(e,Ac,(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`)}},Mc=kc.compute([Ac],e=>{let t=e.facet(Ac);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:jc.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Nc=F.define(),Pc=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==ai.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=>Ui(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(Tc),t=e?e.manager.tooltips.findIndex(e=>e.create==jc.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&&!Ic(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:!Lc(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)}},Fc=4;function Ic(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-Fc&&t.clientX<=r+Fc&&t.clientY>=i-Fc&&t.clientY<=a+Fc}function Lc(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 Rc(e,t={}){let n=I.define(),r=new WeakMap,i=Vt.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,Ct.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(Bc)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>Ac.from(e)}),a=qi.define(a=>new Pc(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,Nc.of(a),Mc]}}function zc(e,t){let n=e.plugin(Tc);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var Bc=I.define(),Vc=F.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function Hc(e,t){let n=e.plugin(Uc),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var Uc=qi.fromClass(class{constructor(e){this.input=e.state.facet(Kc),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(Vc);this.top=new Wc(e,!0,t.topContainer),this.bottom=new Wc(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(Vc);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Wc(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Wc(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Kc);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=>z.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),Wc=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`,this.dom.style[this.top?`top`:`bottom`]=`0`;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=Gc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Gc(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 Gc(e){let t=e.nextSibling;return e.remove(),t}var Kc=F.define({enables:Uc});function qc(e,t){let n,r=new Promise(e=>n=e),i=e=>Zc(e,t,n);e.state.field(Jc,!1)?e.dispatch({effects:Yc.of(i)}):e.dispatch({effects:I.appendConfig.of(Jc.init(()=>[i]))});let a=Xc.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(Jc).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var Jc=Vt.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(Yc)?e=[n.value].concat(e):n.is(Xc)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>Kc.computeN([e],t=>t.field(e))}),Yc=I.define(),Xc=I.define();function Zc(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=ar(`form`),t.input){let e=ar(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(ar(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(ar(`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=ar(`div`,r,ar(`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 Qc=class extends Tn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Qc.prototype.elementClass=``,Qc.prototype.toDOM=void 0,Qc.prototype.mapMode=Ct.TrackBefore,Qc.prototype.startSide=Qc.prototype.endSide=-1,Qc.prototype.point=!0;var $c=F.define(),el=F.define(),tl={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>An.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},nl=F.define();function rl(e){return[al(),nl.of({...tl,...e})]}var il=F.define({combine:e=>e.some(e=>e)});function al(e){let t=[ol];return e&&e.fixed===!1&&t.push(il.of(!0)),t}var ol=qi.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(nl).map(t=>new ul(e,t)),this.fixed=!e.state.facet(il);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(il)!=!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=An.iter(this.view.state.facet($c),this.view.viewport.from),r=[],i=this.gutters.map(e=>new ll(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==Tr.Text&&t){cl(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==Tr.Text){cl(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(nl),n=e.state.facet(nl),r=e.docChanged||e.heightChanged||e.viewportChanged||!An.eq(e.startState.facet($c),e.state.facet($c),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 ul(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=>z.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==ai.LTR?{left:r,right:i}:{right:r,left:i}})});function sl(e){return Array.isArray(e)?e:[e]}function cl(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var ll=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=An.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 dl(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=[];cl(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(el)){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()}}},ul=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=sl(t.markers(e)),t.initialSpacer&&(this.spacer=new dl(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=sl(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!An.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()}},dl=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`:``),fl(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 fl(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 pl=F.define(),ml=F.define(),hl=F.define({combine(e){return wn(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}})}}),gl=class extends Qc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function _l(e,t){return e.state.facet(hl).formatNumber(t,e.state)}var vl=nl.compute([hl],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(pl)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new gl(_l(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(ml)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(hl)!=e.state.facet(hl),initialSpacer(e){return new gl(_l(e,bl(e.state.doc.lines)))},updateSpacer(e,t){let n=_l(t.view,bl(t.view.state.doc.lines));return n==e.number?e:new gl(n)},domEventHandlers:e.facet(hl).domEventHandlers,side:`before`}));function yl(e={}){return[hl.of(e),al(),vl]}function bl(e){let t=9;for(;t<e;)t=t*10+9;return t}var xl=1024,Sl=0,Cl=class{constructor(e,t){this.from=e,this.to=t}},B=class{constructor(e={}){this.id=Sl++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=El.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};B.closedBy=new B({deserialize:e=>e.split(` `)}),B.openedBy=new B({deserialize:e=>e.split(` `)}),B.group=new B({deserialize:e=>e.split(` `)}),B.isolate=new B({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),B.contextHash=new B({perNode:!0}),B.lookAhead=new B({perNode:!0}),B.mounted=new B({perNode:!0});var wl=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[B.mounted.id]}},Tl=Object.create(null),El=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):Tl,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(B.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(B.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};El.none=new El(``,Object.create(null),0,8);var Dl=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new El(e.name,r,e.id,e.flags):e)}return new e(n)}},Ol=new WeakMap,kl=new WeakMap,Al;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(Al||={});var jl=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=wl.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new Gl(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Gl(Ol.get(this)||this.topNode);return r.moveTo(e,t),Ol.set(this,r._tree),r}get topNode(){return new Ll(this,0,0,null)}resolve(e,t=0){let n=Fl(Ol.get(this)||this.topNode,e,t,!1);return Ol.set(this,n),n}resolveInner(e,t=0){let n=Fl(kl.get(this)||this.topNode,e,t,!0);return kl.set(this,n),n}resolveStack(e,t=0){return Wl(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&Al.IncludeAnonymous)>0;for(let e=this.cursor(a|Al.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:Xl(El.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(El.none,t,n,r)))}static build(e){return ql(e)}};jl.empty=new jl(El.none,[],[],0);var Ml=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},Nl=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return El.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(Pl(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function Pl(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Fl(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof Ll&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:Al.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof Ll&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var Il=class{cursor(e=0){return new Gl(this,e)}getChild(e,t=null,n=null){let r=Rl(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Rl(this,e,t,n)}resolve(e,t=0){return Fl(this,e,t,!1)}resolveInner(e,t=0){return Fl(this,e,t,!0)}matchContext(e){return zl(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},Ll=class e extends Il{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&Al.EnterBracketed&&l instanceof jl&&(d=wl.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!Pl(i,r,u,u+l.length))){if(l instanceof Nl){if(a&Al.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Vl(new Bl(o,l,t,u),null,e)}else if(a&Al.IncludeAnonymous||!l.type.isAnonymous||Kl(l)){let s;if(!(a&Al.IgnoreMounts)&&(s=wl.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&Al.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&Al.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&Al.IgnoreOverlays)&&(i=wl.get(this._tree))&&i.overlay){let a=t-this.from,o=r&Al.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Rl(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function zl(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Bl=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Vl=class e extends Il{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&Al.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new jl(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Hl(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof Ll&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Ul(i,n)}var Ul=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Hl(this.heads)}};function Wl(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof Ll?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=wl.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new Ll(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Fl(o,t,n,!1))}}return i?Hl(i):r}var Gl=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Al.EnterBracketed,e instanceof Ll)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Ll?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Al.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Al.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Al.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&Al.IncludeAnonymous||e instanceof Nl||!e.type.isAnonymous||Kl(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new Vl(this.buffer,t,this.stack[e]);return this.bufferNode=new Vl(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return zl(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return zl(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function Kl(e){return e.children.some(e=>e instanceof Nl||!e.type.isAnonymous||Kl(e))}function ql(e){let{buffer:t,nodeSet:n,maxBufferLength:r=xl,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Ml(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0)if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(w==-3){c=x;return}else if(w==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${w}`);let ee=s[x],D,O,te=S-e;if(C-S<=r&&(O=h(o.pos-t,y))){let t=new Uint16Array(O.size-O.skip),r=o.pos-O.size,i=t.length;for(;o.pos>r;)i=g(O.start,t,i);D=new Nl(t,C-O.start,n),te=O.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(ee,E);D=Xl(ee,t,n,0,t.length,0,C-S,e,e)}else D=m(ee,t,n,C-S,T-C,E)}_.push(D),v.push(te)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Nl(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof jl){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(B.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[B.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[B.lookAhead,i];o=o?[e].concat(o):[e]}return new jl(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new jl(s[e.topID],_.reverse(),v.reverse(),y)}var Jl=new WeakMap;function Yl(e,t){if(!e.isAnonymous||t instanceof Nl||t.type!=e)return 1;let n=Jl.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof jl)){n=1;break}n+=Yl(e,r)}Jl.set(t,n)}return n}function Xl(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=Yl(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=Yl(e,t[s]);for(s++;s<i;s++){let n=Yl(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(Xl(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var Zl=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof Vl?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ll&&this.map.set(e.tree,t)}get(e){return e instanceof Vl?this.getBuffer(e.context.buffer,e.index):e instanceof Ll?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Ql=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},$l=class{startParse(e,t,n){return typeof e==`string`&&(e=new eu(e)),n=n?n.length?n.map(e=>new Cl(e.from,e.to)):[new Cl(0,0)]:[new Cl(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},eu=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function tu(e){return(t,n,r,i)=>new ou(t,e,n,r,i)}var nu=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function ru(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var iu=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},au=new B({perNode:!0}),ou=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new jl(e.type,e.children,e.positions,e.length,e.propValues.concat([[au,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[B.mounted.id]=new wl(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new du(this.fragments),t=null,n=null,r=new Gl(new Ll(this.baseTree,this.ranges[0].from,0,null),Al.IncludeAnonymous|Al.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=su(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||(lu(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new iu(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=fu(this.ranges,i.overlay||(r.from<r.to?[new Cl(r.from,r.to)]:[]));e.length&&ru(e),(e.length||!i.overlay)&&this.inner.push(new nu(i.parser,e.length?i.parser.startParse(this.input,mu(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new Cl(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new Cl(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=fu(this.ranges,t.ranges);e.length&&(ru(e),this.inner.splice(t.index,0,new nu(t.parser,t.parser.startParse(this.input,mu(t.mounts,e),e),t.ranges.map(e=>new Cl(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function su(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function cu(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function lu(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];cu(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),cu(o,s[f+3],r,p,m,a),new jl(i,p,m,u)}i.children[a]=l(0,s.length,El.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new Ll(n,r+e.from,t,e._tree))}}var uu=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(Al.IncludeAnonymous|Al.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,Al.IgnoreOverlays|Al.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof jl)t=t.children[0];else break}return!1}},du=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(au)??t.to,this.inner=new uu(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(au)??e.to,this.inner=new uu(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(B.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function fu(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new Cl(e.from,o),e.to>s&&n.splice(a+1,0,new Cl(s,e.to))):e.to>s?n[a--]=new Cl(s,e.to):n.splice(a--,1))}}return r}function pu(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new Cl(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function mu(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=pu(t,i.overlay.map(e=>new Cl(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new Ql(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new Ql(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var hu=0,gu=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=hu++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new vu(e);return e=>e.modified.indexOf(t)>-1?e:vu.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},_u=0,vu=class e{constructor(e){this.name=e,this.instances=[],this.id=_u++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&yu(n,e.modified));if(r)return r;let i=[],a=new gu(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=bu(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function yu(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function bu(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function xu(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new Cu(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Su.add(t)}var Su=new B({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new Cu(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),Cu=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Cu.empty=new Cu([],2,null);function wu(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Tu(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Eu(e,t,n,r=0,i=e.length){let a=new Du(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Du=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Ou(e)||Cu.empty,u=Tu(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(B.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Ou(e){let t=e.type.prop(Su);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var V=gu.define,ku=V(),Au=V(),ju=V(Au),Mu=V(Au),Nu=V(),Pu=V(Nu),Fu=V(Nu),Iu=V(),Lu=V(Iu),Ru=V(),zu=V(),Bu=V(),Vu=V(Bu),Hu=V(),H={comment:ku,lineComment:V(ku),blockComment:V(ku),docComment:V(ku),name:Au,variableName:V(Au),typeName:ju,tagName:V(ju),propertyName:Mu,attributeName:V(Mu),className:V(Au),labelName:V(Au),namespace:V(Au),macroName:V(Au),literal:Nu,string:Pu,docString:V(Pu),character:V(Pu),attributeValue:V(Pu),number:Fu,integer:V(Fu),float:V(Fu),bool:V(Nu),regexp:V(Nu),escape:V(Nu),color:V(Nu),url:V(Nu),keyword:Ru,self:V(Ru),null:V(Ru),atom:V(Ru),unit:V(Ru),modifier:V(Ru),operatorKeyword:V(Ru),controlKeyword:V(Ru),definitionKeyword:V(Ru),moduleKeyword:V(Ru),operator:zu,derefOperator:V(zu),arithmeticOperator:V(zu),logicOperator:V(zu),bitwiseOperator:V(zu),compareOperator:V(zu),updateOperator:V(zu),definitionOperator:V(zu),typeOperator:V(zu),controlOperator:V(zu),punctuation:Bu,separator:V(Bu),bracket:Vu,angleBracket:V(Vu),squareBracket:V(Vu),paren:V(Vu),brace:V(Vu),content:Iu,heading:Lu,heading1:V(Lu),heading2:V(Lu),heading3:V(Lu),heading4:V(Lu),heading5:V(Lu),heading6:V(Lu),contentSeparator:V(Iu),list:V(Iu),quote:V(Iu),emphasis:V(Iu),strong:V(Iu),link:V(Iu),monospace:V(Iu),strikethrough:V(Iu),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:Hu,documentMeta:V(Hu),annotation:V(Hu),processingInstruction:V(Hu),definition:gu.defineModifier(`definition`),constant:gu.defineModifier(`constant`),function:gu.defineModifier(`function`),standard:gu.defineModifier(`standard`),local:gu.defineModifier(`local`),special:gu.defineModifier(`special`)};for(let e in H){let t=H[e];t instanceof gu&&(t.name=e)}wu([{tag:H.link,class:`tok-link`},{tag:H.heading,class:`tok-heading`},{tag:H.emphasis,class:`tok-emphasis`},{tag:H.strong,class:`tok-strong`},{tag:H.keyword,class:`tok-keyword`},{tag:H.atom,class:`tok-atom`},{tag:H.bool,class:`tok-bool`},{tag:H.url,class:`tok-url`},{tag:H.labelName,class:`tok-labelName`},{tag:H.inserted,class:`tok-inserted`},{tag:H.deleted,class:`tok-deleted`},{tag:H.literal,class:`tok-literal`},{tag:H.string,class:`tok-string`},{tag:H.number,class:`tok-number`},{tag:[H.regexp,H.escape,H.special(H.string)],class:`tok-string2`},{tag:H.variableName,class:`tok-variableName`},{tag:H.local(H.variableName),class:`tok-variableName tok-local`},{tag:H.definition(H.variableName),class:`tok-variableName tok-definition`},{tag:H.special(H.variableName),class:`tok-variableName2`},{tag:H.definition(H.propertyName),class:`tok-propertyName tok-definition`},{tag:H.typeName,class:`tok-typeName`},{tag:H.namespace,class:`tok-namespace`},{tag:H.className,class:`tok-className`},{tag:H.macroName,class:`tok-macroName`},{tag:H.propertyName,class:`tok-propertyName`},{tag:H.operator,class:`tok-operator`},{tag:H.comment,class:`tok-comment`},{tag:H.meta,class:`tok-meta`},{tag:H.invalid,class:`tok-invalid`},{tag:H.punctuation,class:`tok-punctuation`}]);var Uu=new B;function Wu(e){return F.define({combine:e?t=>t.concat(e):void 0})}var Gu=new B,Ku=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,Cn.prototype.hasOwnProperty(`tree`)||Object.defineProperty(Cn.prototype,`tree`,{get(){return Yu(this)}}),this.parser=t,this.extension=[od.of(this),Cn.languageData.of((e,t,n)=>{let r=qu(e,t,n),i=r.type.prop(Uu);if(!i)return[];let a=e.facet(i),o=r.type.prop(Gu);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 qu(e,t,n).type.prop(Uu)==this.data}findRegions(e){let t=e.facet(od);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(Uu)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(B.mounted);if(i){if(i.tree.prop(Uu)==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}else 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 jl&&r(i,e.positions[n]+t)}};return r(Yu(e),0),n}get allowsNesting(){return!0}};Ku.setState=I.define();function qu(e,t,n){let r=e.facet(od),i=Yu(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,Al.ExcludeBuffers|Al.EnterBracketed))e.type.isTop&&(i=e);return i}var Ju=class e extends Ku{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=Wu(t.languageData);return new e(n,t.parser.configure({props:[Uu.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 Yu(e){let t=e.field(Ku.state,!1);return t?t.tree:jl.empty}function Xu(e,t,n=50){let r=e.field(Ku.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function Zu(e,t=e.viewport.to,n=100){let r=Xu(e.state,t,n);return r!=Yu(e.state)&&e.dispatch({}),!!r}var Qu=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)}},$u=null,ed=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,[],jl.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Qu(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=jl.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(Ql.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(Ql.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=$u;$u=this;try{return e()}finally{$u=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=td(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=Ql.applyChanges(r,e),i=jl.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=td(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 $l{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=$u;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 jl(El.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 $u}};function td(e,t,n){return Ql.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var nd=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=ed.create(t.facet(od).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};Ku.state=Vt.define({create:nd.init,update(e,t){for(let e of t.effects)if(e.is(Ku.setState))return e.value;return t.startState.facet(od)==t.state.facet(od)?e.apply(t):nd.init(t.state)}});var rd=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(rd=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var id=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,ad=qi.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(Ku.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(Ku.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=rd(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(Ku.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!id?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>id&&id()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Ku.setState.of(new nd(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=>Ui(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),od=F.define({combine(e){return e.length?e[0]:null},enables:e=>[Ku.state,ad,z.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),sd=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},cd=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}},ld=F.define(),ud=F.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 dd(e){let t=e.facet(ud);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function fd(e,t){let n=``,r=e.tabSize,i=e.facet(ud)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function pd(e,t){e instanceof Cn&&(e=new md(e));for(let n of e.state.facet(ld)){let r=n(e,t);if(r!==void 0)return r}let n=Yu(e.state);return n.length>=t?gd(e,n,t):null}var md=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=dd(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 Un(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}},hd=new B;function gd(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 _d(r,e,n)}function _d(e,t,n){for(let r=e;r;r=r.next){let e=yd(r.node);if(e)return e(xd.create(t,n,r))}return 0}function vd(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function yd(e){let t=e.type.prop(hd);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(B.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Td(e,!0,1,void 0,n&&!vd(e)?t.from:void 0)}return e.parent==null?bd:null}function bd(){return 0}var xd=class e extends md{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(Sd(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return _d(this.context.next,this.base,this.pos)}};function Sd(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Cd(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 wd({closing:e,align:t=!0,units:n=1}){return r=>Td(r,t,n,e)}function Td(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?Cd(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Ed=e=>e.baseIndent;function Dd({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Od=F.define(),kd=new B;function Ad(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 jd(e,t,n){let r=Yu(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(kd);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Md(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Md(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Nd(e,t,n){for(let r of e.facet(Od)){let i=r(e,t,n);if(i)return i}return jd(e,t,n)}function Pd(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 Fd=I.define({map:Pd}),Id=I.define({map:Pd});function Ld(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 Rd=Vt.define({create(){return R.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=zd(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(Fd)&&!Vd(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Jd),i=r?R.replace({widget:new Qd(r(t.state,n.value))}):Zd;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Id)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=zd(e,t.selection.main.head)),e},provide:e=>z.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(Zd.range(r,i))}return R.set(t,!0)}});function zd(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 Bd(e,t,n){var r;let i=null;return(r=e.field(Rd,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Vd(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function Hd(e,t){return e.field(Rd,!1)?t:t.concat(I.appendConfig.of(Yd()))}var Ud=e=>{for(let t of Ld(e)){let n=Nd(e.state,t.from,t.to);if(n)return e.dispatch({effects:Hd(e.state,[Fd.of(n),Gd(e,n)])}),!0}return!1},Wd=e=>{if(!e.state.field(Rd,!1))return!1;let t=[];for(let n of Ld(e)){let r=Bd(e.state,n.from,n.to);r&&t.push(Id.of(r),Gd(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Gd(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return z.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var Kd=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Ud},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Wd},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=Nd(t,i.from,i.to);a&&n.push(Fd.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Hd(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(Rd,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(Id.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],qd={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},Jd=F.define({combine(e){return wn(e,qd)}});function Yd(e){let t=[Rd,nf];return e&&t.push(Jd.of(e)),t}function Xd(e,t){let{state:n}=e,r=n.facet(Jd),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Bd(e.state,n.from,n.to);r&&e.dispatch({effects:Id.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 Zd=R.replace({widget:new class extends wr{toDOM(e){return Xd(e,null)}}}),Qd=class extends wr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Xd(e,this.value)}},$d={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},ef=class extends Qc{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 tf(e={}){let t={...$d,...e},n=new ef(t,!0),r=new ef(t,!1),i=qi.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(od)!=e.state.facet(od)||e.startState.field(Rd,!1)!=e.state.field(Rd,!1)||Yu(e.startState)!=Yu(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new Mn;for(let i of e.viewportLineBlocks){let a=Bd(e.state,i.from,i.to)?r:Nd(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,rl({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||An.empty},initialSpacer(){return new ef(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=Bd(e.state,t.from,t.to);if(r)return e.dispatch({effects:Id.of(r)}),!0;let i=Nd(e.state,t.from,t.to);return i?(e.dispatch({effects:Fd.of(i)}),!0):!1}}}),Yd()]}var nf=z.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`}}),rf=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=Yn.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 Ku?e=>e.prop(Uu)==a.data:a?e=>e==a:void 0,this.style=wu(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Yn(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},af=F.define(),of=F.define({combine(e){return e.length?[e[0]]:null}});function sf(e){let t=e.facet(af);return t.length?t:e.facet(of)}function cf(e,t){let n=[uf],r;return e instanceof rf&&(e.module&&n.push(z.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(of.of(e)):r?n.push(af.computeN([z.darkTheme],t=>t.facet(z.darkTheme)==(r==`dark`)?[e]:[])):n.push(af.of(e)),n}var lf=class{constructor(e){this.markCache=Object.create(null),this.tree=Yu(e.state),this.decorations=this.buildDeco(e,sf(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Yu(e.state),n=sf(e.state),r=n!=sf(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 R.none;let n=new Mn;for(let{from:r,to:i}of e.visibleRanges)Eu(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=R.mark({class:r})))},r,i);return n.finish()}},uf=Wt.high(qi.fromClass(lf,{decorations:e=>e.decorations}));H.meta,H.link,H.heading,H.emphasis,H.strong,H.strikethrough,H.keyword,H.atom,H.bool,H.url,H.contentSeparator,H.labelName,H.literal,H.inserted,H.string,H.deleted,H.regexp,H.escape,H.string,H.variableName,H.variableName,H.typeName,H.namespace,H.className,H.variableName,H.macroName,H.propertyName,H.comment,H.invalid;var df=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),ff=1e4,pf=`()[]{}`,mf=F.define({combine(e){return wn(e,{afterCursor:!0,brackets:pf,maxScanDistance:ff,renderMatch:_f})}}),hf=R.mark({class:`cm-matchingBracket`}),gf=R.mark({class:`cm-nonmatchingBracket`});function _f(e){let t=[],n=e.matched?hf:gf;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 vf(e){let t=[],n=e.facet(mf);for(let r of e.selection.ranges){if(!r.empty)continue;let i=wf(e,r.head,-1,n)||r.head>0&&wf(e,r.head-1,1,n)||n.afterCursor&&(wf(e,r.head,1,n)||r.head<e.doc.length&&wf(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return R.set(t,!0)}var yf=[qi.fromClass(class{constructor(e){this.paused=!1,this.decorations=vf(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=vf(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),df];function bf(e={}){return[mf.of(e),yf]}var xf=new B;function Sf(e,t,n){let r=e.prop(t<0?B.openedBy:B.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 Cf(e){let t=e.type.prop(xf);return t?t(e.node):e}function wf(e,t,n,r={}){let i=r.maxScanDistance||ff,a=r.brackets||pf,o=Yu(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Sf(r.type,n,a);if(i&&r.from<r.to){let o=Cf(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Tf(e,t,n,r,o,i,a)}}return Ef(e,t,n,o,s.type,i,a)}function Tf(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=Cf(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(Sf(u.type,n,o))l++;else if(Sf(u.type,-n,o)){if(l==0){let e=Cf(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 Ef(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 Df=Object.create(null),Of=[El.none],kf=[],Af=Object.create(null),jf=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`]])jf[e]=Nf(Df,t);function Mf(e,t){kf.indexOf(e)>-1||(kf.push(e),console.warn(t))}function Nf(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||H[n];r?typeof r==`function`?t.length?t=t.map(r):Mf(n,`Modifier ${n} used at start of tag`):t.length?Mf(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Mf(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=Af[i];if(a)return a.id;let o=Af[i]=El.define({id:Of.length,name:r,props:[xu({[r]:n})]});return Of.push(o),o.id}ai.RTL,ai.LTR;var Pf=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=zf(e.state,n.from);return r.line?If(e):r.block?Rf(e):!1};function Ff(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 If=Ff(Wf,0),Lf=Ff(Uf,0),Rf=Ff((e,t)=>Uf(e,t,Hf(t)),0);function zf(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Bf=50;function Vf(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Bf,r),o=e.sliceDoc(i,i+Bf),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<=2*Bf?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Bf),d=e.sliceDoc(i-Bf,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 Hf(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 Uf(e,t,n=t.selection.ranges){let r=n.map(e=>zf(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Vf(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 Wf(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=zf(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)}}else 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 Gf=on.define(),Kf=on.define(),qf=F.define(),Jf=F.define({combine(e){return wn(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)})}}),Yf=Vt.define({create(){return mp.empty},update(e,t){let n=t.state.facet(Jf),r=t.annotation(Gf);if(r){let i=np.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?rp(o,o.length,n.minDepth,i):lp(o,t.startState.selection),new mp(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Kf);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(ln.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=np.fromTransaction(t),o=t.annotation(ln.time),s=t.annotation(ln.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 mp(e.done.map(np.fromJSON),e.undone.map(np.fromJSON))}});function Xf(e={}){return[Yf,Jf.of(e),z.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Qf:e.inputType==`historyRedo`?$f:null;return n?(e.preventDefault(),n(t)):!1}})]}function Zf(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Yf,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Qf=Zf(0,!1),$f=Zf(1,!1),ep=Zf(0,!0),tp=Zf(1,!0),np=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&&Tt.fromJSON(t.changes),[],t.mapped&&wt.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,n){let r=sp;for(let e of t.startState.facet(qf)){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,sp)}static selection(t){return new e(void 0,sp,void 0,void 0,t)}};function rp(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 ip(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 ap(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function op(e,t){return e.length?t.length?e.concat(t):e:t}var sp=[],cp=200;function lp(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-cp));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),rp(e,e.length-1,1e9,n.setSelAfter(r)))}else return[np.selection([t])]}function up(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 dp(e,t){if(!e.length)return e;let n=e.length,r=sp;for(;n;){let i=fp(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}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[np.selection(r)]:sp}function fp(e,t,n){let r=op(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):sp,n);if(!e.changes)return np.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new np(i,I.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var pp=/^(input\.type|delete)($|\.)/,mp=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||pp.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ip(s.changes,t.changes))||r==`input.type.compose`)?rp(o,o.length-1,i.minDepth,new np(t.changes.compose(s.changes),op(I.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,sp)):rp(o,o.length,i.minDepth,t),new e(o,sp,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:sp;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&ap(a[a.length-1],t)?this:new e(lp(this.done,t),this.undone,n,r)}addMapping(t){return new e(dp(this.done,t),dp(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:Gf.of({side:e,rest:up(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?sp:r.slice(0,r.length-1);return i.mapped&&(n=dp(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Gf.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};mp.empty=new mp(sp,sp);var hp=[{key:`Mod-z`,run:Qf,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:$f,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:$f,preventDefault:!0},{key:`Mod-u`,run:ep,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:tp,preventDefault:!0}];function gp(e,t){return P.create(e.ranges.map(t),e.mainIndex)}function _p(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function vp({state:e,dispatch:t},n){let r=gp(e.selection,n);return r.eq(e.selection,!0)?!1:(t(_p(e,r)),!0)}function yp(e,t){return P.cursor(t?e.to:e.from)}function bp(e,t){return vp(e,n=>n.empty?e.moveByChar(n,t):yp(n,t))}function xp(e){return e.textDirectionAt(e.state.selection.main.head)==ai.LTR}var Sp=e=>bp(e,!xp(e)),Cp=e=>bp(e,xp(e));function wp(e,t){return vp(e,n=>n.empty?e.moveByGroup(n,t):yp(n,t))}var Tp=e=>wp(e,!xp(e)),Ep=e=>wp(e,xp(e));typeof Intl<`u`&&Intl.Segmenter;function Dp(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 Op(e,t,n){let r=Yu(e).resolveInner(t.head),i=n?B.closedBy:B.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Dp(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?wf(e,r.from,1):wf(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,P.cursor(s,n?-1:1)}var kp=e=>vp(e,t=>Op(e.state,t,!xp(e))),Ap=e=>vp(e,t=>Op(e.state,t,xp(e)));function jp(e,t){return vp(e,n=>{if(!n.empty)return yp(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Mp=e=>jp(e,!1),Np=e=>jp(e,!0);function Pp(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(z.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 Fp(e,t){let n=Pp(e),{state:r}=e,i=gp(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):yp(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=z.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(_p(r,i),{effects:a}),!0}var Ip=e=>Fp(e,!1),Lp=e=>Fp(e,!0);function Rp(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=P.cursor(r.from+n))}return i}var zp=e=>vp(e,t=>Rp(e,t,!0)),Bp=e=>vp(e,t=>Rp(e,t,!1)),Vp=e=>vp(e,t=>Rp(e,t,!xp(e))),Hp=e=>vp(e,t=>Rp(e,t,xp(e))),Up=e=>vp(e,t=>P.cursor(e.lineBlockAt(t.head).from,1)),Wp=e=>vp(e,t=>P.cursor(e.lineBlockAt(t.head).to,-1));function Gp(e,t,n){let r=!1,i=gp(e.selection,t=>{let i=wf(e,t.head,-1)||wf(e,t.head,1)||t.head>0&&wf(e,t.head-1,1)||t.head<e.doc.length&&wf(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?P.range(t.anchor,a):P.cursor(a)});return r?(t(_p(e,i)),!0):!1}var Kp=({state:e,dispatch:t})=>Gp(e,t,!1);function qp(e,t){let n=gp(e.state.selection,e=>{let n=t(e);return P.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(_p(e.state,n)),!0)}function Jp(e,t){return qp(e,n=>e.moveByChar(n,t))}var Yp=e=>Jp(e,!xp(e)),Xp=e=>Jp(e,xp(e));function Zp(e,t){return qp(e,n=>e.moveByGroup(n,t))}var Qp=e=>Zp(e,!xp(e)),$p=e=>Zp(e,xp(e)),em=e=>qp(e,t=>Op(e.state,t,!xp(e))),tm=e=>qp(e,t=>Op(e.state,t,xp(e)));function nm(e,t){return qp(e,n=>e.moveVertically(n,t))}var rm=e=>nm(e,!1),im=e=>nm(e,!0);function am(e,t){return qp(e,n=>e.moveVertically(n,t,Pp(e).height))}var om=e=>am(e,!1),sm=e=>am(e,!0),cm=e=>qp(e,t=>Rp(e,t,!0)),lm=e=>qp(e,t=>Rp(e,t,!1)),um=e=>qp(e,t=>Rp(e,t,!xp(e))),dm=e=>qp(e,t=>Rp(e,t,xp(e))),fm=e=>qp(e,t=>P.cursor(e.lineBlockAt(t.head).from)),pm=e=>qp(e,t=>P.cursor(e.lineBlockAt(t.head).to)),mm=({state:e,dispatch:t})=>(t(_p(e,{anchor:0})),!0),hm=({state:e,dispatch:t})=>(t(_p(e,{anchor:e.doc.length})),!0),gm=({state:e,dispatch:t})=>(t(_p(e,{anchor:e.selection.main.anchor,head:0})),!0),_m=({state:e,dispatch:t})=>(t(_p(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),vm=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ym=({state:e,dispatch:t})=>{let n=Rm(e).map(({from:t,to:n})=>P.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:P.create(n),userEvent:`select`})),!0},bm=({state:e,dispatch:t})=>{let n=gp(e.selection,t=>{let n=Yu(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 P.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(_p(e,n)),!0)};function xm(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}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(_p(n,P.create(i,i.length-1))),!0)}var Sm=e=>xm(e,!1),Cm=e=>xm(e,!0),wm=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=P.create([n.main]):n.main.empty||(r=P.create([P.cursor(n.main.head)])),r?(t(_p(e,r)),!0):!1};function Tm(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=Em(e,o,!1)):o>i&&(n=`delete.forward`,o=Em(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Em(e,i,!1),a=Em(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:P.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?z.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Em(e,t,n){if(e instanceof z)for(let r of e.state.facet(z.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Dm=(e,t,n)=>Tm(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=Un(s,a.tabSize)%dd(a)||dd(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=gt(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=gt(o.text,c-o.from,!1,!1)+o.from);return c}),Om=e=>Dm(e,!1,!0),km=e=>Dm(e,!0,!1),Am=(e,t)=>Tm(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=gt(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}),jm=e=>Am(e,!1),Mm=e=>Am(e,!0),Nm=e=>Tm(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Pm=e=>Tm(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Fm=e=>Tm(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Im=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:at.of([``,``])},range:P.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Lm=({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:gt(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:gt(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:P.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Rm(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 zm(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Rm(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(P.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(P.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:P.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Bm=({state:e,dispatch:t})=>zm(e,t,!1),Vm=({state:e,dispatch:t})=>zm(e,t,!0);function Hm(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Rm(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 Um=({state:e,dispatch:t})=>Hm(e,t,!1),Wm=({state:e,dispatch:t})=>Hm(e,t,!0),Gm=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Rm(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=gp(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 Km(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Yu(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(B.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 qm=Ym(!1),Jm=Ym(!0);function Ym(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&&Km(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new md(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=pd(s,r);for(c??=Un(/^\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=[``,fd(t,c)];return o&&l.push(fd(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:at.of(l)},range:P.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Xm(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:P.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Zm=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new md(e,{overrideIndentation:e=>n[e]??-1}),i=Xm(e,(t,i,a)=>{let o=pd(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=fd(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},Qm=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Xm(e,(t,n)=>{n.push({from:t.from,insert:e.facet(ud)})}),{userEvent:`input.indent`})),!0),$m=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Xm(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Un(r,e.tabSize),a=0,o=fd(e,Math.max(0,i-dd(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),eh=e=>(e.setTabFocusMode(),!0),th=[{key:`Ctrl-b`,run:Sp,shift:Yp,preventDefault:!0},{key:`Ctrl-f`,run:Cp,shift:Xp},{key:`Ctrl-p`,run:Mp,shift:rm},{key:`Ctrl-n`,run:Np,shift:im},{key:`Ctrl-a`,run:Up,shift:fm},{key:`Ctrl-e`,run:Wp,shift:pm},{key:`Ctrl-d`,run:km},{key:`Ctrl-h`,run:Om},{key:`Ctrl-k`,run:Nm},{key:`Ctrl-Alt-h`,run:jm},{key:`Ctrl-o`,run:Im},{key:`Ctrl-t`,run:Lm},{key:`Ctrl-v`,run:Lp}],nh=[{key:`ArrowLeft`,run:Sp,shift:Yp,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Tp,shift:Qp,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Vp,shift:um,preventDefault:!0},{key:`ArrowRight`,run:Cp,shift:Xp,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ep,shift:$p,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Hp,shift:dm,preventDefault:!0},{key:`ArrowUp`,run:Mp,shift:rm,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:mm,shift:gm},{mac:`Ctrl-ArrowUp`,run:Ip,shift:om},{key:`ArrowDown`,run:Np,shift:im,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:hm,shift:_m},{mac:`Ctrl-ArrowDown`,run:Lp,shift:sm},{key:`PageUp`,run:Ip,shift:om},{key:`PageDown`,run:Lp,shift:sm},{key:`Home`,run:Bp,shift:lm,preventDefault:!0},{key:`Mod-Home`,run:mm,shift:gm},{key:`End`,run:zp,shift:cm,preventDefault:!0},{key:`Mod-End`,run:hm,shift:_m},{key:`Enter`,run:qm,shift:qm},{key:`Mod-a`,run:vm},{key:`Backspace`,run:Om,shift:Om,preventDefault:!0},{key:`Delete`,run:km,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:jm,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Mm,preventDefault:!0},{mac:`Mod-Backspace`,run:Pm,preventDefault:!0},{mac:`Mod-Delete`,run:Fm,preventDefault:!0}].concat(th.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),rh=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:kp,shift:em},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Ap,shift:tm},{key:`Alt-ArrowUp`,run:Bm},{key:`Shift-Alt-ArrowUp`,run:Um},{key:`Alt-ArrowDown`,run:Vm},{key:`Shift-Alt-ArrowDown`,run:Wm},{key:`Mod-Alt-ArrowUp`,run:Sm},{key:`Mod-Alt-ArrowDown`,run:Cm},{key:`Escape`,run:wm},{key:`Mod-Enter`,run:Jm},{key:`Alt-l`,mac:`Ctrl-l`,run:ym},{key:`Mod-i`,run:bm,preventDefault:!0},{key:`Mod-[`,run:$m},{key:`Mod-]`,run:Qm},{key:`Mod-Alt-\\`,run:Zm},{key:`Shift-Mod-k`,run:Gm},{key:`Shift-Mod-\\`,run:Kp},{key:`Mod-/`,run:Pf},{key:`Alt-A`,run:Lf},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:eh}].concat(nh),ih=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=Yu(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(dh(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 ah(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 oh(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=ah(t)+ah(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function sh(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:oh(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function ch(e,t){return n=>{for(let t=Yu(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 lh=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function uh(e){return e.selection.main.from}function dh(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 fh=on.define();function ph(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:P.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var mh=new WeakMap;function hh(e){if(!Array.isArray(e))return e;let t=mh.get(e);return t||mh.set(e,t=sh(e)),t}var gh=I.define(),_h=I.define(),vh=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=yt(e,t),r=xt(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(yt(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=yt(e,0),i=xt(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=yt(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=xt(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=yt(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=bt(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+=xt(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?xt(yt(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)}},yh=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)}},bh=F.define({combine(e){return wn(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:Sh,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=>xh(e(n),t(n)),optionClass:(e,t)=>n=>xh(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function xh(e,t){return e?t?e+` `+t:e:t}function Sh(e,t,n,r,i,a){let o=e.textDirection==ai.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 Ch=I.define();function wh(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 Th(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 Eh=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(bh);this.optionContent=wh(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Th(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:Ch.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(bh).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:_h.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=Th(r.length,i,e.state.facet(bh).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=Th(t.options.length,t.selected,this.view.state.facet(bh).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=>Ui(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&&Oh(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(bh).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 Dh(e,t){return n=>new Eh(n,e,t)}function Oh(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 kh(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Ah(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(bh);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 lh(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new yh(n):new vh(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 lh(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):kh(e.completion)>kh(c)&&(s[s.length-1]=e),c=e.completion}return s}var jh=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,Ih(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=Ah(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(bh).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,Ih(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Gh,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)}},Mh=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Lh,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(bh),i=(r.override||n.languageDataAt(`autocomplete`,uh(n)).map(hh)).map(e=>(this.active.find(t=>t.source==e)||new zh(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(Hh));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Nh(i,this.active)||o?a=jh.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 zh(e.source,0):e));for(let e of t.effects)e.is(Ch)&&(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?Ph:Fh}};function Nh(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 Ph={"aria-autocomplete":`list`},Fh={};function Ih(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Lh=[];function Rh(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(fh);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 zh=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=Rh(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(gh))i=new e(i.source,1,n.value);else if(n.is(_h))i=new e(i.source,0);else if(n.is(Hh))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(uh(e.state))}},Bh=class e extends zh{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=uh(t.state);if(o>a||!r||n&2&&(uh(t.startState)==this.from||o<this.limit))return new zh(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Vh(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 ih(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??uh(t.state)):new zh(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new zh(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Vh(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):dh(e,!0).test(i)}var Hh=I.define({map(e,t){return e.map(e=>e.map(t))}}),Uh=Vt.define({create(){return Mh.start()},update(e,t){return e.update(t)},provide:e=>[kc.from(e,e=>e.tooltip),z.contentAttributes.from(e,e=>e.attrs)]});function Wh(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(Uh).active.find(e=>e.source==t.source);return r instanceof Bh?(typeof n==`string`?e.dispatch({...ph(e.state,n,r.from,r.to),annotations:fh.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var Gh=Dh(Uh,Wh);function Kh(e,t=`option`){return n=>{let r=n.state.field(Uh,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(bh).interactionDelay)return!1;let i=1,a;t==`page`&&(a=zc(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:Ch.of(s)}),!0}}var qh=e=>{let t=e.state.field(Uh,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(bh).interactionDelay?!1:Wh(e,t.open.options[t.open.selected])},Jh=e=>e.state.field(Uh,!1)?(e.dispatch({effects:gh.of(!0)}),!0):!1,Yh=e=>{let t=e.state.field(Uh,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:_h.of(null)}),!0)},Xh=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Zh=50,Qh=1e3,$h=qi.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(Uh).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Uh),n=e.state.facet(bh);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Uh)==t)return;let r=e.transactions.some(e=>{let t=Rh(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>Zh&&Date.now()-n.time>Qh){for(let e of n.context.abortListeners)try{e()}catch(e){Ui(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(gh)))&&(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(Uh);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(bh).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new ih(t,uh(t),e.explicit,this.view),r=new Xh(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:_h.of(null)}),Ui(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(bh).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(bh),n=this.view.state.field(Uh);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=uh(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new Bh(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 zh(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:Hh.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Uh,!1);if(t&&t.tooltip&&this.view.state.facet(bh).closeOnBlur){let n=t.open&&zc(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:_h.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:gh.of(!1)}),20),this.composing=0}}}),eg=typeof navigator==`object`&&/Win/.test(navigator.platform),tg=Wt.highest(z.domEventHandlers({keydown(e,t){let n=t.state.field(Uh,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(eg&&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&&Wh(t,r),!1}})),ng=z.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`}}}),rg=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},ig=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,Ct.TrackDel),r=t.mapPos(this.to,1,Ct.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},ag=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(ud);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 ig(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,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 rg(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)}},og=R.widget({widget:new class extends wr{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),sg=R.mark({class:`cm-snippetField`}),cg=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=R.set(e.map(e=>(e.from==e.to?og:sg).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))}},lg=I.define({map(e,t){return e&&e.map(t)}}),ug=I.define(),dg=Vt.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(lg))return n.value;if(n.is(ug)&&e)return new cg(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=>z.decorations.from(e,e=>e?e.deco:R.none)});function fg(e,t){return P.create(e.filter(e=>e.field==t).map(e=>P.range(e.from,e.to)))}function pg(e){let t=ag.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:at.of(a)},scrollIntoView:!0,annotations:n?[fh.of(n),ln.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=fg(o,0)),o.some(e=>e.field>0)){let t=new cg(o,0),n=c.effects=[lg.of(t)];e.state.field(dg,!1)===void 0&&n.push(I.appendConfig.of([dg,_g,yg,ng]))}e.dispatch(e.state.update(c))}}function mg(e){return({state:t,dispatch:n})=>{let r=t.field(dg,!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:fg(r.ranges,i),effects:lg.of(a?null:new cg(r.ranges,i)),scrollIntoView:!0})),!0}}var hg=[{key:`Tab`,run:mg(1),shift:mg(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(dg,!1)?(t(e.update({effects:lg.of(null)})),!0):!1}],gg=F.define({combine(e){return e.length?e[0]:hg}}),_g=Wt.highest(uc.compute([gg],e=>e.facet(gg)));function vg(e,t){return{...t,apply:pg(e)}}var yg=z.domEventHandlers({mousedown(e,t){let n=t.state.field(dg,!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:fg(n.ranges,i.field),effects:lg.of(n.ranges.some(e=>e.field>i.field)?new cg(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),bg=new class extends Tn{};bg.startSide=1,bg.endSide=-1,typeof navigator==`object`&&navigator.userAgent;function xg(e={}){return[tg,Uh,bh.of(e),$h,Cg,ng]}var Sg=[{key:`Ctrl-Space`,run:Jh},{mac:"Alt-`",run:Jh},{mac:`Alt-i`,run:Jh},{key:`Escape`,run:Yh},{key:`ArrowDown`,run:Kh(!0)},{key:`ArrowUp`,run:Kh(!1)},{key:`PageDown`,run:Kh(!0,`page`)},{key:`PageUp`,run:Kh(!1,`page`)},{key:`Enter`,run:qh}],Cg=Wt.highest(uc.computeN([bh],e=>e.facet(bh).defaultKeymap?[Sg]:[]));function wg(e){let t=e.field(Uh,!1);return t&&t.active.some(e=>e.isPending)?`pending`:t&&t.active.some(e=>e.state!=0)?`active`:null}var Tg=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,Eg=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(Tg(e)):Tg,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 yt(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=bt(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=xt(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`&&(Eg.prototype[Symbol.iterator]=function(){return this});var Dg={from:-1,to:-1,match:/.*/.exec(``),precise:!0},Og=`gm`+(/x/.unicode==null?``:`u`),kg=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Dg,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Mg(e,t,n,r,i);this.re=new RegExp(t,Og+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=Pg(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=Pg(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}}},Ag=new WeakMap,jg=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=Ag.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Ag.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)),Ag.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Mg=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Dg,this.matchPos=Pg(e,r),this.re=new RegExp(t,Og+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=jg.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=Pg(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=jg.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(kg.prototype[Symbol.iterator]=Mg.prototype[Symbol.iterator]=function(){return this});function Ng(e){try{return new RegExp(e,Og),!0}catch{return!1}}function Pg(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 Fg=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=qc(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,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/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=P.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,z.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Ig={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Lg=F.define({combine(e){return wn(e,Ig,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Rg(e){let t=[Wg,Ug];return e&&t.push(Lg.of(e)),t}var zg=R.mark({class:`cm-selectionMatch`}),Bg=R.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Vg(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=vn.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=vn.Word)}function Hg(e,t,n,r){return e(t.sliceDoc(n,n+1))==vn.Word&&e(t.sliceDoc(r-1,r))==vn.Word}var Ug=qi.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(Lg),{state:n}=e,r=n.selection;if(r.ranges.length>1)return R.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return R.none;let e=n.wordAt(i.head);if(!e)return R.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 R.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Vg(o,n,i.from,i.to)&&Hg(o,n,i.from,i.to)))return R.none}else if(a=n.sliceDoc(i.from,i.to),!a)return R.none}let s=[];for(let r of e.visibleRanges){let e=new Eg(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Vg(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Bg.range(r,a)):(r>=i.to||a<=i.from)&&s.push(zg.range(r,a)),s.length>t.maxMatches))return R.none}}return R.set(s)}},{decorations:e=>e.decorations}),Wg=z.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Gg=({state:e,dispatch:t})=>{let{selection:n}=e,r=P.create(n.ranges.map(t=>e.wordAt(t.head)||P.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Kg(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 Eg(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new Eg(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 qg=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Gg({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=Kg(e,r);return i?(t(e.update({selection:e.selection.addRange(P.range(i.from,i.to),!1),effects:z.scrollIntoView(i.to)})),!0):!1},Jg=F.define({combine(e){return wn(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new O_(e),scrollToMatch:e=>z.scrollIntoView(e)})}}),Yg=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||Ng(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`?`
|
|
19
|
+
`: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 o_(this):new e_(this)}getCursor(e,t=0,n){let r=e.doc?e:Cn.create({doc:e});return n??=r.doc.length,this.regexp?n_(this,r,t,n):Qg(this,r,t,n)}},Xg=class{constructor(e){this.spec=e}};function Zg(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 Qg(e,t,n,r){let i;return e.wholeWord&&(i=$g(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Zg(e.test,t,i)),new Eg(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function $g(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(r_(i,n-a))!=vn.Word||t(i_(i,n-a))!=vn.Word)&&(t(i_(i,r-a))!=vn.Word||t(r_(i,r-a))!=vn.Word))}var e_=class extends Xg{constructor(e){super(e)}nextMatch(e,t,n){let r=Qg(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=Qg(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=Qg(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=Qg(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=Qg(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 t_(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function n_(e,t,n,r){let i;return e.wholeWord&&(i=a_(t.charCategorizer(t.selection.main.head))),e.test&&(i=t_(e.test,t,i)),new kg(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function r_(e,t){return e.slice(gt(e,t,!1),t)}function i_(e,t){return e.slice(t,gt(e,t))}function a_(e){return(t,n,r)=>!r[0].length||(e(r_(r.input,r.index))!=vn.Word||e(i_(r.input,r.index))!=vn.Word)&&(e(i_(r.input,r.index+r[0].length))!=vn.Word||e(r_(r.input,r.index+r[0].length))!=vn.Word)}var o_=class extends Xg{nextMatch(e,t,n){let r=n_(this.spec,e,n,e.doc.length).next();return r.done&&(r=n_(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=n_(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=n_(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=n_(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)}},s_=I.define(),c_=I.define(),l_=Vt.define({create(e){return new u_(S_(e).create(),null)},update(e,t){for(let n of t.effects)n.is(s_)?e=new u_(n.value.create(),e.panel):n.is(c_)&&(e=new u_(e.query,n.value?x_:null));return e},provide:e=>Kc.from(e,e=>e.panel)}),u_=class{constructor(e,t){this.query=e,this.panel=t}},d_=R.mark({class:`cm-searchMatch`}),f_=R.mark({class:`cm-searchMatch cm-searchMatch-selected`}),p_=qi.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(l_))}update(e){let t=e.state.field(l_);(t!=e.startState.field(l_)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return R.none;let{view:n}=this,r=new Mn;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?f_:d_)})}return r.finish()}},{decorations:e=>e.decorations});function m_(e){return t=>{let n=t.state.field(l_,!1);return n&&n.query.spec.valid?e(t,n):T_(t)}}var h_=m_((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=P.single(r.from,r.to),a=e.state.facet(Jg);return e.dispatch({selection:i,effects:[M_(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),w_(e),!0}),g_=m_((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=P.single(i.from,i.to),o=e.state.facet(Jg);return e.dispatch({selection:a,effects:[M_(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),w_(e),!0}),__=m_((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:P.create(n.map(e=>P.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),v_=({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 Eg(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(P.range(t.value.from,t.value.to))}return t(e.update({selection:P.create(a,o),userEvent:`select.search.matches`})),!0},y_=m_((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}),u.push(z.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=P.single(o.from,o.to).map(d),u.push(M_(e,o)),u.push(n.facet(Jg).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),b_=m_((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:z.announce.of(r),userEvent:`input.replace.all`}),!0});function x_(e){return e.state.facet(Jg).createPanel(e)}function S_(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(Jg);return new Yg({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 C_(e){let t=Hc(e,x_);return t&&t.dom.querySelector(`[main-field]`)}function w_(e){let t=C_(e);t&&t==e.root.activeElement&&t.select()}var T_=e=>{let t=e.state.field(l_,!1);if(t&&t.panel){let n=C_(e);if(n&&n!=e.root.activeElement){let r=S_(e.state,t.query.spec);r.valid&&e.dispatch({effects:s_.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[c_.of(!0),t?s_.of(S_(e.state,t.query.spec)):I.appendConfig.of(P_)]});return!0},E_=e=>{let t=e.state.field(l_,!1);if(!t||!t.panel)return!1;let n=Hc(e,x_);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:c_.of(!1)}),!0},D_=[{key:`Mod-f`,run:T_,scope:`editor search-panel`},{key:`F3`,run:h_,shift:g_,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:h_,shift:g_,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:E_,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:v_},{key:`Mod-Alt-g`,run:Fg},{key:`Mod-d`,run:qg,preventDefault:!0}],O_=class{constructor(e){this.view=e;let t=this.query=e.state.field(l_).query.spec;this.commit=this.commit.bind(this),this.searchField=ar(`input`,{value:t.search,placeholder:k_(e,`Find`),"aria-label":k_(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=ar(`input`,{value:t.replace,placeholder:k_(e,`Replace`),"aria-label":k_(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=ar(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=ar(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=ar(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return ar(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=ar(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>h_(e),[k_(e,`next`)]),n(`prev`,()=>g_(e),[k_(e,`previous`)]),n(`select`,()=>__(e),[k_(e,`all`)]),ar(`label`,null,[this.caseField,k_(e,`match case`)]),ar(`label`,null,[this.reField,k_(e,`regexp`)]),ar(`label`,null,[this.wordField,k_(e,`by word`)]),...e.state.readOnly?[]:[ar(`br`),this.replaceField,n(`replace`,()=>y_(e),[k_(e,`replace`)]),n(`replaceAll`,()=>b_(e),[k_(e,`replace all`)])],ar(`button`,{name:`close`,onclick:()=>E_(e),"aria-label":k_(e,`close`),type:`button`},[`×`])])}commit(){let e=new Yg({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:s_.of(e)}))}keydown(e){pc(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?g_:h_)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),y_(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(s_)&&!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(Jg).top}};function k_(e,t){return e.state.phrase(t)}var A_=30,j_=/[\s\.,:;?!]/;function M_(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-A_),o=Math.min(i,n+A_),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<A_;e++)if(!j_.test(s[e+1])&&j_.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-A_;e--)if(!j_.test(s[e-1])&&j_.test(s[e])){s=s.slice(0,e);break}}return z.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var N_=z.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`}}),P_=[l_,Wt.low(p_),N_];function F_(){return z.theme({".cm-activeLine":{backgroundColor:`var(--cm-activeLine-bg, rgba(0, 0, 0, 0.05))`}})}var I_=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},L_=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Q_).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Mn,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=uv(s);if(i)o.add(n,n,R.widget({widget:new rv(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,R.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,R_(f))}};function R_(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 I_(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new I_(r.from,n,r.diagnostic)}),r}function z_(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Q_).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(H_))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function B_(e,t){return e.field(G_,!1)?t:t.concat(I.appendConfig.of(fv))}function V_(e,t){return{effects:B_(e,[H_.of(t)])}}var H_=I.define(),U_=I.define(),W_=I.define(),G_=Vt.define({create(){return new L_(R.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=R_(n,e.selected.diagnostic,i)||R_(n,null,i)}!n.size&&i&&t.state.facet(Q_).autoPanel&&(i=null),e=new L_(n,i,r)}for(let n of t.effects)if(n.is(H_)){let r=t.state.facet(Q_).autoPanel?n.value.length?av.open:null:e.panel;e=L_.init(n.value,r,t.state)}else n.is(U_)?e=new L_(e.diagnostics,n.value?av.open:null,e.selected):n.is(W_)&&(e=new L_(e.diagnostics,e.panel,n.value));return e},provide:e=>[Kc.from(e,e=>e.panel),z.decorations.from(e,e=>e.diagnostics)]}),K_=R.mark({class:`cm-lintRange cm-lintRange-active`});function q_(e,t,n){let{diagnostics:r}=e.state.field(G_),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(Q_).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:J_(e,i)}}}:null}function J_(e,t){return ar(`ul`,{class:`cm-tooltip-lint`},t.map(t=>nv(e,t,!1)))}var Y_=e=>{let t=e.state.field(G_,!1);return!t||!t.panel?!1:(e.dispatch({effects:U_.of(!1)}),!0)},X_=qi.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(Q_);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(Q_);t.length&&Z_(t.map(e=>Promise.resolve(e(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(V_(this.view.state,t.reduce((e,t)=>e.concat(t))))},e=>{Ui(this.view.state,e)})}}update(e){let t=e.state.facet(Q_);(e.docChanged||t!=e.startState.facet(Q_)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function Z_(e,t,n){let r=[],i=-1;for(let a of e)a.then(n=>{r.push(n),clearTimeout(i),r.length==e.length?t(r):i=setTimeout(()=>t(r),200)},n)}var Q_=F.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...wn(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:$_,tooltipFilter:$_,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 $_(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function ev(e,t={}){return[Q_.of({source:e,config:t}),X_,fv]}function tv(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 nv(e,t,n){let r=n?tv(t.actions):[];return ar(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},ar(`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=R_(e.state.field(G_).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),ar(`u`,s.slice(c,c+1)),s.slice(c+1)];return ar(`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&&ar(`div`,{class:`cm-diagnosticSource`},t.source))}var rv=class extends wr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ar(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},iv=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=nv(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},av=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Y_(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=tv(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=R_(this.view.state.field(G_).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=ar(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=ar(`div`,{class:`cm-panel-lint`},this.list,ar(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Y_(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(G_).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(G_),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 iv(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 iv(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=R_(this.view.state.field(G_).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:W_.of(t)})}static open(t){return new e(t)}};function ov(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 sv(e){return ov(`<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 cv=z.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:sv(`#f11`)},".cm-lintRange-warning":{backgroundImage:sv(`orange`)},".cm-lintRange-info":{backgroundImage:sv(`#999`)},".cm-lintRange-hint":{backgroundImage:sv(`#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 lv(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function uv(e){let t=`hint`,n=1;for(let r of e){let e=lv(r.severity);e>n&&(n=e,t=r.severity)}return t}var dv=Rc(q_,{hideOn:z_}),fv=[G_,z.decorations.compute([G_],e=>{let{selected:t,panel:n}=e.field(G_);return!t||!n||t.from==t.to?R.none:R.set([K_.range(t.from,t.to)])}),dv,cv];function pv(e,t){let n=e.field(G_,!1);if(n&&n.diagnostics.size){let e=[],r=[],i=-1;for(let a=An.iter([n.diagnostics]);;a.next()){for(let n=0;n<e.length;n++)(!a.value||a.value.spec.diagnostics.indexOf(e[n])<0)&&(t(e[n],r[n],i),e.splice(n,1),r.splice(n--,1));if(!a.value)break;for(let t of a.value.spec.diagnostics)e.indexOf(t)<0&&(e.push(t),r.push(a.from));i=a.to}}}function mv(e){let t=[];return pv(e,({from:e,to:n,severity:r,message:i})=>{t.push({from:e,to:n,severity:r,message:i})}),t}var hv=({className:e,value:t=``,readOnly:n=!1,onChange:r,onMount:i,onValidate:a,extensions:o=[],options:s={}})=>{let c=(0,N.useRef)(null),l=(0,N.useRef)(null),u=(0,N.useRef)(r),d=(0,N.useRef)(a);(0,N.useEffect)(()=>{u.current=r},[r]),(0,N.useEffect)(()=>{d.current=a},[a]);let f=(0,N.useMemo)(()=>{let e=[];return e.push(Xf(),uc.of([...rh,...hp,...Sg,...Kd,...D_])),s.lineNumbers!==!1&&e.push(yl()),s.lineWrapping&&e.push(z.lineWrapping),s.highlightActiveLine!==!1&&e.push(F_()),s.foldGutter!==!1&&e.push(tf()),s.autocompletion!==!1&&e.push(xg()),e.push(bf()),e.push(Rg()),n&&(e.push(Cn.readOnly.of(!0)),e.push(z.editable.of(!1))),e.push(...o),e.push(z.updateListener.of(e=>{if(e.docChanged&&(u.current&&u.current(e.state.doc.toString()),d.current)){let t=mv(e.state);d.current(t)}})),e},[n,s.lineNumbers,s.lineWrapping,s.highlightActiveLine,s.foldGutter,s.autocompletion,o]);return(0,N.useEffect)(()=>{if(!c.current)return;let e=new z({state:Cn.create({doc:t,extensions:f}),parent:c.current});return l.current=e,i?.(e),()=>{e.destroy(),l.current=null}},[]),(0,N.useEffect)(()=>{let e=l.current;if(!e)return;let n=e.state.doc.toString();t!==n&&e.dispatch({changes:{from:0,to:n.length,insert:t||``}})},[t]),(0,N.useEffect)(()=>{let e=l.current;e&&e.dispatch({effects:I.reconfigure.of(f)})},[f]),(0,ye.jsx)(`div`,{className:me(`h-[300px] w-full`,e),children:(0,ye.jsx)(`div`,{ref:c,className:`h-full w-full`})})};function gv(e,t,n){e%=360,e<0&&(e+=360),t=Math.max(0,Math.min(100,t)),n=Math.max(0,Math.min(100,n)),t/=100,n/=100;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=n-r/2,o=0,s=0,c=0;0<=e&&e<60?(o=r,s=i,c=0):60<=e&&e<120?(o=i,s=r,c=0):120<=e&&e<180?(o=0,s=r,c=i):180<=e&&e<240?(o=0,s=i,c=r):240<=e&&e<300?(o=i,s=0,c=r):300<=e&&e<360&&(o=r,s=0,c=i);let l=e=>{let t=Math.round((e+a)*255).toString(16);return t.length===1?`0`+t:t};return`#${l(o)}${l(s)}${l(c)}`}function _v(e,t){let n=e.trim();if(!n)return t;if(n.startsWith(`#`))return n;let r=n.match(/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)%\s+(\d+(?:\.\d+)?)%$/);return r&&r[1]&&r[2]&&r[3]?gv(parseFloat(r[1]),parseFloat(r[2]),parseFloat(r[3])):t}function vv(e,t){if(typeof document>`u`)return t;try{let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return n?_v(n,t):t}catch(n){return console.error(`Error getting CSS variable ${e}:`,n),t}}function yv(){return typeof document>`u`?`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`}var bv=e=>{let t=e instanceof Error?e.message:String(e);t=t.replace(/Query failed: Error: /,``);let n=t.indexOf(`
|
|
20
|
+
`);return n>=0?t.substring(0,n):t};function xv(e,t){let n=document.createElement(`div`),r=(0,Ke.createRoot)(n);return(0,Ge.flushSync)(()=>{r.render((0,ye.jsx)(e,{...t}))}),{container:n,root:r}}function Sv(e,t){let{container:n,root:r}=xv(e,t);return{dom:n,destroy:()=>r.unmount()}}function Cv(e,t){let{container:n,root:r}=xv(e,t),i=n.innerHTML;return r.unmount(),i}function wv({message:e,code:t}){return(0,ye.jsxs)(`div`,{className:`text-foreground px-2`,children:[(0,ye.jsx)(`span`,{children:e}),t&&(0,ye.jsxs)(`span`,{className:`text-muted-foreground opacity-70`,children:[` (`,t,`)`]})]})}var Tv=class e{constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(t,n){for(let n of t)if(e.isIncremental(n)){let e=Av(n.range),t=this.offsetAt(e.start),r=this.offsetAt(e.end);this._content=this._content.substring(0,t)+n.text+this._content.substring(r,this._content.length);let i=Math.max(e.start.line,0),a=Math.max(e.end.line,0),o=this._lineOffsets,s=Ov(n.text,!1,t);if(a-i===s.length)for(let e=0,t=s.length;e<t;e++)o[e+i+1]=s[e];else s.length<1e4?o.splice(i+1,a-i,...s):this._lineOffsets=o=o.slice(0,i+1).concat(s,o.slice(a+1));let c=n.text.length-(r-t);if(c!==0)for(let e=i+1+s.length,t=o.length;e<t;e++)o[e]=o[e]+c}else if(e.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw Error(`Unknown change event received`);this._version=n}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=Ov(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,r=t.length;if(r===0)return{line:0,character:e};for(;n<r;){let i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}let i=n-1;return e=this.ensureBeforeEOL(e,t[i]),{line:i,character:e-t[i]}}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line];if(e.character<=0)return n;let r=e.line+1<t.length?t[e.line+1]:this._content.length,i=Math.min(n+e.character,r);return this.ensureBeforeEOL(i,n)}ensureBeforeEOL(e,t){for(;e>t&&kv(this._content.charCodeAt(e-1));)e--;return e}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength==`number`)}static isFull(e){let t=e;return t!=null&&typeof t.text==`string`&&t.range===void 0&&t.rangeLength===void 0}},Ev;(function(e){function t(e,t,n,r){return new Tv(e,t,n,r)}e.create=t;function n(e,t,n){if(e instanceof Tv)return e.update(t,n),e;throw Error(`TextDocument.update: document must be created by TextDocument.create`)}e.update=n;function r(e,t){let n=e.getText(),r=Dv(t.map(jv),(e,t)=>{let n=e.range.start.line-t.range.start.line;return n===0?e.range.start.character-t.range.start.character:n}),i=0,a=[];for(let t of r){let r=e.offsetAt(t.range.start);if(r<i)throw Error(`Overlapping edit`);r>i&&a.push(n.substring(i,r)),t.newText.length&&a.push(t.newText),i=e.offsetAt(t.range.end)}return a.push(n.substr(i)),a.join(``)}e.applyEdits=r})(Ev||={});function Dv(e,t){if(e.length<=1)return e;let n=e.length/2|0,r=e.slice(0,n),i=e.slice(n);Dv(r,t),Dv(i,t);let a=0,o=0,s=0;for(;a<r.length&&o<i.length;)t(r[a],i[o])<=0?e[s++]=r[a++]:e[s++]=i[o++];for(;a<r.length;)e[s++]=r[a++];for(;o<i.length;)e[s++]=i[o++];return e}function Ov(e,t,n=0){let r=t?[n]:[];for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);kv(i)&&(i===13&&t+1<e.length&&e.charCodeAt(t+1)===10&&t++,r.push(n+t+1))}return r}function kv(e){return e===13||e===10}function Av(e){let t=e.start,n=e.end;return t.line>n.line||t.line===n.line&&t.character>n.character?{start:n,end:t}:e}function jv(e){let t=Av(e.range);return t===e.range?e:{newText:e.newText,range:t}}function Mv(e,t){let n=Ev.create(`inmemory://doc.json`,`json`,1,e);return{document:n,jsonDocument:t.languageService.parseJSONDocument(n)}}async function Nv(e,t){let n=[];if(!e.trim())return n;try{let{document:r,jsonDocument:i}=Mv(e,t),a=await t.languageService.doValidation(r,i);for(let{message:e,code:t,range:i,severity:o}of a)n.push({from:r.offsetAt(i.start),to:r.offsetAt(i.end),severity:Pv(o),message:e,renderMessage:()=>{let{dom:n}=Sv(wv,{message:e,code:t});return n}})}catch(t){let r=t instanceof Error?`Validation error: ${t.message}`:`Unexpected validation error`;n.push({from:0,to:Math.min(e.length,100),severity:`error`,message:r,renderMessage:()=>{let{dom:e}=Sv(wv,{message:r});return e}})}return n}function Pv(e){switch(e){case 1:return`error`;case 2:return`warning`;case 3:return`info`;case 4:return`hint`;default:return`warning`}}function Fv(e,t=500){return ev(async t=>await Nv(t.state.doc.toString(),e),{delay:t})}var Iv;(function(e){function t(e){return typeof e==`string`}e.is=t})(Iv||={});var Lv;(function(e){function t(e){return typeof e==`string`}e.is=t})(Lv||={});var Rv;(function(e){e.MIN_VALUE=-2147483648,e.MAX_VALUE=2147483647;function t(t){return typeof t==`number`&&e.MIN_VALUE<=t&&t<=e.MAX_VALUE}e.is=t})(Rv||={});var zv;(function(e){e.MIN_VALUE=0,e.MAX_VALUE=2147483647;function t(t){return typeof t==`number`&&e.MIN_VALUE<=t&&t<=e.MAX_VALUE}e.is=t})(zv||={});var Bv;(function(e){function t(e,t){return e===Number.MAX_VALUE&&(e=zv.MAX_VALUE),t===Number.MAX_VALUE&&(t=zv.MAX_VALUE),{line:e,character:t}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&U.uinteger(t.line)&&U.uinteger(t.character)}e.is=n})(Bv||={});var Vv;(function(e){function t(e,t,n,r){if(U.uinteger(e)&&U.uinteger(t)&&U.uinteger(n)&&U.uinteger(r))return{start:Bv.create(e,t),end:Bv.create(n,r)};if(Bv.is(e)&&Bv.is(t))return{start:e,end:t};throw Error(`Range#create called with invalid arguments[${e}, ${t}, ${n}, ${r}]`)}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&Bv.is(t.start)&&Bv.is(t.end)}e.is=n})(Vv||={});var Hv;(function(e){function t(e,t){return{uri:e,range:t}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&Vv.is(t.range)&&(U.string(t.uri)||U.undefined(t.uri))}e.is=n})(Hv||={});var Uv;(function(e){function t(e,t,n,r){return{targetUri:e,targetRange:t,targetSelectionRange:n,originSelectionRange:r}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&Vv.is(t.targetRange)&&U.string(t.targetUri)&&Vv.is(t.targetSelectionRange)&&(Vv.is(t.originSelectionRange)||U.undefined(t.originSelectionRange))}e.is=n})(Uv||={});var Wv;(function(e){function t(e,t,n,r){return{red:e,green:t,blue:n,alpha:r}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&U.numberRange(t.red,0,1)&&U.numberRange(t.green,0,1)&&U.numberRange(t.blue,0,1)&&U.numberRange(t.alpha,0,1)}e.is=n})(Wv||={});var Gv;(function(e){function t(e,t){return{range:e,color:t}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&Vv.is(t.range)&&Wv.is(t.color)}e.is=n})(Gv||={});var Kv;(function(e){function t(e,t,n){return{label:e,textEdit:t,additionalTextEdits:n}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&U.string(t.label)&&(U.undefined(t.textEdit)||ty.is(t))&&(U.undefined(t.additionalTextEdits)||U.typedArray(t.additionalTextEdits,ty.is))}e.is=n})(Kv||={});var qv;(function(e){e.Comment=`comment`,e.Imports=`imports`,e.Region=`region`})(qv||={});var Jv;(function(e){function t(e,t,n,r,i,a){let o={startLine:e,endLine:t};return U.defined(n)&&(o.startCharacter=n),U.defined(r)&&(o.endCharacter=r),U.defined(i)&&(o.kind=i),U.defined(a)&&(o.collapsedText=a),o}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&U.uinteger(t.startLine)&&U.uinteger(t.startLine)&&(U.undefined(t.startCharacter)||U.uinteger(t.startCharacter))&&(U.undefined(t.endCharacter)||U.uinteger(t.endCharacter))&&(U.undefined(t.kind)||U.string(t.kind))}e.is=n})(Jv||={});var Yv;(function(e){function t(e,t){return{location:e,message:t}}e.create=t;function n(e){let t=e;return U.defined(t)&&Hv.is(t.location)&&U.string(t.message)}e.is=n})(Yv||={});var Xv;(function(e){e.Error=1,e.Warning=2,e.Information=3,e.Hint=4})(Xv||={});var Zv;(function(e){e.Unnecessary=1,e.Deprecated=2})(Zv||={});var Qv;(function(e){function t(e){let t=e;return U.objectLiteral(t)&&U.string(t.href)}e.is=t})(Qv||={});var $v;(function(e){function t(e,t,n,r,i,a){let o={range:e,message:t};return U.defined(n)&&(o.severity=n),U.defined(r)&&(o.code=r),U.defined(i)&&(o.source=i),U.defined(a)&&(o.relatedInformation=a),o}e.create=t;function n(e){let t=e;return U.defined(t)&&Vv.is(t.range)&&U.string(t.message)&&(U.number(t.severity)||U.undefined(t.severity))&&(U.integer(t.code)||U.string(t.code)||U.undefined(t.code))&&(U.undefined(t.codeDescription)||U.string(t.codeDescription?.href))&&(U.string(t.source)||U.undefined(t.source))&&(U.undefined(t.relatedInformation)||U.typedArray(t.relatedInformation,Yv.is))}e.is=n})($v||={});var ey;(function(e){function t(e,t,...n){let r={title:e,command:t};return U.defined(n)&&n.length>0&&(r.arguments=n),r}e.create=t;function n(e){let t=e;return U.defined(t)&&U.string(t.title)&&U.string(t.command)}e.is=n})(ey||={});var ty;(function(e){function t(e,t){return{range:e,newText:t}}e.replace=t;function n(e,t){return{range:{start:e,end:e},newText:t}}e.insert=n;function r(e){return{range:e,newText:``}}e.del=r;function i(e){let t=e;return U.objectLiteral(t)&&U.string(t.newText)&&Vv.is(t.range)}e.is=i})(ty||={});var ny;(function(e){function t(e,t,n){let r={label:e};return t!==void 0&&(r.needsConfirmation=t),n!==void 0&&(r.description=n),r}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&U.string(t.label)&&(U.boolean(t.needsConfirmation)||t.needsConfirmation===void 0)&&(U.string(t.description)||t.description===void 0)}e.is=n})(ny||={});var ry;(function(e){function t(e){let t=e;return U.string(t)}e.is=t})(ry||={});var iy;(function(e){function t(e,t,n){return{range:e,newText:t,annotationId:n}}e.replace=t;function n(e,t,n){return{range:{start:e,end:e},newText:t,annotationId:n}}e.insert=n;function r(e,t){return{range:e,newText:``,annotationId:t}}e.del=r;function i(e){let t=e;return ty.is(t)&&(ny.is(t.annotationId)||ry.is(t.annotationId))}e.is=i})(iy||={});var ay;(function(e){function t(e,t){return{textDocument:e,edits:t}}e.create=t;function n(e){let t=e;return U.defined(t)&&fy.is(t.textDocument)&&Array.isArray(t.edits)}e.is=n})(ay||={});var oy;(function(e){function t(e,t,n){let r={kind:`create`,uri:e};return t!==void 0&&(t.overwrite!==void 0||t.ignoreIfExists!==void 0)&&(r.options=t),n!==void 0&&(r.annotationId=n),r}e.create=t;function n(e){let t=e;return t&&t.kind===`create`&&U.string(t.uri)&&(t.options===void 0||(t.options.overwrite===void 0||U.boolean(t.options.overwrite))&&(t.options.ignoreIfExists===void 0||U.boolean(t.options.ignoreIfExists)))&&(t.annotationId===void 0||ry.is(t.annotationId))}e.is=n})(oy||={});var sy;(function(e){function t(e,t,n,r){let i={kind:`rename`,oldUri:e,newUri:t};return n!==void 0&&(n.overwrite!==void 0||n.ignoreIfExists!==void 0)&&(i.options=n),r!==void 0&&(i.annotationId=r),i}e.create=t;function n(e){let t=e;return t&&t.kind===`rename`&&U.string(t.oldUri)&&U.string(t.newUri)&&(t.options===void 0||(t.options.overwrite===void 0||U.boolean(t.options.overwrite))&&(t.options.ignoreIfExists===void 0||U.boolean(t.options.ignoreIfExists)))&&(t.annotationId===void 0||ry.is(t.annotationId))}e.is=n})(sy||={});var cy;(function(e){function t(e,t,n){let r={kind:`delete`,uri:e};return t!==void 0&&(t.recursive!==void 0||t.ignoreIfNotExists!==void 0)&&(r.options=t),n!==void 0&&(r.annotationId=n),r}e.create=t;function n(e){let t=e;return t&&t.kind===`delete`&&U.string(t.uri)&&(t.options===void 0||(t.options.recursive===void 0||U.boolean(t.options.recursive))&&(t.options.ignoreIfNotExists===void 0||U.boolean(t.options.ignoreIfNotExists)))&&(t.annotationId===void 0||ry.is(t.annotationId))}e.is=n})(cy||={});var ly;(function(e){function t(e){let t=e;return t&&(t.changes!==void 0||t.documentChanges!==void 0)&&(t.documentChanges===void 0||t.documentChanges.every(e=>U.string(e.kind)?oy.is(e)||sy.is(e)||cy.is(e):ay.is(e)))}e.is=t})(ly||={});var uy;(function(e){function t(e){return{uri:e}}e.create=t;function n(e){let t=e;return U.defined(t)&&U.string(t.uri)}e.is=n})(uy||={});var dy;(function(e){function t(e,t){return{uri:e,version:t}}e.create=t;function n(e){let t=e;return U.defined(t)&&U.string(t.uri)&&U.integer(t.version)}e.is=n})(dy||={});var fy;(function(e){function t(e,t){return{uri:e,version:t}}e.create=t;function n(e){let t=e;return U.defined(t)&&U.string(t.uri)&&(t.version===null||U.integer(t.version))}e.is=n})(fy||={});var py;(function(e){function t(e,t,n,r){return{uri:e,languageId:t,version:n,text:r}}e.create=t;function n(e){let t=e;return U.defined(t)&&U.string(t.uri)&&U.string(t.languageId)&&U.integer(t.version)&&U.string(t.text)}e.is=n})(py||={});var my;(function(e){e.PlainText=`plaintext`,e.Markdown=`markdown`;function t(t){let n=t;return n===e.PlainText||n===e.Markdown}e.is=t})(my||={});var hy;(function(e){function t(e){let t=e;return U.objectLiteral(e)&&my.is(t.kind)&&U.string(t.value)}e.is=t})(hy||={});var gy;(function(e){e.Text=1,e.Method=2,e.Function=3,e.Constructor=4,e.Field=5,e.Variable=6,e.Class=7,e.Interface=8,e.Module=9,e.Property=10,e.Unit=11,e.Value=12,e.Enum=13,e.Keyword=14,e.Snippet=15,e.Color=16,e.File=17,e.Reference=18,e.Folder=19,e.EnumMember=20,e.Constant=21,e.Struct=22,e.Event=23,e.Operator=24,e.TypeParameter=25})(gy||={});var _y;(function(e){e.PlainText=1,e.Snippet=2})(_y||={});var vy;(function(e){e.Deprecated=1})(vy||={});var yy;(function(e){function t(e,t,n){return{newText:e,insert:t,replace:n}}e.create=t;function n(e){let t=e;return t&&U.string(t.newText)&&Vv.is(t.insert)&&Vv.is(t.replace)}e.is=n})(yy||={});var by;(function(e){e.asIs=1,e.adjustIndentation=2})(by||={});var xy;(function(e){function t(e){let t=e;return t&&(U.string(t.detail)||t.detail===void 0)&&(U.string(t.description)||t.description===void 0)}e.is=t})(xy||={});var Sy;(function(e){function t(e){return{label:e}}e.create=t})(Sy||={});var Cy;(function(e){function t(e,t){return{items:e||[],isIncomplete:!!t}}e.create=t})(Cy||={});var wy;(function(e){function t(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,`\\$&`)}e.fromPlainText=t;function n(e){let t=e;return U.string(t)||U.objectLiteral(t)&&U.string(t.language)&&U.string(t.value)}e.is=n})(wy||={});var Ty;(function(e){function t(e){let t=e;return!!t&&U.objectLiteral(t)&&(hy.is(t.contents)||wy.is(t.contents)||U.typedArray(t.contents,wy.is))&&(e.range===void 0||Vv.is(e.range))}e.is=t})(Ty||={});var Ey;(function(e){function t(e,t){return t?{label:e,documentation:t}:{label:e}}e.create=t})(Ey||={});var Dy;(function(e){function t(e,t,...n){let r={label:e};return U.defined(t)&&(r.documentation=t),U.defined(n)?r.parameters=n:r.parameters=[],r}e.create=t})(Dy||={});var Oy;(function(e){e.Text=1,e.Read=2,e.Write=3})(Oy||={});var ky;(function(e){function t(e,t){let n={range:e};return U.number(t)&&(n.kind=t),n}e.create=t})(ky||={});var Ay;(function(e){e.File=1,e.Module=2,e.Namespace=3,e.Package=4,e.Class=5,e.Method=6,e.Property=7,e.Field=8,e.Constructor=9,e.Enum=10,e.Interface=11,e.Function=12,e.Variable=13,e.Constant=14,e.String=15,e.Number=16,e.Boolean=17,e.Array=18,e.Object=19,e.Key=20,e.Null=21,e.EnumMember=22,e.Struct=23,e.Event=24,e.Operator=25,e.TypeParameter=26})(Ay||={});var jy;(function(e){e.Deprecated=1})(jy||={});var My;(function(e){function t(e,t,n,r,i){let a={name:e,kind:t,location:{uri:r,range:n}};return i&&(a.containerName=i),a}e.create=t})(My||={});var Ny;(function(e){function t(e,t,n,r){return r===void 0?{name:e,kind:t,location:{uri:n}}:{name:e,kind:t,location:{uri:n,range:r}}}e.create=t})(Ny||={});var Py;(function(e){function t(e,t,n,r,i,a){let o={name:e,detail:t,kind:n,range:r,selectionRange:i};return a!==void 0&&(o.children=a),o}e.create=t;function n(e){let t=e;return t&&U.string(t.name)&&U.number(t.kind)&&Vv.is(t.range)&&Vv.is(t.selectionRange)&&(t.detail===void 0||U.string(t.detail))&&(t.deprecated===void 0||U.boolean(t.deprecated))&&(t.children===void 0||Array.isArray(t.children))&&(t.tags===void 0||Array.isArray(t.tags))}e.is=n})(Py||={});var Fy;(function(e){e.Empty=``,e.QuickFix=`quickfix`,e.Refactor=`refactor`,e.RefactorExtract=`refactor.extract`,e.RefactorInline=`refactor.inline`,e.RefactorRewrite=`refactor.rewrite`,e.Source=`source`,e.SourceOrganizeImports=`source.organizeImports`,e.SourceFixAll=`source.fixAll`})(Fy||={});var Iy;(function(e){e.Invoked=1,e.Automatic=2})(Iy||={});var Ly;(function(e){function t(e,t,n){let r={diagnostics:e};return t!=null&&(r.only=t),n!=null&&(r.triggerKind=n),r}e.create=t;function n(e){let t=e;return U.defined(t)&&U.typedArray(t.diagnostics,$v.is)&&(t.only===void 0||U.typedArray(t.only,U.string))&&(t.triggerKind===void 0||t.triggerKind===Iy.Invoked||t.triggerKind===Iy.Automatic)}e.is=n})(Ly||={});var Ry;(function(e){function t(e,t,n){let r={title:e},i=!0;return typeof t==`string`?(i=!1,r.kind=t):ey.is(t)?r.command=t:r.edit=t,i&&n!==void 0&&(r.kind=n),r}e.create=t;function n(e){let t=e;return t&&U.string(t.title)&&(t.diagnostics===void 0||U.typedArray(t.diagnostics,$v.is))&&(t.kind===void 0||U.string(t.kind))&&(t.edit!==void 0||t.command!==void 0)&&(t.command===void 0||ey.is(t.command))&&(t.isPreferred===void 0||U.boolean(t.isPreferred))&&(t.edit===void 0||ly.is(t.edit))}e.is=n})(Ry||={});var zy;(function(e){function t(e,t){let n={range:e};return U.defined(t)&&(n.data=t),n}e.create=t;function n(e){let t=e;return U.defined(t)&&Vv.is(t.range)&&(U.undefined(t.command)||ey.is(t.command))}e.is=n})(zy||={});var By;(function(e){function t(e,t){return{tabSize:e,insertSpaces:t}}e.create=t;function n(e){let t=e;return U.defined(t)&&U.uinteger(t.tabSize)&&U.boolean(t.insertSpaces)}e.is=n})(By||={});var Vy;(function(e){function t(e,t,n){return{range:e,target:t,data:n}}e.create=t;function n(e){let t=e;return U.defined(t)&&Vv.is(t.range)&&(U.undefined(t.target)||U.string(t.target))}e.is=n})(Vy||={});var Hy;(function(e){function t(e,t){return{range:e,parent:t}}e.create=t;function n(t){let n=t;return U.objectLiteral(n)&&Vv.is(n.range)&&(n.parent===void 0||e.is(n.parent))}e.is=n})(Hy||={});var Uy;(function(e){e.namespace=`namespace`,e.type=`type`,e.class=`class`,e.enum=`enum`,e.interface=`interface`,e.struct=`struct`,e.typeParameter=`typeParameter`,e.parameter=`parameter`,e.variable=`variable`,e.property=`property`,e.enumMember=`enumMember`,e.event=`event`,e.function=`function`,e.method=`method`,e.macro=`macro`,e.keyword=`keyword`,e.modifier=`modifier`,e.comment=`comment`,e.string=`string`,e.number=`number`,e.regexp=`regexp`,e.operator=`operator`,e.decorator=`decorator`})(Uy||={});var Wy;(function(e){e.declaration=`declaration`,e.definition=`definition`,e.readonly=`readonly`,e.static=`static`,e.deprecated=`deprecated`,e.abstract=`abstract`,e.async=`async`,e.modification=`modification`,e.documentation=`documentation`,e.defaultLibrary=`defaultLibrary`})(Wy||={});var Gy;(function(e){function t(e){let t=e;return U.objectLiteral(t)&&(t.resultId===void 0||typeof t.resultId==`string`)&&Array.isArray(t.data)&&(t.data.length===0||typeof t.data[0]==`number`)}e.is=t})(Gy||={});var Ky;(function(e){function t(e,t){return{range:e,text:t}}e.create=t;function n(e){let t=e;return t!=null&&Vv.is(t.range)&&U.string(t.text)}e.is=n})(Ky||={});var qy;(function(e){function t(e,t,n){return{range:e,variableName:t,caseSensitiveLookup:n}}e.create=t;function n(e){let t=e;return t!=null&&Vv.is(t.range)&&U.boolean(t.caseSensitiveLookup)&&(U.string(t.variableName)||t.variableName===void 0)}e.is=n})(qy||={});var Jy;(function(e){function t(e,t){return{range:e,expression:t}}e.create=t;function n(e){let t=e;return t!=null&&Vv.is(t.range)&&(U.string(t.expression)||t.expression===void 0)}e.is=n})(Jy||={});var Yy;(function(e){function t(e,t){return{frameId:e,stoppedLocation:t}}e.create=t;function n(e){let t=e;return U.defined(t)&&Vv.is(e.stoppedLocation)}e.is=n})(Yy||={});var Xy;(function(e){e.Type=1,e.Parameter=2;function t(e){return e===1||e===2}e.is=t})(Xy||={});var Zy;(function(e){function t(e){return{value:e}}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&(t.tooltip===void 0||U.string(t.tooltip)||hy.is(t.tooltip))&&(t.location===void 0||Hv.is(t.location))&&(t.command===void 0||ey.is(t.command))}e.is=n})(Zy||={});var Qy;(function(e){function t(e,t,n){let r={position:e,label:t};return n!==void 0&&(r.kind=n),r}e.create=t;function n(e){let t=e;return U.objectLiteral(t)&&Bv.is(t.position)&&(U.string(t.label)||U.typedArray(t.label,Zy.is))&&(t.kind===void 0||Xy.is(t.kind))&&t.textEdits===void 0||U.typedArray(t.textEdits,ty.is)&&(t.tooltip===void 0||U.string(t.tooltip)||hy.is(t.tooltip))&&(t.paddingLeft===void 0||U.boolean(t.paddingLeft))&&(t.paddingRight===void 0||U.boolean(t.paddingRight))}e.is=n})(Qy||={});var $y;(function(e){function t(e){return{kind:`snippet`,value:e}}e.createSnippet=t})($y||={});var eb;(function(e){function t(e,t,n,r){return{insertText:e,filterText:t,range:n,command:r}}e.create=t})(eb||={});var tb;(function(e){function t(e){return{items:e}}e.create=t})(tb||={});var nb;(function(e){e.Invoked=0,e.Automatic=1})(nb||={});var rb;(function(e){function t(e,t){return{range:e,text:t}}e.create=t})(rb||={});var ib;(function(e){function t(e,t){return{triggerKind:e,selectedCompletionInfo:t}}e.create=t})(ib||={});var ab;(function(e){function t(e){let t=e;return U.objectLiteral(t)&&Lv.is(t.uri)&&U.string(t.name)}e.is=t})(ab||={});var ob;(function(e){function t(e,t,n,r){return new sb(e,t,n,r)}e.create=t;function n(e){let t=e;return!!(U.defined(t)&&U.string(t.uri)&&(U.undefined(t.languageId)||U.string(t.languageId))&&U.uinteger(t.lineCount)&&U.func(t.getText)&&U.func(t.positionAt)&&U.func(t.offsetAt))}e.is=n;function r(e,t){let n=e.getText(),r=i(t,(e,t)=>{let n=e.range.start.line-t.range.start.line;return n===0?e.range.start.character-t.range.start.character:n}),a=n.length;for(let t=r.length-1;t>=0;t--){let i=r[t],o=e.offsetAt(i.range.start),s=e.offsetAt(i.range.end);if(s<=a)n=n.substring(0,o)+i.newText+n.substring(s,n.length);else throw Error(`Overlapping edit`);a=o}return n}e.applyEdits=r;function i(e,t){if(e.length<=1)return e;let n=e.length/2|0,r=e.slice(0,n),a=e.slice(n);i(r,t),i(a,t);let o=0,s=0,c=0;for(;o<r.length&&s<a.length;)t(r[o],a[s])<=0?e[c++]=r[o++]:e[c++]=a[s++];for(;o<r.length;)e[c++]=r[o++];for(;s<a.length;)e[c++]=a[s++];return e}})(ob||={});var sb=class{constructor(e,t,n,r){this._uri=e,this._languageId=t,this._version=n,this._content=r,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(e,t){this._content=e.text,this._version=t,this._lineOffsets=void 0}getLineOffsets(){if(this._lineOffsets===void 0){let e=[],t=this._content,n=!0;for(let r=0;r<t.length;r++){n&&=(e.push(r),!1);let i=t.charAt(r);n=i===`\r`||i===`
|
|
21
|
+
`,i===`\r`&&r+1<t.length&&t.charAt(r+1)===`
|
|
22
|
+
`&&r++}n&&t.length>0&&e.push(t.length),this._lineOffsets=e}return this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,r=t.length;if(r===0)return Bv.create(0,e);for(;n<r;){let i=Math.floor((n+r)/2);t[i]>e?r=i:n=i+1}let i=n-1;return Bv.create(i,e-t[i])}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line],r=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,r),n)}get lineCount(){return this.getLineOffsets().length}},U;(function(e){let t=Object.prototype.toString;function n(e){return e!==void 0}e.defined=n;function r(e){return e===void 0}e.undefined=r;function i(e){return e===!0||e===!1}e.boolean=i;function a(e){return t.call(e)===`[object String]`}e.string=a;function o(e){return t.call(e)===`[object Number]`}e.number=o;function s(e,n,r){return t.call(e)===`[object Number]`&&n<=e&&e<=r}e.numberRange=s;function c(e){return t.call(e)===`[object Number]`&&-2147483648<=e&&e<=2147483647}e.integer=c;function l(e){return t.call(e)===`[object Number]`&&0<=e&&e<=2147483647}e.uinteger=l;function u(e){return t.call(e)===`[object Function]`}e.func=u;function d(e){return typeof e==`object`&&!!e}e.objectLiteral=d;function f(e,t){return Array.isArray(e)&&e.every(t)}e.typedArray=f})(U||={});function cb(){}function lb(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function ub(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var db=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fb=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pb={};function mb(e,t){return((t||pb).jsx?fb:db).test(e)}var hb=/[ \t\n\f\r]/g;function gb(e){return typeof e==`object`?e.type===`text`?_b(e.value):!1:_b(e)}function _b(e){return e.replace(hb,``)===``}var vb=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};vb.prototype.normal={},vb.prototype.property={},vb.prototype.space=void 0;function yb(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new vb(n,r,t)}function bb(e){return e.toLowerCase()}var xb=class{constructor(e,t){this.attribute=t,this.property=e}};xb.prototype.attribute=``,xb.prototype.booleanish=!1,xb.prototype.boolean=!1,xb.prototype.commaOrSpaceSeparated=!1,xb.prototype.commaSeparated=!1,xb.prototype.defined=!1,xb.prototype.mustUseProperty=!1,xb.prototype.number=!1,xb.prototype.overloadedBoolean=!1,xb.prototype.property=``,xb.prototype.spaceSeparated=!1,xb.prototype.space=void 0;var Sb=t({boolean:()=>wb,booleanish:()=>Tb,commaOrSpaceSeparated:()=>kb,commaSeparated:()=>Ob,number:()=>W,overloadedBoolean:()=>Eb,spaceSeparated:()=>Db}),Cb=0,wb=Ab(),Tb=Ab(),Eb=Ab(),W=Ab(),Db=Ab(),Ob=Ab(),kb=Ab();function Ab(){return 2**++Cb}var jb=Object.keys(Sb),Mb=class extends xb{constructor(e,t,n,r){let i=-1;if(super(e,t),Nb(this,`space`,r),typeof n==`number`)for(;++i<jb.length;){let e=jb[i];Nb(this,jb[i],(n&Sb[e])===Sb[e])}}};Mb.prototype.defined=!0;function Nb(e,t,n){n&&(e[t]=n)}function Pb(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Mb(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[bb(r)]=r,n[bb(a.attribute)]=r}return new vb(t,n,e.space)}var Fb=Pb({properties:{ariaActiveDescendant:null,ariaAtomic:Tb,ariaAutoComplete:null,ariaBusy:Tb,ariaChecked:Tb,ariaColCount:W,ariaColIndex:W,ariaColSpan:W,ariaControls:Db,ariaCurrent:null,ariaDescribedBy:Db,ariaDetails:null,ariaDisabled:Tb,ariaDropEffect:Db,ariaErrorMessage:null,ariaExpanded:Tb,ariaFlowTo:Db,ariaGrabbed:Tb,ariaHasPopup:null,ariaHidden:Tb,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Db,ariaLevel:W,ariaLive:null,ariaModal:Tb,ariaMultiLine:Tb,ariaMultiSelectable:Tb,ariaOrientation:null,ariaOwns:Db,ariaPlaceholder:null,ariaPosInSet:W,ariaPressed:Tb,ariaReadOnly:Tb,ariaRelevant:null,ariaRequired:Tb,ariaRoleDescription:Db,ariaRowCount:W,ariaRowIndex:W,ariaRowSpan:W,ariaSelected:Tb,ariaSetSize:W,ariaSort:null,ariaValueMax:W,ariaValueMin:W,ariaValueNow:W,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Ib(e,t){return t in e?e[t]:t}function Lb(e,t){return Ib(e,t.toLowerCase())}var Rb=Pb({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Ob,acceptCharset:Db,accessKey:Db,action:null,allow:null,allowFullScreen:wb,allowPaymentRequest:wb,allowUserMedia:wb,alt:null,as:null,async:wb,autoCapitalize:null,autoComplete:Db,autoFocus:wb,autoPlay:wb,blocking:Db,capture:null,charSet:null,checked:wb,cite:null,className:Db,cols:W,colSpan:null,content:null,contentEditable:Tb,controls:wb,controlsList:Db,coords:W|Ob,crossOrigin:null,data:null,dateTime:null,decoding:null,default:wb,defer:wb,dir:null,dirName:null,disabled:wb,download:Eb,draggable:Tb,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:wb,formTarget:null,headers:Db,height:W,hidden:Eb,high:W,href:null,hrefLang:null,htmlFor:Db,httpEquiv:Db,id:null,imageSizes:null,imageSrcSet:null,inert:wb,inputMode:null,integrity:null,is:null,isMap:wb,itemId:null,itemProp:Db,itemRef:Db,itemScope:wb,itemType:Db,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:wb,low:W,manifest:null,max:null,maxLength:W,media:null,method:null,min:null,minLength:W,multiple:wb,muted:wb,name:null,nonce:null,noModule:wb,noValidate:wb,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:wb,optimum:W,pattern:null,ping:Db,placeholder:null,playsInline:wb,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:wb,referrerPolicy:null,rel:Db,required:wb,reversed:wb,rows:W,rowSpan:W,sandbox:Db,scope:null,scoped:wb,seamless:wb,selected:wb,shadowRootClonable:wb,shadowRootDelegatesFocus:wb,shadowRootMode:null,shape:null,size:W,sizes:null,slot:null,span:W,spellCheck:Tb,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W,step:null,style:null,tabIndex:W,target:null,title:null,translate:null,type:null,typeMustMatch:wb,useMap:null,value:Tb,width:W,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Db,axis:null,background:null,bgColor:null,border:W,borderColor:null,bottomMargin:W,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:wb,declare:wb,event:null,face:null,frame:null,frameBorder:null,hSpace:W,leftMargin:W,link:null,longDesc:null,lowSrc:null,marginHeight:W,marginWidth:W,noResize:wb,noHref:wb,noShade:wb,noWrap:wb,object:null,profile:null,prompt:null,rev:null,rightMargin:W,rules:null,scheme:null,scrolling:Tb,standby:null,summary:null,text:null,topMargin:W,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:wb,disableRemotePlayback:wb,prefix:null,property:null,results:W,security:null,unselectable:null},space:`html`,transform:Lb}),zb=Pb({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`,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:kb,accentHeight:W,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W,amplitude:W,arabicForm:null,ascent:W,attributeName:null,attributeType:null,azimuth:W,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W,by:null,calcMode:null,capHeight:W,className:Db,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:W,diffuseConstant:W,direction:null,display:null,dur:null,divisor:W,dominantBaseline:null,download:wb,dx:null,dy:null,edgeMode:null,editable:null,elevation:W,enableBackground:null,end:null,event:null,exponent:W,externalResourcesRequired:null,fill:null,fillOpacity:W,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:Ob,g2:Ob,glyphName:Ob,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W,horizOriginX:W,horizOriginY:W,id:null,ideographic:W,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W,k:W,k1:W,k2:W,k3:W,k4:W,kernelMatrix:kb,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:W,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:W,overlineThickness:W,paintOrder:null,panose1:null,path:null,pathLength:W,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Db,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W,pointsAtY:W,pointsAtZ:W,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:kb,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:kb,rev:kb,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:kb,requiredFeatures:kb,requiredFonts:kb,requiredFormats:kb,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:W,specularExponent:W,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W,strikethroughThickness:W,string:null,stroke:null,strokeDashArray:kb,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W,strokeOpacity:W,strokeWidth:null,style:null,surfaceScale:W,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:kb,tabIndex:W,tableValues:null,target:null,targetX:W,targetY:W,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:kb,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W,underlineThickness:W,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W,values:null,vAlphabetic:W,vMathematical:W,vectorEffect:null,vHanging:W,vIdeographic:W,version:null,vertAdvY:W,vertOriginX:W,vertOriginY:W,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Ib}),Bb=Pb({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()}}),Vb=Pb({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Lb}),Hb=Pb({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Ub={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`},Wb=/[A-Z]/g,Gb=/-[a-z]/g,Kb=/^data[-\w.:]+$/i;function qb(e,t){let n=bb(t),r=t,i=xb;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Kb.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Gb,Yb);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Gb.test(e)){let n=e.replace(Wb,Jb);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Mb}return new i(r,t)}function Jb(e){return`-`+e.toLowerCase()}function Yb(e){return e.charAt(1).toUpperCase()}var Xb=yb([Fb,Rb,Bb,Vb,Hb],`html`),Zb=yb([Fb,zb,Bb,Vb,Hb],`svg`);function Qb(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function $b(e){return e.join(` `).trim()}var ex=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,u=`
|
|
23
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function ee(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),ee()}function _(e){return e?e.replace(l,p):p}t.exports=g})),tx=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(ex());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),nx=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))}})),rx=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(tx()),r=nx();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),ix=ox(`end`),ax=ox(`start`);function ox(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 sx(e){let t=ax(e),n=ix(e);if(t&&n)return{start:t,end:n}}function cx(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?ux(e.position):`start`in e||`end`in e?ux(e):`line`in e||`column`in e?lx(e):``}function lx(e){return dx(e&&e.line)+`:`+dx(e&&e.column)}function ux(e){return lx(e&&e.start)+`-`+lx(e&&e.end)}function dx(e){return e&&typeof e==`number`?e:1}var fx=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=cx(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}};fx.prototype.file=``,fx.prototype.name=``,fx.prototype.reason=``,fx.prototype.message=``,fx.prototype.stack=``,fx.prototype.column=void 0,fx.prototype.line=void 0,fx.prototype.ancestors=void 0,fx.prototype.cause=void 0,fx.prototype.fatal=void 0,fx.prototype.place=void 0,fx.prototype.ruleId=void 0,fx.prototype.source=void 0;var px=e(rx(),1),mx={}.hasOwnProperty,hx=new Map,gx=/[A-Z]/g,_x=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),vx=new Set([`td`,`th`]),yx=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function bx(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=jx(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=Ax(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`?Zb:Xb,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=xx(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function xx(e,t,n){if(t.type===`element`)return Sx(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Cx(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Tx(e,t,n);if(t.type===`mdxjsEsm`)return wx(e,t);if(t.type===`root`)return Ex(e,t,n);if(t.type===`text`)return Dx(e,t)}function Sx(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Zb,e.schema=i),e.ancestors.push(t);let a=Lx(e,t.tagName,!1),o=Mx(e,t),s=Px(e,t);return _x.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!gb(e):!0})),Ox(e,o,a,t),kx(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Cx(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)}Rx(e,t.position)}function wx(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Rx(e,t.position)}function Tx(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Zb,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Lx(e,t.name,!0),o=Nx(e,t),s=Px(e,t);return Ox(e,o,a,t),kx(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ex(e,t,n){let r={};return kx(r,Px(e,t)),e.create(t,e.Fragment,r,n)}function Dx(e,t){return t.value}function Ox(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function kx(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Ax(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 jx(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=ax(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 Mx(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&mx.call(t.properties,i)){let a=Fx(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&vx.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 Nx(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 Rx(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 Rx(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Px(e,t){let n=[],r=-1,i=e.passKeys?new Map:hx;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=xx(e,a,o);s!==void 0&&n.push(s)}return n}function Fx(e,t,n){let r=qb(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ub(n):$b(n)),r.property===`style`){let t=typeof n==`object`?n:Ix(e,String(n));return e.stylePropertyNameCase===`css`&&(t=zx(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Ub[r.property]||r.property:r.attribute,n]}}function Ix(e,t){try{return(0,px.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new fx("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=yx+`#cannot-parse-style-attribute`,r}}function Lx(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=mb(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=mb(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return mx.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Rx(e)}function Rx(e,t){let n=new fx("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=yx+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function zx(e){let t={},n;for(n in e)mx.call(e,n)&&(t[Bx(n)]=e[n]);return t}function Bx(e){let t=e.replace(gx,Vx);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Vx(e){return`-`+e.toLowerCase()}var Hx={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`]},Ux={};function Wx(e,t){let n=t||Ux;return Gx(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function Gx(e,t,n){if(qx(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 Kx(e.children,t,n)}return Array.isArray(e)?Kx(e,t,n):``}function Kx(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Gx(e[i],t,n);return r.join(``)}function qx(e){return!!(e&&typeof e==`object`)}var Jx=document.createElement(`i`);function Yx(e){let t=`&`+e+`;`;Jx.innerHTML=t;let n=Jx.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function Xx(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 Zx(e,t){return e.length>0?(Xx(e,e.length,0,t),e):t}var Qx={}.hasOwnProperty;function $x(e){let t={},n=-1;for(;++n<e.length;)eS(t,e[n]);return t}function eS(e,t){let n;for(n in t){let r=(Qx.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Qx.call(r,a)||(r[a]=[]);let e=i[a];tS(r[a],Array.isArray(e)?e:e?[e]:[])}}}function tS(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Xx(e,0,0,r)}function nS(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 rS(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var iS=hS(/[A-Za-z]/),aS=hS(/[\dA-Za-z]/),oS=hS(/[#-'*+\--9=?A-Z^-~]/);function sS(e){return e!==null&&(e<32||e===127)}var cS=hS(/\d/),lS=hS(/[\dA-Fa-f]/),uS=hS(/[!-/:-@[-`{-~]/);function G(e){return e!==null&&e<-2}function dS(e){return e!==null&&(e<0||e===32)}function fS(e){return e===-2||e===-1||e===32}var pS=hS(/\p{P}|\p{S}/u),mS=hS(/\s/);function hS(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function gS(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&aS(e.charCodeAt(n+1))&&aS(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 _S(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return fS(r)?(e.enter(n),s(r)):t(r)}function s(r){return fS(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var vS={tokenize:yS};function yS(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),_S(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);return}return G(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var bS={tokenize:SS},xS={tokenize:CS};function SS(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++;return Xx(t.events,a+1,0,t.events.slice(n)),t.events.length=s,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(xS,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(xS,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);return}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);return}return G(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++;Xx(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}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 CS(e,t,n){return _S(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function wS(e){if(e===null||dS(e)||mS(e))return 1;if(pS(e))return 2}function TS(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 ES={name:`attention`,resolveAll:DS,tokenize:OS};function DS(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};kS(d,-c),kS(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Zx(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Zx(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Zx(l,TS(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Zx(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Zx(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Xx(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function OS(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=wS(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=wS(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function kS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var AS={name:`autolink`,tokenize:jS};function jS(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 iS(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||aS(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||aS(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||sS(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):oS(t)?(e.consume(t),l):n(t)}function u(e){return aS(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||aS(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var MS={partial:!0,tokenize:NS};function NS(e,t,n){return r;function r(t){return fS(t)?_S(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||G(e)?t(e):n(e)}}var PS={continuation:{tokenize:IS},exit:LS,name:`blockQuote`,tokenize:FS};function FS(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 fS(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function IS(e,t,n){let r=this;return i;function i(t){return fS(t)?_S(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(PS,t,n)(r)}}function LS(e){e.exit(`blockQuote`)}var RS={name:`characterEscape`,tokenize:zS};function zS(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 uS(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var BS={name:`characterReference`,tokenize:VS};function VS(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=aS,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=lS,u):(e.enter(`characterReferenceValue`),a=7,o=cS,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===aS&&!Yx(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 HS={partial:!0,tokenize:GS},US={concrete:!0,name:`codeFenced`,tokenize:WS};function WS(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`),fS(t)?_S(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||G(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(HS,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||G(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):fS(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),_S(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||G(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||G(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&&fS(t)?_S(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||G(t)?e.check(HS,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||G(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`),fS(t)?_S(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`),fS(t)?_S(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||G(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function GS(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 KS={name:`codeIndented`,tokenize:JS},qS={partial:!0,tokenize:YS};function JS(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),_S(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):G(t)?e.attempt(qS,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||G(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function YS(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):G(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):_S(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):G(e)?i(e):n(e)}}var XS={name:`codeText`,previous:QS,resolve:ZS,tokenize:$S};function ZS(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 QS(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function $S(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)):G(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||G(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 eC=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&&tC(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),tC(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),tC(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);tC(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);tC(this.left,t.reverse())}}};function tC(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 nC(e){let t={},n=-1,r,i,a,o,s,c,l,u=new eC(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,rC(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 Xx(e,0,1/0,u.slice(0)),!l}function rC(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 iC={resolve:oC,tokenize:sC},aC={partial:!0,tokenize:cC};function oC(e){return nC(e),e}function sC(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):G(t)?e.check(aC,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 cC(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_S(e,a,`linePrefix`)}function a(i){if(i===null||G(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 lC(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||sS(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||G(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||dS(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||sS(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 uC(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):G(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||G(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!fS(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function dC(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):G(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_S(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||G(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 fC(e,t){let n;return r;function r(i){return G(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):fS(i)?_S(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var pC={name:`definition`,tokenize:hC},mC={partial:!0,tokenize:gC};function hC(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return uC.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=rS(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 dS(t)?fC(e,l)(t):l(t)}function l(t){return lC(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(mC,d,d)(t)}function d(t){return fS(t)?_S(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||G(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function gC(e,t,n){return r;function r(t){return dS(t)?fC(e,i)(t):n(t)}function i(t){return dC(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return fS(t)?_S(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||G(e)?t(e):n(e)}}var _C={name:`hardBreakEscape`,tokenize:vC};function vC(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return G(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var yC={name:`headingAtx`,resolve:bC,tokenize:xC};function bC(e,t){let n=e.length-2,r=3,i,a;return 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&&(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`},Xx(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function xC(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||dS(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||G(n)?(e.exit(`atxHeading`),t(n)):fS(n)?_S(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||dS(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var SC=`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(`.`),CC=[`pre`,`script`,`style`,`textarea`],wC={concrete:!0,name:`htmlFlow`,resolveTo:DC,tokenize:OC},TC={partial:!0,tokenize:AC},EC={partial:!0,tokenize:kC};function DC(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 OC(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:j):iS(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):iS(a)?(e.consume(a),i=4,r.interrupt?t:j):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:j):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:D:m):n(i)}function h(t){return iS(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||dS(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&CC.includes(l)?(i=1,r.interrupt?t(s):D(s)):SC.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):D(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||aS(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:D):n(i)}function v(t){return fS(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||iS(t)?(e.consume(t),b):fS(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||aS(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):fS(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):fS(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||G(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||dS(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||fS(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),ee):n(t)}function ee(t){return t===null||G(t)?D(t):fS(t)?(e.consume(t),ee):n(t)}function D(t){return t===45&&i===2?(e.consume(t),ne):t===60&&i===1?(e.consume(t),re):t===62&&i===4?(e.consume(t),ae):t===63&&i===3?(e.consume(t),j):t===93&&i===5?(e.consume(t),A):G(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(TC,oe,O)(t)):t===null||G(t)?(e.exit(`htmlFlowData`),O(t)):(e.consume(t),D)}function O(t){return e.check(EC,te,oe)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),k}function k(t){return t===null||G(t)?O(t):(e.enter(`htmlFlowData`),D(t))}function ne(t){return t===45?(e.consume(t),j):D(t)}function re(t){return t===47?(e.consume(t),o=``,ie):D(t)}function ie(t){if(t===62){let n=o.toLowerCase();return CC.includes(n)?(e.consume(t),ae):D(t)}return iS(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ie):D(t)}function A(t){return t===93?(e.consume(t),j):D(t)}function j(t){return t===62?(e.consume(t),ae):t===45&&i===2?(e.consume(t),j):D(t)}function ae(t){return t===null||G(t)?(e.exit(`htmlFlowData`),oe(t)):(e.consume(t),ae)}function oe(n){return e.exit(`htmlFlow`),t(n)}}function kC(e,t,n){let r=this;return i;function i(t){return G(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function AC(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(MS,t,n)}}var jC={name:`htmlText`,tokenize:MC};function MC(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):iS(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):iS(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):G(t)?(o=d,re(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ne(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):G(t)?(o=h,re(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ne(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ne(t):G(t)?(o=v,re(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):G(t)?(o=y,re(t)):(e.consume(t),y)}function b(e){return e===62?ne(e):y(e)}function x(t){return iS(t)?(e.consume(t),S):n(t)}function S(t){return t===45||aS(t)?(e.consume(t),S):C(t)}function C(t){return G(t)?(o=C,re(t)):fS(t)?(e.consume(t),C):ne(t)}function w(t){return t===45||aS(t)?(e.consume(t),w):t===47||t===62||dS(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ne):t===58||t===95||iS(t)?(e.consume(t),E):G(t)?(o=T,re(t)):fS(t)?(e.consume(t),T):ne(t)}function E(t){return t===45||t===46||t===58||t===95||aS(t)?(e.consume(t),E):ee(t)}function ee(t){return t===61?(e.consume(t),D):G(t)?(o=ee,re(t)):fS(t)?(e.consume(t),ee):T(t)}function D(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,O):G(t)?(o=D,re(t)):fS(t)?(e.consume(t),D):(e.consume(t),te)}function O(t){return t===i?(e.consume(t),i=void 0,k):t===null?n(t):G(t)?(o=O,re(t)):(e.consume(t),O)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||dS(t)?T(t):(e.consume(t),te)}function k(e){return e===47||e===62||dS(e)?T(e):n(e)}function ne(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function re(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ie}function ie(t){return fS(t)?_S(e,A,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):A(t)}function A(t){return e.enter(`htmlTextData`),o(t)}}var NC={name:`labelEnd`,resolveAll:LC,resolveTo:RC,tokenize:zC},PC={tokenize:BC},FC={tokenize:VC},IC={tokenize:HC};function LC(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&&Xx(e,0,e.length,n),e}function RC(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Zx(s,e.slice(a+1,a+r+3)),s=Zx(s,[[`enter`,u,t]]),s=Zx(s,TS(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Zx(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Zx(s,e.slice(o+1)),s=Zx(s,[[`exit`,c,t]]),Xx(e,a,e.length,s),e}function zC(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(rS(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(PC,u,o?u:d)(t):t===91?e.attempt(FC,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(IC,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function BC(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 dS(t)?fC(e,a)(t):a(t)}function a(t){return t===41?u(t):lC(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return dS(t)?fC(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?dC(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return dS(t)?fC(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 VC(e,t,n){let r=this;return i;function i(t){return uC.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(rS(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function HC(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 UC={name:`labelStartImage`,resolveAll:NC.resolveAll,tokenize:WC};function WC(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var GC={name:`labelStartLink`,resolveAll:NC.resolveAll,tokenize:KC};function KC(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var qC={name:`lineEnding`,tokenize:JC};function JC(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),_S(e,t,`linePrefix`)}}var YC={name:`thematicBreak`,tokenize:XC};function XC(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||G(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),fS(t)?_S(e,s,`whitespace`)(t):s(t))}}var ZC={continuation:{tokenize:tw},exit:rw,name:`list`,tokenize:ew},QC={partial:!0,tokenize:iw},$C={partial:!0,tokenize:nw};function ew(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:cS(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(YC,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 cS(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(MS,r.interrupt?n:u,e.attempt(QC,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return fS(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 tw(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(MS,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,_S(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!fS(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($C,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,_S(e,e.attempt(ZC,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function nw(e,t,n){let r=this;return _S(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 rw(e){e.exit(this.containerState.type)}function iw(e,t,n){let r=this;return _S(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!fS(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var aw={name:`setextUnderline`,resolveTo:ow,tokenize:sw};function ow(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function sw(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`),fS(t)?_S(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||G(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var cw={tokenize:lw};function lw(e){let t=this,n=e.attempt(MS,r,e.attempt(this.parser.constructs.flowInitial,i,_S(e,e.attempt(this.parser.constructs.flow,i,e.attempt(iC,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var uw={resolveAll:mw()},dw=pw(`string`),fw=pw(`text`);function pw(e){return{resolveAll:mw(e===`text`?hw: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);return}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 mw(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 hw(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var gw=t({attentionMarkers:()=>ww,contentInitial:()=>vw,disable:()=>Tw,document:()=>_w,flow:()=>bw,flowInitial:()=>yw,insideSpan:()=>Cw,string:()=>xw,text:()=>Sw}),_w={42:ZC,43:ZC,45:ZC,48:ZC,49:ZC,50:ZC,51:ZC,52:ZC,53:ZC,54:ZC,55:ZC,56:ZC,57:ZC,62:PS},vw={91:pC},yw={[-2]:KS,[-1]:KS,32:KS},bw={35:yC,42:YC,45:[aw,YC],60:wC,61:aw,95:YC,96:US,126:US},xw={38:BS,92:RS},Sw={[-5]:qC,[-4]:qC,[-3]:qC,33:UC,38:BS,42:ES,60:[AS,jC],91:GC,92:[_C,RS],93:NC,95:ES,96:XS},Cw={null:[ES,uw]},ww={null:[42,95]},Tw={null:[]};function Ew(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=Zx(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=TS(a,l.events,l),l.events):[]}function f(e,t){return Ow(p(e),t)}function p(e){return Dw(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(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){G(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&&Xx(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 Dw(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 Ow(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=`
|
|
24
|
+
`;break;case-3:o=`\r
|
|
25
|
+
`;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 kw(e){let t={constructs:$x([gw,...(e||{}).extensions||[]]),content:n(vS),defined:[],document:n(bS),flow:n(cw),lazy:{},string:n(dw),text:n(fw)};return t;function n(e){return n;function n(n){return Ew(t,e,n)}}}function Aw(e){for(;!nC(e););return e}var jw=/[\0\t\n\r]/g;function Mw(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(jw.lastIndex=u,c=jw.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Nw=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Pw(e){return e.replace(Nw,Fw)}function Fw(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return nS(n.slice(t?2:1),t?16:10)}return Yx(n)||e}var Iw={}.hasOwnProperty;function Lw(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Rw(n)(Aw(kw(n).document().write(Mw()(e,t,!0))))}function Rw(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ve),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(me,o),codeText:a(he,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(_e),hardBreakEscape:a(N),hardBreakTrailing:a(N),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(xe),listItem:a(Ce),listItemValue:f,listOrdered:a(Se,d),listUnordered:a(Se),paragraph:a(we),reference:se,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:M,characterReferenceMarkerNumeric:M,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(k),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(O),htmlFlowData:E,htmlText:c(te),htmlTextData:E,image:c(re),label:A,labelText:ie,lineEnding:ee,link:c(ne),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ce,resourceDestinationString:j,resourceTitleString:ae,resource:oe,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};Bw(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Iw.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||Hw).call(a,void 0,e[0])}for(r.position={start:zw(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:zw(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;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 i=r;for(s=void 0;i--;){let t=e[i];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=i}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),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(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:zw(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Hw).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+cx({start:e.start,end:e.end})+`): it’s not open`);n.position.end=zw(e.end)}function u(){return Wx(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(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 p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){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 _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rS(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ee(),n.position={start:zw(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=zw(e.end)}function ee(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=zw(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function D(){this.data.atHardBreak=!0}function O(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ne(){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 re(){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 ie(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Pw(t),n.identifier=rS(t).toLowerCase()}function A(){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 j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ae(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function oe(){this.data.inReference=void 0}function se(){this.data.referenceType=`collapsed`}function ce(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rS(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function M(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=nS(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=Yx(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=zw(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function me(){return{type:`code`,lang:null,meta:null,value:``}}function he(){return{type:`inlineCode`,value:``}}function ge(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function _e(){return{type:`emphasis`,children:[]}}function ve(){return{type:`heading`,depth:0,children:[]}}function N(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function xe(){return{type:`link`,title:null,url:``,children:[]}}function Se(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ce(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function we(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function zw(e){return{line:e.line,column:e.column,offset:e.offset}}function Bw(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Bw(e,r):Vw(e,r)}}function Vw(e,t){let n;for(n in t)if(Iw.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`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function Hw(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+cx({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cx({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+cx({start:t.start,end:t.end})+`) is still open`)}function Uw(e){let t=this;t.parser=n;function n(n){return Lw(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Ww(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 Gw(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
26
|
+
`}]}function Kw(e,t){let n=t.value?t.value+`
|
|
27
|
+
`:``,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 qw(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Jw(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Yw(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=gS(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 Xw(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 Zw(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Qw(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 $w(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Qw(e,t);let i={src:gS(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 eT(e,t){let n={src:gS(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 tT(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 nT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Qw(e,t);let i={href:gS(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 rT(e,t){let n={href:gS(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 iT(e,t,n){let r=e.all(t),i=n?aT(n):oT(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:`
|
|
28
|
+
`}),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:`
|
|
29
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function aT(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=oT(n[r])}return t}function oT(e){return e.spread??e.children.length>1}function sT(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 cT(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lT(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function uT(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dT(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=ax(t.children[1]),o=ix(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 fT(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 pT(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var mT=9,hT=32;function gT(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(_T(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(_T(t.slice(i),i>0,!1)),a.join(``)}function _T(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===mT||t===hT;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===mT||t===hT;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function vT(e,t){let n={type:`text`,value:gT(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function yT(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var bT={blockquote:Ww,break:Gw,code:Kw,delete:qw,emphasis:Jw,footnoteReference:Yw,heading:Xw,html:Zw,imageReference:$w,image:eT,inlineCode:tT,linkReference:nT,link:rT,listItem:iT,list:sT,paragraph:cT,root:lT,strong:uT,table:dT,tableCell:pT,tableRow:fT,text:vT,thematicBreak:yT,toml:xT,yaml:xT,definition:xT,footnoteDefinition:xT};function xT(){}var ST=typeof self==`object`?self:globalThis,CT=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new ST[e](t)},wT=(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)e[r(t)]=r(n);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(CT(e,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)}}return n(CT(a,o),i)};return r},TT=e=>wT(new Map,e)(0),ET=``,{toString:DT}={},{keys:OT}=Object,kT=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=DT.call(e).slice(8,-1);switch(n){case`Array`:return[1,ET];case`Object`:return[2,ET];case`Date`:return[3,ET];case`RegExp`:return[4,ET];case`Map`:return[5,ET];case`Set`:return[6,ET];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},AT=([e,t])=>e===0&&(t===`function`||t===`symbol`),jT=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=kT(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of OT(r))(e||!AT(kT(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(AT(kT(n))||AT(kT(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!AT(kT(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},MT=(e,{json:t,lossy:n}={})=>{let r=[];return jT(!(t||n),!!t,new Map,r)(e),r},NT=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?TT(MT(e,t)):structuredClone(e):(e,t)=>TT(MT(e,t));function PT(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 FT(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function IT(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||PT,r=e.options.footnoteBackLabel||FT,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=gS(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:{...NT(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
30
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
31
|
+
`}]}}var LT=(function(e){if(e==null)return HT;if(typeof e==`function`)return VT(e);if(typeof e==`object`)return Array.isArray(e)?RT(e):zT(e);if(typeof e==`string`)return BT(e);throw Error(`Expected function, string, or object as test`)});function RT(e){let t=[],n=-1;for(;++n<e.length;)t[n]=LT(e[n]);return VT(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function zT(e){let t=e;return VT(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function BT(e){return VT(t);function t(t){return t&&t.type===e}}function VT(e){return t;function t(t,n,r){return!!(UT(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function HT(){return!0}function UT(e){return typeof e==`object`&&!!e&&`type`in e}function WT(e){return e}var GT=[];function KT(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=LT(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 (`+WT(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=GT,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=qT(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 qT(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?GT:[e]}function JT(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),KT(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 YT={}.hasOwnProperty,XT={};function ZT(e,t){let n=t||XT,r=new Map,i=new Map,a={all:s,applyData:$T,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...bT,...n.handlers},one:o,options:n,patch:QT,wrap:tE};return JT(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(YT.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=NT(n);return r.children=a.all(e),r}return NT(e)}return(a.options.unknownHandler||eE)(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=nE(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=nE(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function QT(e,t){e.position&&(t.position=sx(e))}function $T(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,NT(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function eE(e,t){let n=t.data||{},r=`value`in t&&!(YT.call(n,`hProperties`)||YT.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 tE(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
32
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
33
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
34
|
+
`}),n}function nE(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function rE(e,t){let n=ZT(e,t),r=n.one(e,void 0),i=IT(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
35
|
+
`},i)),a}function iE(e,t){return e&&`run`in e?async function(n,r){let i=rE(n,{file:r,...t});await e.run(i,r)}:function(n,r){return rE(n,{file:r,...e||t})}}function aE(e){if(e)throw e}var oE=e(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}}))(),1);function sE(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 cE(){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);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?lE(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 lE(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 uE={basename:dE,dirname:fE,extname:pE,join:mE,sep:`/`};function dE(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);_E(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 fE(e){if(_E(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 pE(e){_E(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}continue}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 mE(...e){let t=-1,n;for(;++t<e.length;)_E(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:hE(n)}function hE(e){_E(e);let t=e.codePointAt(0)===47,n=gE(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function gE(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 _E(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var vE={cwd:yE};function yE(){return`/`}function bE(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function xE(e){if(typeof e==`string`)e=new URL(e);else if(!bE(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 SE(e)}function SE(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 CE=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],wE=class{constructor(e){let t;t=e?bE(e)?{path:e}:typeof e==`string`||OE(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:vE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<CE.length;){let e=CE[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)CE.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?uE.basename(this.path):void 0}set basename(e){EE(e,`basename`),TE(e,`basename`),this.path=uE.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?uE.dirname(this.path):void 0}set dirname(e){DE(this.basename,`dirname`),this.path=uE.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?uE.extname(this.path):void 0}set extname(e){if(TE(e,`extname`),DE(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=uE.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){bE(e)&&(e=xE(e)),EE(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?uE.basename(this.path,this.extname):void 0}set stem(e){EE(e,`stem`),TE(e,`stem`),this.path=uE.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 fx(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 TE(e,t){if(e&&e.includes(uE.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+uE.sep+"`")}function EE(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function DE(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function OE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var kE=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),AE={}.hasOwnProperty,jE=new class e extends kE{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=cE()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,oE.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(PE(`data`,this.frozen),this.namespace[e]=t,this):AE.call(this.namespace,e)&&this.namespace[e]||void 0:e?(PE(`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=LE(e),n=this.parser||this.Parser;return ME(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),ME(`process`,this.parser||this.Parser),NE(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=LE(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);zE(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(),ME(`processSync`,this.parser||this.Parser),NE(`processSync`,this.compiler||this.Compiler),this.process(e,r),IE(`processSync`,`process`,t),n;function r(e,r){t=!0,aE(e),n=r}}run(e,t,n){FE(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=LE(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),IE(`runSync`,`run`,n),r;function i(e,t){aE(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=LE(t),r=this.compiler||this.Compiler;return NE(`stringify`,r),FE(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(PE(`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,oE.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];sE(o)&&sE(r)&&(r=(0,oE.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function ME(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function NE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function PE(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 FE(e){if(!sE(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function IE(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function LE(e){return RE(e)?e:new wE(e)}function RE(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function zE(e){return typeof e==`string`||BE(e)}function BE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var VE=[],HE={allowDangerousHtml:!0},UE=/^(https?|ircs?|mailto|xmpp)$/i,WE=[{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 GE(e){let t=KE(e),n=qE(e);return JE(t.runSync(t.parse(n),n),e)}function KE(e){let t=e.rehypePlugins||VE,n=e.remarkPlugins||VE,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...HE}:HE;return jE().use(Uw).use(n).use(iE,r).use(t)}function qE(e){let t=e.children||``,n=new wE;return typeof t==`string`?n.value=t:``+t,n}function JE(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||YE;for(let e of WE)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return JT(e,l),bx(e,{Fragment:ye.Fragment,components:i,ignoreInvalidStyle:!0,jsx:ye.jsx,jsxs:ye.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 Hx)if(Object.hasOwn(Hx,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Hx[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 YE(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||UE.test(e.slice(0,t))?e:``}function XE(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 ZE(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function QE(e,t,n){let r=LT((n||{}).ignore||[]),i=$E(t),a=-1;for(;++a<i.length;)KT(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 $E(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([eD(e[0]),tD(e[1])])}return t}function eD(e){return typeof e==`string`?new RegExp(ZE(e),`g`):e}function tD(e){return typeof e==`function`?e:function(){return e}}var nD=`phrasing`,rD=[`autolink`,`link`,`image`,`label`];function iD(){return{transforms:[fD],enter:{literalAutolink:oD,literalAutolinkEmail:sD,literalAutolinkHttp:sD,literalAutolinkWww:sD},exit:{literalAutolink:dD,literalAutolinkEmail:uD,literalAutolinkHttp:cD,literalAutolinkWww:lD}}}function aD(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:nD,notInConstruct:rD},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:nD,notInConstruct:rD},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:nD,notInConstruct:rD}]}}function oD(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function sD(e){this.config.enter.autolinkProtocol.call(this,e)}function cD(e){this.config.exit.autolinkProtocol.call(this,e)}function lD(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 uD(e){this.config.exit.autolinkEmail.call(this,e)}function dD(e){this.exit(e)}function fD(e){QE(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,pD],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,mD]],{ignore:[`link`,`linkReference`]})}function pD(e,t,n,r,i){let a=``;if(!_D(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!hD(n)))return!1;let o=gD(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 mD(e,t,n,r){return!_D(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function hD(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 gD(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=XE(e,`(`),a=XE(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 _D(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||mS(n)||pS(n))&&(!t||n!==47)}DD.peek=ED;function vD(){this.buffer()}function yD(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function bD(){this.buffer()}function xD(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function SD(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=rS(this.sliceSerialize(e)).toLowerCase(),n.label=t}function CD(e){this.exit(e)}function wD(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=rS(this.sliceSerialize(e)).toLowerCase(),n.label=t}function TD(e){this.exit(e)}function ED(){return`[`}function DD(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 OD(){return{enter:{gfmFootnoteCallString:vD,gfmFootnoteCall:yD,gfmFootnoteDefinitionLabelString:bD,gfmFootnoteDefinition:xD},exit:{gfmFootnoteCallString:SD,gfmFootnoteCall:CD,gfmFootnoteDefinitionLabelString:wD,gfmFootnoteDefinition:TD}}}function kD(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:DD},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?`
|
|
36
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?jD:AD))),s(),o}}function AD(e,t,n){return t===0?e:jD(e,t,n)}function jD(e,t,n){return(n?``:` `)+e}var MD=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];LD.peek=RD;function ND(){return{canContainEols:[`delete`],enter:{strikethrough:FD},exit:{strikethrough:ID}}}function PD(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:MD}],handlers:{delete:LD}}}function FD(e){this.enter({type:`delete`,children:[]},e)}function ID(e){this.exit(e)}function LD(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function RD(){return`~`}function zD(e){return e.length}function BD(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||zD,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=VD(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]=HD(r[d]);else{let e=HD(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(`
|
|
37
|
+
`)}function VD(e){return e==null?``:String(e)}function HD(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}function UD(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()),WD);return i(),o}function WD(e,t,n){return`>`+(n?``:` `)+e}function GD(e,t){return KD(e,t.inConstruct,!0)&&!KD(e,t.notInConstruct,!1)}function KD(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 qD(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
38
|
+
`&&GD(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
39
|
+
`}function JD(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 YD(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function XD(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ZD(e,t,n,r){let i=XD(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(YD(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,QD);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(JD(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
40
|
+
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
41
|
+
`),a&&(u+=s.move(a+`
|
|
42
|
+
`)),u+=s.move(c),l(),u}function QD(e,t,n){return(n?``:` `)+e}function $D(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function eO(e,t,n,r){let i=$D(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?` `:`
|
|
43
|
+
`,...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 tO(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function nO(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function rO(e,t,n){let r=wS(e),i=wS(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}iO.peek=aO;function iO(e,t,n,r){let i=tO(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=rO(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=nO(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=rO(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+nO(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function aO(e,t,n){return n.options.emphasis||`*`}function oO(e,t){let n=!1;return JT(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)&&Wx(e)&&(t.options.setext||n))}function sO(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(oO(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
44
|
+
`,after:`
|
|
45
|
+
`});return r(),t(),o+`
|
|
46
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
47
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
48
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=nO(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}cO.peek=lO;function cO(e){return e.value||``}function lO(){return`<`}uO.peek=dO;function uO(e,t,n,r){let i=$D(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 dO(){return`!`}fO.peek=pO;function fO(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=[],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 pO(){return`!`}mO.peek=hO;function mO(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)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 hO(){return"`"}function gO(e,t){let n=Wx(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))}_O.peek=vO;function _O(e,t,n,r){let i=$D(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(gO(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let 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 vO(e,t,n){return gO(e,n)?`<`:`[`}yO.peek=bO;function yO(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=[],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 bO(){return`[`}function xO(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 SO(e){let t=xO(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 CO(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function wO(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 TO(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?CO(n):xO(n),s=e.ordered?o===`.`?`)`:`.`:SO(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),wO(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 EO(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 DO(e,t,n,r){let i=EO(n),a=n.bulletCurrent||xO(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 OO(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var kO=LT([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function AO(e,t,n,r){return(e.children.some(function(e){return kO(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function jO(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}MO.peek=NO;function MO(e,t,n,r){let i=jO(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=rO(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=nO(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=rO(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+nO(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function NO(e,t,n){return n.options.strong||`*`}function PO(e,t,n,r){return n.safe(e.value,r)}function FO(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 IO(e,t,n){let r=(wO(n)+(n.options.ruleSpaces?` `:``)).repeat(FO(n));return n.options.ruleSpaces?r.slice(0,-1):r}var LO={blockquote:UD,break:qD,code:ZD,definition:eO,emphasis:iO,hardBreak:qD,heading:sO,html:cO,image:uO,imageReference:fO,inlineCode:mO,link:_O,linkReference:yO,list:TO,listItem:DO,paragraph:OO,root:AO,strong:MO,text:PO,thematicBreak:IO};function RO(){return{enter:{table:zO,tableData:UO,tableHeader:UO,tableRow:VO},exit:{codeText:WO,table:BO,tableData:HO,tableHeader:HO,tableRow:HO}}}function zO(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 BO(e){this.exit(e),this.data.inTable=void 0}function VO(e){this.enter({type:`tableRow`,children:[]},e)}function HO(e){this.exit(e)}function UO(e){this.enter({type:`tableCell`,children:[]},e)}function WO(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,GO));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function GO(e,t){return t===`|`?t:e}function KO(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
49
|
+
`,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(`
|
|
50
|
+
`))}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 BD(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=LO.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function qO(){return{exit:{taskListCheckValueChecked:YO,taskListCheckValueUnchecked:YO,paragraph:XO}}}function JO(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:ZO}}}function YO(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function XO(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 ZO(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=LO.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 QO(){return[iD(),OD(),ND(),RO(),qO()]}function $O(e){return{extensions:[aD(),kD(e),PD(),KO(e),JO()]}}var ek={tokenize:mk,partial:!0},tk={tokenize:hk,partial:!0},nk={tokenize:gk,partial:!0},rk={tokenize:_k,partial:!0},ik={tokenize:vk,partial:!0},ak={name:`wwwAutolink`,tokenize:fk,previous:yk},ok={name:`protocolAutolink`,tokenize:pk,previous:bk},sk={name:`emailAutolink`,tokenize:dk,previous:xk},ck={};function lk(){return{text:ck}}for(var uk=48;uk<123;)ck[uk]=sk,uk++,uk===58?uk=65:uk===91&&(uk=97);ck[43]=sk,ck[45]=sk,ck[46]=sk,ck[95]=sk,ck[72]=[sk,ok],ck[104]=[sk,ok],ck[87]=[sk,ak],ck[119]=[sk,ak];function dk(e,t,n){let r=this,i,a;return o;function o(t){return!Sk(t)||!xk.call(r,r.previous)||Ck(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Sk(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(ik,u,l)(t):t===45||t===95||aS(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&&iS(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function fk(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!yk.call(r,r.previous)||Ck(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(ek,e.attempt(tk,e.attempt(nk,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function pk(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&bk.call(r,r.previous)&&!Ck(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(iS(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||sS(t)||dS(t)||mS(t)||pS(t)?n(t):e.attempt(tk,e.attempt(nk,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function mk(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 hk(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(rk,c,s)(t):t===null||dS(t)||mS(t)||t!==45&&pS(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 gk(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(rk,t,a)(o):o===null||dS(o)||mS(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function _k(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||dS(o)||mS(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||dS(e)||mS(e)?t(e):r(e)}function a(e){return iS(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):iS(t)?(e.consume(t),o):n(t)}}function vk(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return aS(e)?n(e):t(e)}}function yk(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||dS(e)}function bk(e){return!iS(e)}function xk(e){return!(e===47||Sk(e))}function Sk(e){return e===43||e===45||e===46||e===95||aS(e)}function Ck(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 wk={tokenize:Mk,partial:!0};function Tk(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:kk,continuation:{tokenize:Ak},exit:jk}},text:{91:{name:`gfmFootnoteCall`,tokenize:Ok},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Ek,resolveTo:Dk}}}}function Ek(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=rS(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 Dk(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 Ok(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||dS(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(rS(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return dS(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 kk(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||dS(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=rS(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return dS(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),_S(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Ak(e,t,n){return e.check(MS,t,e.attempt(wk,t,n))}function jk(e){e.exit(`gfmFootnoteDefinition`)}function Mk(e,t,n){let r=this;return _S(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 Nk(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&&Xx(o,o.length,0,TS(s,e.slice(r+1,n),t)),Xx(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Xx(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=wS(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=wS(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Pk=class{constructor(){this.map=[]}add(e,t,n){Fk(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}};function Fk(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Ik(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 Lk(){return{flow:{null:{name:`table`,tokenize:Rk,resolveAll:zk}}}}function Rk(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 e=r.events[t][1].type;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?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):G(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):fS(t)?_S(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||dS(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,fS(t)?_S(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 fS(t)?_S(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||G(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 fS(t)?_S(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||G(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||G(n)?(e.exit(`tableRow`),t(n)):fS(n)?_S(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||dS(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 zk(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 Pk;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Vk(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=Bk(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=Bk(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=Bk(f,t,o,i,n,d)):(o[0]=o[1],d=Bk(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Vk(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=Ik(t.events,n))}return e}function Bk(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Hk(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Hk(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=Hk(t.events,n[2]),a=Hk(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({},Hk(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Vk(e,t,n,r,i){let a=[],o=Hk(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 Hk(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Uk={name:`tasklistCheck`,tokenize:Gk};function Wk(){return{text:{91:Uk}}}function Gk(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 dS(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 G(r)?t(r):fS(r)?e.check({tokenize:Kk},t,n)(r):n(r)}}function Kk(e,t,n){return _S(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function qk(e){return $x([lk(),Tk(),Nk(e),Lk(),Wk()])}var Jk={};function Yk(e){let t=this,n=e||Jk,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(qk(n)),a.push(QO()),o.push($O(n))}var Xk=({documentation:e})=>!e||e.trim().length===0?null:(0,ye.jsx)(`div`,{className:`prose dark:prose-invert bg-popover max-h-96 max-w-md overflow-y-auto p-2 text-sm`,children:(0,ye.jsx)(GE,{remarkPlugins:[Yk],children:e})});function Zk(e){return e.replace(/\$\{(\d+):([^}]*)\}/g,"${$2}").replace(/\$\d+/g,"${}")}function Qk(e){return e.replace(/\$\{\d+:?([^}]*)\}/g,`$1`).replace(/\$\d+/g,``)}function $k(e,t){let n=e.textEdit&&`newText`in e.textEdit?e.textEdit.newText:e.insertText||e.label;e.insertTextFormat===_y.Snippet?n=Zk(n):n.includes(`$`)&&(n=Qk(n));let r=n.includes("${}")||n.includes("${");if(e.textEdit&&`range`in e.textEdit){let i=t.offsetAt(e.textEdit.range.start),a=t.offsetAt(e.textEdit.range.end);return e.insertTextFormat===_y.Snippet&&r?(e,t)=>{pg(n)(e,t,i,a)}:e=>{e.dispatch({changes:{from:i,to:a,insert:n},selection:{anchor:i+n.length}})}}return e.insertTextFormat===_y.Snippet&&r?pg(n):n}async function eA(e,t,n,r){let{document:i,jsonDocument:a}=Mv(e,r),o=i.positionAt(t),s=await r.languageService.doComplete(i,o,a);if(!s||s.items.length===0)return null;let c=!1,l=s.items.map(e=>{e.textEdit&&`range`in e.textEdit&&(c=!0);let t=typeof e.documentation==`string`?e.documentation:e.documentation?.value;return{label:e.label,type:tA(e.kind),detail:e.detail,info:t?()=>Sv(Xk,{documentation:t}):void 0,apply:$k(e,i),boost:e.sortText?-(parseInt(e.sortText,10)||0):0}});return{from:n??t,options:l,validFor:c?void 0:/^[\w$"]*$/}}function tA(e){switch(e){case gy.Property:return`property`;case gy.Value:return`constant`;case gy.Enum:return`enum`;case gy.Keyword:return`keyword`;case gy.Class:return`class`;case gy.Function:return`function`;case gy.Variable:return`variable`;case gy.Text:return`text`;default:return`property`}}function nA(e){return xg({activateOnTyping:!0,override:[async t=>{let n=t.state.doc.toString(),r=t.matchBefore(/[\w$"]*$/);return eA(n,t.pos,r?.from,e)}]})}function rA(){return z.updateListener.of(e=>{if(!e.docChanged)return;let t=!1;e.changes.iterChanges((e,n,r,i,a)=>{let o=a.toString();/^["']$/.test(o)&&(t=!0)}),t&&requestAnimationFrame(()=>{try{Jh(e.view)}catch(e){console.debug(`Could not trigger completion:`,e)}})})}var iA=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new aA(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new oA(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216))if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new aA(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},aA=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},oA=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},sA=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function cA(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var lA=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},uA=new lA,dA=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=uA,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=uA,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},fA=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;hA(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};fA.prototype.contextual=fA.prototype.fallback=fA.prototype.extend=!1;var pA=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?cA(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(hA(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};pA.prototype.contextual=fA.prototype.fallback=fA.prototype.extend=!1;var mA=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function hA(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||_A(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function gA(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function _A(e,t,n,r){let i=gA(n,r,t);return i<0||gA(n,r,e)<i}var vA=typeof process<`u`&&/\bparse\b/.test({}.LOG),yA=null;function bA(e,t,n){let r=e.cursor(Al.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var xA=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?bA(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?bA(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof jl){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(B.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},SA=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new lA)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new lA,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new lA,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535)if(o[s+1]==1)s=kA(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(kA(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(kA(o,s+1),t,n,r))}return r}},CA=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new dA(t,r),this.tokens=new SA(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[iA.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new xA(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&AA(r);if(e)return vA&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw vA&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return vA&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=vA?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(B.contextHash)||0)==n))return e.useNode(o,r),vA&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof jl)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof jl&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),vA&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),vA&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return wA(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=vA?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),vA&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(vA&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)vA&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))vA&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),vA&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),wA(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),jl.build({buffer:sA.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(yA||=new WeakMap).get(e);return t||yA.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function wA(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var TA=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},EA=e=>e,DA=class{constructor(e){this.start=e.start,this.shift=e.shift||EA,this.reduce=e.reduce||EA,this.reuse=e.reuse||EA,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},OA=class e extends $l{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=B[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new Dl(t.map((t,i)=>El.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=xl;let a=cA(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(jA),this.states=cA(e.states,Uint32Array),this.data=cA(e.stateData),this.goto=cA(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new fA(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new CA(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535)if(n[i+1]==1)a=n[i=kA(n,i+2)];else if(n[i+1]==2)return kA(n,i+2);else break;if(a==t||a==0)return kA(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=kA(this.data,n+2);else break;r=t(kA(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=kA(this.data,n+2);else break;if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=jA(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new TA(e,n,r)}static deserialize(t){return new e(t)}};function kA(e,t){return e[t]|e[t+1]<<16}function AA(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function jA(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var MA=xu({String:H.string,Number:H.number,"True False":H.bool,PropertyName:H.propertyName,Null:H.null,", :":H.separator,"[ ]":H.squareBracket,"{ }":H.brace}),NA=OA.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:`#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O`,goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:`⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array`,maxTerm:25,nodeProps:[[`isolate`,-2,6,11,``],[`openedBy`,7,`{`,14,`[`],[`closedBy`,8,`}`,15,`]`]],propSources:[MA],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),PA=Ju.define({name:`json`,parser:NA.configure({props:[hd.add({Object:Dd({except:/^\s*\}/}),Array:Dd({except:/^\s*\]/})}),kd.add({"Object Array":Ad})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function FA(){return new sd(PA)}function IA({hideGutter:e}={}){let t=Ve(),n=yv();return z.theme({"&":{backgroundColor:`var(--color-background)`,color:`var(--color-foreground)`,height:`100%`},"&.cm-focused":{outline:`none`},".cm-content":{caretColor:`var(--color-primary)`,fontFamily:n,fontSize:`12px`,lineHeight:`18px`,paddingTop:`0`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--color-primary)`},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`var(--color-accent)`},".cm-activeLine":{backgroundColor:`var(--color-muted)`},".cm-selectionMatch":{backgroundColor:`hsl(var(--editor-selection-match) / 0.27)`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`hsl(var(--editor-bracket-match) / 0.1)`,outline:`1px solid var(--color-border)`},".cm-gutters":{backgroundColor:`var(--color-background)`,color:`var(--color-muted-foreground)`,border:`none`,paddingLeft:`20px`,...e&&{display:`none`}},".cm-gutterElement":{marginTop:`0`,paddingRight:`0`},".cm-activeLineGutter":{backgroundColor:`var(--color-muted)`},".cm-foldPlaceholder":{backgroundColor:`var(--color-editor-fold-placeholder)`,border:`1px solid var(--color-border)`,color:`var(--color-foreground)`},".cm-tooltip":{backgroundColor:`var(--color-popover)`,color:`var(--color-popover-foreground)`,border:`1px solid var(--color-border)`},".cm-tooltip-hover":{backgroundColor:`var(--color-popover)`,color:`var(--color-popover-foreground)`,border:`1px solid var(--color-border)`,padding:`4px 8px`},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:`var(--color-accent)`,color:`var(--color-foreground)`}},".cm-completionLabel":{color:`var(--color-foreground)`},".cm-completionDetail":{color:`var(--color-muted-foreground)`,fontStyle:`italic`},".cm-panels":{backgroundColor:`var(--color-background)`,color:`var(--color-foreground)`},".cm-panels.cm-panels-top":{borderBottom:`1px solid var(--color-border)`},".cm-panels.cm-panels-bottom":{borderTop:`1px solid var(--color-border)`},".cm-searchMatch":{backgroundColor:`hsl(var(--editor-search-match) / 0.2)`,outline:`1px solid var(--color-border)`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`var(--color-editor-search-match-selected)`},".cm-button":{backgroundImage:`none`,backgroundColor:`var(--color-accent)`,color:`var(--color-foreground)`,border:`1px solid var(--color-border)`},".cm-textfield":{backgroundColor:`var(--color-background)`,color:`var(--color-foreground)`,border:`1px solid var(--color-border)`},".cm-lint-marker":{width:`1em`,height:`1em`},".cm-lint-marker-error":{content:`✗`,color:`var(--color-editor-lint-error)`},".cm-lint-marker-warning":{content:`⚠`,color:`var(--color-editor-lint-warning)`},".cm-diagnostic-error":{borderLeft:`3px solid var(--color-editor-lint-error)`},".cm-diagnostic-warning":{borderLeft:`none`}},{dark:t===`dark`})}function LA(e={}){return[IA(e),cf(rf.define([{tag:[H.propertyName],color:`var(--color-editor-property)`},{tag:[H.string],color:`var(--color-editor-string)`},{tag:[H.number],color:`var(--color-editor-number)`},{tag:[H.bool,H.null,H.keyword],color:`var(--color-editor-keyword)`},{tag:[H.bracket,H.punctuation,H.separator],color:`var(--color-editor-punctuation)`},{tag:[H.comment],color:`var(--color-editor-comment)`},{tag:H.invalid,color:`var(--color-editor-invalid)`}]))]}var RA=[xc({get parent(){return typeof document<`u`?document.body:void 0}}),z.theme({".cm-tooltip":{zIndex:`100000`,padding:`0 !important`},".cm-tooltip-lint":{fontSize:`12px`,fontFamily:yv(),maxWidth:`500px`,padding:`4px 0 !important`,lineHeight:`18px`},".cm-diagnostic":{padding:`0 !important`,margin:`0 !important`,lineHeight:`1.6`,"&:not(:first-child)":{borderTop:`1px solid var(--color-border)`,marginTop:`8px !important`,paddingTop:`8px !important`}},".cm-diagnosticText":{fontSize:`12px`,display:`block`,fontFamily:`inherit`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,lineHeight:`18px`,color:`var(--color-foreground)`,padding:0}})];function zA(e,t=!1){let n=e.length,r=0,i=``,a=0,o=16,s=0,c=0,l=0,u=0,d=0;function f(t,n){let i=0,a=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)a=a*16+t-48;else if(t>=65&&t<=70)a=a*16+t-65+10;else if(t>=97&&t<=102)a=a*16+t-97+10;else break;r++,i++}return i<t&&(a=-1),a}function p(e){r=e,i=``,a=0,o=16,d=0}function m(){let t=r;if(e.charCodeAt(r)===48)r++;else for(r++;r<e.length&&HA(e.charCodeAt(r));)r++;if(r<e.length&&e.charCodeAt(r)===46)if(r++,r<e.length&&HA(e.charCodeAt(r)))for(r++;r<e.length&&HA(e.charCodeAt(r));)r++;else return d=3,e.substring(t,r);let n=r;if(r<e.length&&(e.charCodeAt(r)===69||e.charCodeAt(r)===101))if(r++,(r<e.length&&e.charCodeAt(r)===43||e.charCodeAt(r)===45)&&r++,r<e.length&&HA(e.charCodeAt(r))){for(r++;r<e.length&&HA(e.charCodeAt(r));)r++;n=r}else d=3;return e.substring(t,n)}function h(){let t=``,i=r;for(;;){if(r>=n){t+=e.substring(i,r),d=2;break}let a=e.charCodeAt(r);if(a===34){t+=e.substring(i,r),r++;break}if(a===92){if(t+=e.substring(i,r),r++,r>=n){d=2;break}switch(e.charCodeAt(r++)){case 34:t+=`"`;break;case 92:t+=`\\`;break;case 47:t+=`/`;break;case 98:t+=`\b`;break;case 102:t+=`\f`;break;case 110:t+=`
|
|
51
|
+
`;break;case 114:t+=`\r`;break;case 116:t+=` `;break;case 117:let e=f(4,!0);e>=0?t+=String.fromCharCode(e):d=4;break;default:d=5}i=r;continue}if(a>=0&&a<=31)if(VA(a)){t+=e.substring(i,r),d=2;break}else d=6;r++}return t}function g(){if(i=``,d=0,a=r,c=s,u=l,r>=n)return a=n,o=17;let t=e.charCodeAt(r);if(BA(t)){do r++,i+=String.fromCharCode(t),t=e.charCodeAt(r);while(BA(t));return o=15}if(VA(t))return r++,i+=String.fromCharCode(t),t===13&&e.charCodeAt(r)===10&&(r++,i+=`
|
|
52
|
+
`),s++,l=r,o=14;switch(t){case 123:return r++,o=1;case 125:return r++,o=2;case 91:return r++,o=3;case 93:return r++,o=4;case 58:return r++,o=6;case 44:return r++,o=5;case 34:return r++,i=h(),o=10;case 47:let c=r-1;if(e.charCodeAt(r+1)===47){for(r+=2;r<n&&!VA(e.charCodeAt(r));)r++;return i=e.substring(c,r),o=12}if(e.charCodeAt(r+1)===42){r+=2;let t=n-1,a=!1;for(;r<t;){let t=e.charCodeAt(r);if(t===42&&e.charCodeAt(r+1)===47){r+=2,a=!0;break}r++,VA(t)&&(t===13&&e.charCodeAt(r)===10&&r++,s++,l=r)}return a||(r++,d=1),i=e.substring(c,r),o=13}return i+=String.fromCharCode(t),r++,o=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!HA(e.charCodeAt(r)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=m(),o=11;default:for(;r<n&&_(t);)r++,t=e.charCodeAt(r);if(a!==r){switch(i=e.substring(a,r),i){case`true`:return o=8;case`false`:return o=9;case`null`:return o=7}return o=16}return i+=String.fromCharCode(t),r++,o=16}}function _(e){if(BA(e)||VA(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function v(){let e;do e=g();while(e>=12&&e<=15);return e}return{setPosition:p,getPosition:()=>r,scan:t?v:g,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>a,getTokenLength:()=>r-a,getTokenStartLine:()=>c,getTokenStartCharacter:()=>a-u,getTokenError:()=>d}}function BA(e){return e===32||e===9}function VA(e){return e===10||e===13}function HA(e){return e>=48&&e<=57}var UA;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})(UA||={});var WA=Array(20).fill(0).map((e,t)=>` `.repeat(t)),GA=200,KA={" ":{"\n":Array(GA).fill(0).map((e,t)=>`
|
|
53
|
+
`+` `.repeat(t)),"\r":Array(GA).fill(0).map((e,t)=>`\r`+` `.repeat(t)),"\r\n":Array(GA).fill(0).map((e,t)=>`\r
|
|
54
|
+
`+` `.repeat(t))}," ":{"\n":Array(GA).fill(0).map((e,t)=>`
|
|
55
|
+
`+` `.repeat(t)),"\r":Array(GA).fill(0).map((e,t)=>`\r`+` `.repeat(t)),"\r\n":Array(GA).fill(0).map((e,t)=>`\r
|
|
56
|
+
`+` `.repeat(t))}},qA=[`
|
|
57
|
+
`,`\r`,`\r
|
|
58
|
+
`];function JA(e,t,n){let r,i,a,o,s;if(t){for(o=t.offset,s=o+t.length,a=o;a>0&&!QA(e,a-1);)a--;let c=s;for(;c<e.length&&!QA(e,c);)c++;i=e.substring(a,c),r=XA(i,n)}else i=e,r=0,a=0,o=0,s=e.length;let c=ZA(n,e),l=qA.includes(c),u=0,d=0,f;f=n.insertSpaces?WA[n.tabSize||4]??YA(WA[1],n.tabSize||4):` `;let p=f===` `?` `:` `,m=zA(i,!1),h=!1;function g(){if(u>1)return YA(c,u)+YA(f,r+d);let e=f.length*(r+d);return!l||e>KA[p][c].length?c+YA(f,r+d):e<=0?c:KA[p][c][e]}function _(){let e=m.scan();for(u=0;e===15||e===14;)e===14&&n.keepLines?u+=1:e===14&&(u=1),e=m.scan();return h=e===16||m.getTokenError()!==0,e}let v=[];function y(n,r,i){!h&&(!t||r<s&&i>o)&&e.substring(r,i)!==n&&v.push({offset:r,length:i-r,content:n})}let b=_();if(n.keepLines&&u>0&&y(YA(c,u),0,0),b!==17){let e=m.getTokenOffset()+a;y(f.length*r<20&&n.insertSpaces?WA[f.length*r]:YA(f,r),a,e)}for(;b!==17;){let e=m.getTokenOffset()+m.getTokenLength()+a,t=_(),r=``,i=!1;for(;u===0&&(t===12||t===13);){let n=m.getTokenOffset()+a;y(WA[1],e,n),e=m.getTokenOffset()+m.getTokenLength()+a,i=t===12,r=i?g():``,t=_()}if(t===2)b!==1&&d--,n.keepLines&&u>0||!n.keepLines&&b!==1?r=g():n.keepLines&&(r=WA[1]);else if(t===4)b!==3&&d--,n.keepLines&&u>0||!n.keepLines&&b!==3?r=g():n.keepLines&&(r=WA[1]);else{switch(b){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():WA[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():WA[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=WA[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=WA[1]);break;case 10:n.keepLines&&u>0?r=g():t===6&&!i&&(r=``);break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():(t===12||t===13)&&!i?r=WA[1]:t!==5&&t!==17&&(h=!0);break;case 16:h=!0;break}u>0&&(t===12||t===13)&&(r=g())}t===17&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?c:``);let o=m.getTokenOffset()+a;y(r,e,o),b=t}return v}function YA(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}function XA(e,t){let n=0,r=0,i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===WA[1])r++;else if(t===` `)r+=i;else break;n++}return Math.floor(r/i)}function ZA(e,t){for(let e=0;e<t.length;e++){let n=t.charAt(e);if(n===`\r`)return e+1<t.length&&t.charAt(e+1)===`
|
|
59
|
+
`?`\r
|
|
60
|
+
`:`\r`;if(n===`
|
|
61
|
+
`)return`
|
|
62
|
+
`}return e&&e.eol||`
|
|
63
|
+
`}function QA(e,t){return`\r
|
|
64
|
+
`.indexOf(e.charAt(t))!==-1}var $A;(function(e){e.DEFAULT={allowTrailingComma:!1}})($A||={});function ej(e,t=[],n=$A.DEFAULT){let r=null,i=[],a=[];function o(e){Array.isArray(i)?i.push(e):r!==null&&(i[r]=e)}return aj(e,{onObjectBegin:()=>{let e={};o(e),a.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=a.pop()},onArrayBegin:()=>{let e=[];o(e),a.push(i),i=e,r=null},onArrayEnd:()=>{i=a.pop()},onLiteralValue:o,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n),i[0]}function tj(e){if(!e.parent||!e.parent.children)return[];let t=tj(e.parent);if(e.parent.type===`property`){let n=e.parent.children[0].value;t.push(n)}else if(e.parent.type===`array`){let n=e.parent.children.indexOf(e);n!==-1&&t.push(n)}return t}function nj(e){switch(e.type){case`array`:return e.children.map(nj);case`object`:let t=Object.create(null);for(let n of e.children){let e=n.children[1];e&&(t[n.children[0].value]=nj(e))}return t;case`null`:case`string`:case`number`:case`boolean`:return e.value;default:return}}function rj(e,t,n=!1){return t>=e.offset&&t<e.offset+e.length||n&&t===e.offset+e.length}function ij(e,t,n=!1){if(rj(e,t,n)){let r=e.children;if(Array.isArray(r))for(let e=0;e<r.length&&r[e].offset<=t;e++){let i=ij(r[e],t,n);if(i)return i}return e}}function aj(e,t,n=$A.DEFAULT){let r=zA(e,!1),i=[],a=0;function o(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function s(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function c(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function u(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let d=l(t.onObjectBegin),f=c(t.onObjectProperty),p=u(t.onObjectEnd),m=l(t.onArrayBegin),h=u(t.onArrayEnd),g=c(t.onLiteralValue),_=s(t.onSeparator),v=o(t.onComment),y=s(t.onError),b=n&&n.disallowComments,x=n&&n.allowTrailingComma;function S(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:b||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(e){case 12:case 13:b?C(10):v();break;case 16:C(1);break;case 15:case 14:break;default:return e}}}function C(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){S();break}else if(n.indexOf(e)!==-1)break;e=S()}}}function w(e){let t=r.getTokenValue();return e?g(t):(f(t),i.push(t)),S(),!0}function T(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(C(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return S(),!0}function E(){return r.getToken()===10?(w(!1),r.getToken()===6?(_(`:`),S(),O()||C(4,[],[2,5])):C(5,[],[2,5]),i.pop(),!0):(C(3,[],[2,5]),!1)}function ee(){d(),S();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||C(4,[],[]),_(`,`),S(),r.getToken()===2&&x)break}else e&&C(6,[],[]);E()||C(4,[],[2,5]),e=!0}return p(),r.getToken()===2?S():C(7,[2],[]),!0}function D(){m(),S();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||C(4,[],[]),_(`,`),S(),r.getToken()===4&&x)break}else t&&C(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,O()||C(4,[],[4,5]),t=!0}return h(),e||i.pop(),r.getToken()===4?S():C(8,[4],[]),!0}function O(){switch(r.getToken()){case 3:return D();case 1:return ee();case 10:return w(!0);default:return T()}}return S(),r.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):O()?(r.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}var oj=zA,sj;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(sj||={});var cj;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(cj||={});var lj=ej,uj=ij,dj=tj,fj=nj,pj;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(pj||={});function mj(e,t,n){return JA(e,t,n)}function hj(e,t){if(e===t)return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;let n,r;if(Array.isArray(e)){if(e.length!==t.length)return!1;for(n=0;n<e.length;n++)if(!hj(e[n],t[n]))return!1}else{let i=[];for(r in e)i.push(r);i.sort();let a=[];for(r in t)a.push(r);if(a.sort(),!hj(i,a))return!1;for(n=0;n<i.length;n++)if(!hj(e[i[n]],t[i[n]]))return!1}return!0}function gj(e){return typeof e==`number`}function _j(e){return e!==void 0}function vj(e){return typeof e==`boolean`}function yj(e){return typeof e==`string`}function bj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xj(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function Sj(e,t){let n=e.length-t.length;return n>0?e.lastIndexOf(t)===n:n===0?e===t:!1}function Cj(e){let t=``;xj(e,`(?i)`)&&(e=e.substring(4),t=`i`);try{return new RegExp(e,t+`u`)}catch{try{return new RegExp(e,t)}catch{return}}}function wj(e){let t=0;for(let n=0;n<e.length;n++){t++;let r=e.charCodeAt(n);55296<=r&&r<=56319&&n++}return t}var Tj;(function(e){e[e.Undefined=0]=`Undefined`,e[e.EnumValueMismatch=1]=`EnumValueMismatch`,e[e.Deprecated=2]=`Deprecated`,e[e.UnexpectedEndOfComment=257]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=258]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=259]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=260]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=261]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=262]=`InvalidCharacter`,e[e.PropertyExpected=513]=`PropertyExpected`,e[e.CommaExpected=514]=`CommaExpected`,e[e.ColonExpected=515]=`ColonExpected`,e[e.ValueExpected=516]=`ValueExpected`,e[e.CommaOrCloseBacketExpected=517]=`CommaOrCloseBacketExpected`,e[e.CommaOrCloseBraceExpected=518]=`CommaOrCloseBraceExpected`,e[e.TrailingComma=519]=`TrailingComma`,e[e.DuplicateKey=520]=`DuplicateKey`,e[e.CommentNotPermitted=521]=`CommentNotPermitted`,e[e.PropertyKeysMustBeDoublequoted=528]=`PropertyKeysMustBeDoublequoted`,e[e.SchemaUnsupportedFeature=769]=`SchemaUnsupportedFeature`,e[e.SchemaResolveError=65536]=`SchemaResolveError`})(Tj||={});var Ej;(function(e){e[e.v3=3]=`v3`,e[e.v4=4]=`v4`,e[e.v6=6]=`v6`,e[e.v7=7]=`v7`,e[e.v2019_09=19]=`v2019_09`,e[e.v2020_12=20]=`v2020_12`})(Ej||={});var Dj;(function(e){e.LATEST={textDocument:{completion:{completionItem:{documentationFormat:[my.Markdown,my.PlainText],commitCharactersSupport:!0,labelDetailsSupport:!0}}}}})(Dj||={});var Oj;(()=>{var e={975:e=>{function t(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}function n(e,t){for(var n,r=``,i=0,a=-1,o=0,s=0;s<=e.length;++s){if(s<e.length)n=e.charCodeAt(s);else{if(n===47)break;n=47}if(n===47){if(!(a===s-1||o===1))if(a!==s-1&&o===2){if(r.length<2||i!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){var c=r.lastIndexOf(`/`);if(c!==r.length-1){c===-1?(r=``,i=0):i=(r=r.slice(0,c)).length-1-r.lastIndexOf(`/`),a=s,o=0;continue}}else if(r.length===2||r.length===1){r=``,i=0,a=s,o=0;continue}}t&&(r.length>0?r+=`/..`:r=`..`,i=2)}else r.length>0?r+=`/`+e.slice(a+1,s):r=e.slice(a+1,s),i=s-a-1;a=s,o=0}else n===46&&o!==-1?++o:o=-1}return r}var r={resolve:function(){for(var e,r=``,i=!1,a=arguments.length-1;a>=-1&&!i;a--){var o;a>=0?o=arguments[a]:(e===void 0&&(e=process.cwd()),o=e),t(o),o.length!==0&&(r=o+`/`+r,i=o.charCodeAt(0)===47)}return r=n(r,!i),i?r.length>0?`/`+r:`/`:r.length>0?r:`.`},normalize:function(e){if(t(e),e.length===0)return`.`;var r=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;return(e=n(e,!r)).length!==0||r||(e=`.`),e.length>0&&i&&(e+=`/`),r?`/`+e:e},isAbsolute:function(e){return t(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return`.`;for(var e,n=0;n<arguments.length;++n){var i=arguments[n];t(i),i.length>0&&(e===void 0?e=i:e+=`/`+i)}return e===void 0?`.`:r.normalize(e)},relative:function(e,n){if(t(e),t(n),e===n||(e=r.resolve(e))===(n=r.resolve(n)))return``;for(var i=1;i<e.length&&e.charCodeAt(i)===47;++i);for(var a=e.length,o=a-i,s=1;s<n.length&&n.charCodeAt(s)===47;++s);for(var c=n.length-s,l=o<c?o:c,u=-1,d=0;d<=l;++d){if(d===l){if(c>l){if(n.charCodeAt(s+d)===47)return n.slice(s+d+1);if(d===0)return n.slice(s+d)}else o>l&&(e.charCodeAt(i+d)===47?u=d:d===0&&(u=0));break}var f=e.charCodeAt(i+d);if(f!==n.charCodeAt(s+d))break;f===47&&(u=d)}var p=``;for(d=i+u+1;d<=a;++d)d!==a&&e.charCodeAt(d)!==47||(p.length===0?p+=`..`:p+=`/..`);return p.length>0?p+n.slice(s+u):(s+=u,n.charCodeAt(s)===47&&++s,n.slice(s))},_makeLong:function(e){return e},dirname:function(e){if(t(e),e.length===0)return`.`;for(var n=e.charCodeAt(0),r=n===47,i=-1,a=!0,o=e.length-1;o>=1;--o)if((n=e.charCodeAt(o))===47){if(!a){i=o;break}}else a=!1;return i===-1?r?`/`:`.`:r&&i===1?`//`:e.slice(0,i)},basename:function(e,n){if(n!==void 0&&typeof n!=`string`)throw TypeError(`"ext" argument must be a string`);t(e);var r,i=0,a=-1,o=!0;if(n!==void 0&&n.length>0&&n.length<=e.length){if(n.length===e.length&&n===e)return``;var s=n.length-1,c=-1;for(r=e.length-1;r>=0;--r){var l=e.charCodeAt(r);if(l===47){if(!o){i=r+1;break}}else c===-1&&(o=!1,c=r+1),s>=0&&(l===n.charCodeAt(s)?--s==-1&&(a=r):(s=-1,a=c))}return i===a?a=c:a===-1&&(a=e.length),e.slice(i,a)}for(r=e.length-1;r>=0;--r)if(e.charCodeAt(r)===47){if(!o){i=r+1;break}}else a===-1&&(o=!1,a=r+1);return a===-1?``:e.slice(i,a)},extname:function(e){t(e);for(var n=-1,r=0,i=-1,a=!0,o=0,s=e.length-1;s>=0;--s){var c=e.charCodeAt(s);if(c!==47)i===-1&&(a=!1,i=s+1),c===46?n===-1?n=s:o!==1&&(o=1):n!==-1&&(o=-1);else if(!a){r=s+1;break}}return n===-1||i===-1||o===0||o===1&&n===i-1&&n===r+1?``:e.slice(n,i)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return function(e,t){var n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+`/`+r:r}(0,e)},parse:function(e){t(e);var n={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return n;var r,i=e.charCodeAt(0),a=i===47;a?(n.root=`/`,r=1):r=0;for(var o=-1,s=0,c=-1,l=!0,u=e.length-1,d=0;u>=r;--u)if((i=e.charCodeAt(u))!==47)c===-1&&(l=!1,c=u+1),i===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1);else if(!l){s=u+1;break}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===s+1?c!==-1&&(n.base=n.name=s===0&&a?e.slice(1,c):e.slice(s,c)):(s===0&&a?(n.name=e.slice(1,o),n.base=e.slice(1,c)):(n.name=e.slice(s,o),n.base=e.slice(s,c)),n.ext=e.slice(o,c)),s>0?n.dir=e.slice(0,s-1):a&&(n.dir=`/`),n},sep:`/`,delimiter:`:`,win32:null,posix:null};r.posix=r,e.exports=r}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,`__esModule`,{value:!0})};var r={};let i;n.r(r),n.d(r,{URI:()=>u,Utils:()=>C}),typeof process==`object`?i=process.platform===`win32`:typeof navigator==`object`&&(i=navigator.userAgent.indexOf(`Windows`)>=0);let a=/^\w[\w\d+.-]*$/,o=/^\//,s=/^\/\//;function c(e,t){if(!e.scheme&&t)throw Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!a.test(e.scheme))throw Error(`[UriError]: Scheme contains illegal characters.`);if(e.path){if(e.authority){if(!o.test(e.path))throw Error(`[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character`)}else if(s.test(e.path))throw Error(`[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")`)}}let l=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class u{static isUri(e){return e instanceof u||!!e&&typeof e.authority==`string`&&typeof e.fragment==`string`&&typeof e.path==`string`&&typeof e.query==`string`&&typeof e.scheme==`string`&&typeof e.fsPath==`string`&&typeof e.with==`function`&&typeof e.toString==`function`}scheme;authority;path;query;fragment;constructor(e,t,n,r,i,a=!1){typeof e==`object`?(this.scheme=e.scheme||``,this.authority=e.authority||``,this.path=e.path||``,this.query=e.query||``,this.fragment=e.fragment||``):(this.scheme=function(e,t){return e||t?e:`file`}(e,a),this.authority=t||``,this.path=function(e,t){switch(e){case`https`:case`http`:case`file`:t?t[0]!==`/`&&(t=`/`+t):t=`/`}return t}(this.scheme,n||``),this.query=r||``,this.fragment=i||``,c(this,a))}get fsPath(){return g(this,!1)}with(e){if(!e)return this;let{scheme:t,authority:n,path:r,query:i,fragment:a}=e;return t===void 0?t=this.scheme:t===null&&(t=``),n===void 0?n=this.authority:n===null&&(n=``),r===void 0?r=this.path:r===null&&(r=``),i===void 0?i=this.query:i===null&&(i=``),a===void 0?a=this.fragment:a===null&&(a=``),t===this.scheme&&n===this.authority&&r===this.path&&i===this.query&&a===this.fragment?this:new f(t,n,r,i,a)}static parse(e,t=!1){let n=l.exec(e);return n?new f(n[2]||``,b(n[4]||``),b(n[5]||``),b(n[7]||``),b(n[9]||``),t):new f(``,``,``,``,``)}static file(e){let t=``;if(i&&(e=e.replace(/\\/g,`/`)),e[0]===`/`&&e[1]===`/`){let n=e.indexOf(`/`,2);n===-1?(t=e.substring(2),e=`/`):(t=e.substring(2,n),e=e.substring(n)||`/`)}return new f(`file`,t,e,``,``)}static from(e){let t=new f(e.scheme,e.authority,e.path,e.query,e.fragment);return c(t,!0),t}toString(e=!1){return _(this,e)}toJSON(){return this}static revive(e){if(e){if(e instanceof u)return e;{let t=new f(e);return t._formatted=e.external,t._fsPath=e._sep===d?e.fsPath:null,t}}return e}}let d=i?1:void 0;class f extends u{_formatted=null;_fsPath=null;get fsPath(){return this._fsPath||=g(this,!1),this._fsPath}toString(e=!1){return e?_(this,!0):(this._formatted||=_(this,!1),this._formatted)}toJSON(){let e={$mid:1};return this._fsPath&&(e.fsPath=this._fsPath,e._sep=d),this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),this.query&&(e.query=this.query),this.fragment&&(e.fragment=this.fragment),e}}let p={58:`%3A`,47:`%2F`,63:`%3F`,35:`%23`,91:`%5B`,93:`%5D`,64:`%40`,33:`%21`,36:`%24`,38:`%26`,39:`%27`,40:`%28`,41:`%29`,42:`%2A`,43:`%2B`,44:`%2C`,59:`%3B`,61:`%3D`,32:`%20`};function m(e,t,n){let r,i=-1;for(let a=0;a<e.length;a++){let o=e.charCodeAt(a);if(o>=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57||o===45||o===46||o===95||o===126||t&&o===47||n&&o===91||n&&o===93||n&&o===58)i!==-1&&(r+=encodeURIComponent(e.substring(i,a)),i=-1),r!==void 0&&(r+=e.charAt(a));else{r===void 0&&(r=e.substr(0,a));let t=p[o];t===void 0?i===-1&&(i=a):(i!==-1&&(r+=encodeURIComponent(e.substring(i,a)),i=-1),r+=t)}}return i!==-1&&(r+=encodeURIComponent(e.substring(i))),r===void 0?e:r}function h(e){let t;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===35||r===63?(t===void 0&&(t=e.substr(0,n)),t+=p[r]):t!==void 0&&(t+=e[n])}return t===void 0?e:t}function g(e,t){let n;return n=e.authority&&e.path.length>1&&e.scheme===`file`?`//${e.authority}${e.path}`:e.path.charCodeAt(0)===47&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&e.path.charCodeAt(2)===58?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,i&&(n=n.replace(/\//g,`\\`)),n}function _(e,t){let n=t?h:m,r=``,{scheme:i,authority:a,path:o,query:s,fragment:c}=e;if(i&&(r+=i,r+=`:`),(a||i===`file`)&&(r+=`/`,r+=`/`),a){let e=a.indexOf(`@`);if(e!==-1){let t=a.substr(0,e);a=a.substr(e+1),e=t.lastIndexOf(`:`),e===-1?r+=n(t,!1,!1):(r+=n(t.substr(0,e),!1,!1),r+=`:`,r+=n(t.substr(e+1),!1,!0)),r+=`@`}a=a.toLowerCase(),e=a.lastIndexOf(`:`),e===-1?r+=n(a,!1,!0):(r+=n(a.substr(0,e),!1,!0),r+=a.substr(e))}if(o){if(o.length>=3&&o.charCodeAt(0)===47&&o.charCodeAt(2)===58){let e=o.charCodeAt(1);e>=65&&e<=90&&(o=`/${String.fromCharCode(e+32)}:${o.substr(3)}`)}else if(o.length>=2&&o.charCodeAt(1)===58){let e=o.charCodeAt(0);e>=65&&e<=90&&(o=`${String.fromCharCode(e+32)}:${o.substr(2)}`)}r+=n(o,!0,!1)}return s&&(r+=`?`,r+=n(s,!1,!1)),c&&(r+=`#`,r+=t?c:m(c,!1,!1)),r}function v(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+v(e.substr(3)):e}}let y=/(%[0-9A-Za-z][0-9A-Za-z])+/g;function b(e){return e.match(y)?e.replace(y,(e=>v(e))):e}var x=n(975);let S=x.posix||x;var C;(function(e){e.joinPath=function(e,...t){return e.with({path:S.join(e.path,...t)})},e.resolvePath=function(e,...t){let n=e.path,r=!1;n[0]!==`/`&&(n=`/`+n,r=!0);let i=S.resolve(n,...t);return r&&i[0]===`/`&&!e.authority&&(i=i.substring(1)),e.with({path:i})},e.dirname=function(e){if(e.path.length===0||e.path===`/`)return e;let t=S.dirname(e.path);return t.length===1&&t.charCodeAt(0)===46&&(t=``),e.with({path:t})},e.basename=function(e){return S.basename(e.path)},e.extname=function(e){return S.extname(e.path)}})(C||={}),Oj=r})();var{URI:kj,Utils:Aj}=Oj,jj;function K(...e){let t=e[0],n,r,i;if(typeof t==`string`)n=t,r=t,e.splice(0,1),i=!e||typeof e[0]!=`object`?e:e[0];else if(t instanceof Array){let n=e.slice(1);if(t.length!==n.length+1)throw Error(`expected a string as the first argument to l10n.t`);let r=t[0];for(let e=1;e<t.length;e++)r+=`{${e-1}}`+t[e];return K(r,...n)}else r=t.message,n=r,t.comment&&t.comment.length>0&&(n+=`/${Array.isArray(t.comment)?t.comment.join(``):t.comment}`),i=t.args??{};let a=jj?.[n];return a?typeof a==`string`?Nj(a,i):a.comment?Nj(a.message,i):Nj(r,i):Nj(r,i)}var Mj=/{([^}]+)}/g;function Nj(e,t){return Object.keys(t).length===0?e:e.replace(Mj,(e,n)=>t[n]??e)}var Pj={"color-hex":{errorMessage:K(`Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.`),pattern:/^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$/},"date-time":{errorMessage:K(`String is not a RFC3339 date-time.`),pattern:/^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i},date:{errorMessage:K(`String is not a RFC3339 date.`),pattern:/^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/i},time:{errorMessage:K(`String is not a RFC3339 time.`),pattern:/^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i},email:{errorMessage:K(`String is not an e-mail address.`),pattern:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}))$/},hostname:{errorMessage:K(`String is not a hostname.`),pattern:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i},ipv4:{errorMessage:K(`String is not an IPv4 address.`),pattern:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/},ipv6:{errorMessage:K(`String is not an IPv6 address.`),pattern:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i}},Fj=class{constructor(e,t,n=0){this.offset=t,this.length=n,this.parent=e}get children(){return[]}toString(){return`type: `+this.type+` (`+this.offset+`/`+this.length+`)`+(this.parent?` parent: {`+this.parent.toString()+`}`:``)}},Ij=class extends Fj{constructor(e,t){super(e,t),this.type=`null`,this.value=null}},Lj=class extends Fj{constructor(e,t,n){super(e,n),this.type=`boolean`,this.value=t}},Rj=class extends Fj{constructor(e,t){super(e,t),this.type=`array`,this.items=[]}get children(){return this.items}},zj=class extends Fj{constructor(e,t){super(e,t),this.type=`number`,this.isInteger=!0,this.value=NaN}},Bj=class extends Fj{constructor(e,t,n){super(e,t,n),this.type=`string`,this.value=``}},Vj=class extends Fj{constructor(e,t,n){super(e,t),this.type=`property`,this.colonOffset=-1,this.keyNode=n}get children(){return this.valueNode?[this.keyNode,this.valueNode]:[this.keyNode]}},Hj=class extends Fj{constructor(e,t){super(e,t),this.type=`object`,this.properties=[]}get children(){return this.properties}};function Uj(e){return vj(e)?e?{}:{not:{}}:e}var Wj;(function(e){e[e.Key=0]=`Key`,e[e.Enum=1]=`Enum`})(Wj||={});var Gj=`http://json-schema.org/`,Kj=`https://json-schema.org/`;function qj(e){e.startsWith(Gj)&&(e=Kj+e.substring(Gj.length));try{return kj.parse(e).toString(!0)}catch{return e}}function Jj(e){return Yj[qj(e)]??void 0}var Yj={"https://json-schema.org/draft-03/schema":Ej.v3,"https://json-schema.org/draft-04/schema":Ej.v4,"https://json-schema.org/draft-06/schema":Ej.v6,"https://json-schema.org/draft-07/schema":Ej.v7,"https://json-schema.org/draft/2019-09/schema":Ej.v2019_09,"https://json-schema.org/draft/2020-12/schema":Ej.v2020_12},Xj=class{constructor(e){this.schemaDraft=e}},Zj=class e{constructor(e=-1,t){this.focusOffset=e,this.exclude=t,this.schemas=[]}add(e){this.schemas.push(e)}merge(e){Array.prototype.push.apply(this.schemas,e.schemas)}include(e){return(this.focusOffset===-1||rM(e,this.focusOffset))&&e!==this.exclude}newSub(){return new e(-1,this.exclude)}},Qj=class{constructor(){}get schemas(){return[]}add(e){}merge(e){}include(e){return!0}newSub(){return this}};Qj.instance=new Qj;var $j=class{constructor(){this.problems=[],this.propertiesMatches=0,this.processedProperties=new Set,this.propertiesValueMatches=0,this.primaryValueMatches=0,this.enumValueMatch=!1,this.enumValues=void 0}hasProblems(){return!!this.problems.length}merge(e){this.problems=this.problems.concat(e.problems),this.propertiesMatches+=e.propertiesMatches,this.propertiesValueMatches+=e.propertiesValueMatches,this.mergeProcessedProperties(e)}mergeEnumValues(e){!this.enumValueMatch&&!e.enumValueMatch&&this.enumValues&&e.enumValues&&(this.enumValues=this.enumValues.concat(e.enumValues))}updateEnumMismatchProblemMessages(){if(!this.enumValueMatch&&this.enumValues)for(let e of this.problems)e.code===Tj.EnumValueMismatch&&(e.message=K(`Value is not accepted. Valid values: {0}.`,this.enumValues.map(e=>JSON.stringify(e)).join(`, `)))}mergePropertyMatch(e){this.problems=this.problems.concat(e.problems),this.propertiesMatches++,(e.enumValueMatch||!e.hasProblems()&&e.propertiesMatches)&&this.propertiesValueMatches++,e.enumValueMatch&&e.enumValues&&e.enumValues.length===1&&this.primaryValueMatches++}mergeProcessedProperties(e){e.processedProperties.forEach(e=>this.processedProperties.add(e))}compare(e){let t=this.hasProblems();return t===e.hasProblems()?this.enumValueMatch===e.enumValueMatch?this.primaryValueMatches===e.primaryValueMatches?this.propertiesValueMatches===e.propertiesValueMatches?this.propertiesMatches-e.propertiesMatches:this.propertiesValueMatches-e.propertiesValueMatches:this.primaryValueMatches-e.primaryValueMatches:e.enumValueMatch?-1:1:t?-1:1}};function eM(e,t=[],n=[]){return new iM(e,t,n)}function tM(e){return fj(e)}function nM(e){return dj(e)}function rM(e,t,n=!1){return t>=e.offset&&t<e.offset+e.length||n&&t===e.offset+e.length}var iM=class{constructor(e,t=[],n=[]){this.root=e,this.syntaxErrors=t,this.comments=n}getNodeFromOffset(e,t=!1){if(this.root)return uj(this.root,e,t)}visit(e){if(this.root){let t=n=>{let r=e(n),i=n.children;if(Array.isArray(i))for(let e=0;e<i.length&&r;e++)r=t(i[e]);return r};t(this.root)}}validate(e,t,n=Xv.Warning,r){if(this.root&&t){let i=new $j;return oM(this.root,t,i,Qj.instance,new Xj(r??aM(t))),i.problems.map(t=>{let r=Vv.create(e.positionAt(t.location.offset),e.positionAt(t.location.offset+t.location.length));return $v.create(r,t.message,t.severity??n,t.code)})}}getMatchingSchemas(e,t=-1,n){if(this.root&&e){let r=new Zj(t,n),i=new Xj(aM(e));return oM(this.root,e,new $j,r,i),r.schemas}return[]}};function aM(e,t=Ej.v2020_12){let n=e.$schema;return n?Jj(n)??t:t}function oM(e,t,n,r,i){if(!e||!r.include(e))return;if(e.type===`property`)return oM(e.valueNode,t,n,r,i);let a=e;switch(o(),a.type){case`object`:d(a);break;case`array`:u(a);break;case`string`:l(a);break;case`number`:c(a);break}r.add({node:a,schema:t});function o(){function e(e){return a.type===e||e===`integer`&&a.type===`number`&&a.isInteger}if(Array.isArray(t.type)?t.type.some(e)||n.problems.push({location:{offset:a.offset,length:a.length},message:t.errorMessage||K(`Incorrect type. Expected one of {0}.`,t.type.join(`, `))}):t.type&&(e(t.type)||n.problems.push({location:{offset:a.offset,length:a.length},message:t.errorMessage||K(`Incorrect type. Expected "{0}".`,t.type)})),Array.isArray(t.allOf))for(let e of t.allOf){let t=new $j,o=r.newSub();oM(a,Uj(e),t,o,i),n.merge(t),r.merge(o)}let o=Uj(t.not);if(o){let e=new $j,s=r.newSub();oM(a,o,e,s,i),e.hasProblems()||n.problems.push({location:{offset:a.offset,length:a.length},message:t.errorMessage||K(`Matches a schema that is not allowed.`)});for(let e of s.schemas)e.inverted=!e.inverted,r.add(e)}let c=(e,t)=>{let o=[],c=s(e)??e,l;for(let e of c){let n=Uj(e),s=new $j,c=r.newSub();if(oM(a,n,s,c,i),s.hasProblems()||o.push(n),!l)l={schema:n,validationResult:s,matchingSchemas:c};else if(!t&&!s.hasProblems()&&!l.validationResult.hasProblems())l.matchingSchemas.merge(c),l.validationResult.propertiesMatches+=s.propertiesMatches,l.validationResult.propertiesValueMatches+=s.propertiesValueMatches,l.validationResult.mergeProcessedProperties(s);else{let e=s.compare(l.validationResult);e>0?l={schema:n,validationResult:s,matchingSchemas:c}:e===0&&(l.matchingSchemas.merge(c),l.validationResult.mergeEnumValues(s))}}return o.length>1&&t&&n.problems.push({location:{offset:a.offset,length:1},message:K(`Matches multiple schemas when only one must validate.`)}),l&&(l.validationResult.updateEnumMismatchProblemMessages(),n.merge(l.validationResult),r.merge(l.matchingSchemas)),o.length};Array.isArray(t.anyOf)&&c(t.anyOf,!1),Array.isArray(t.oneOf)&&c(t.oneOf,!0);let l=e=>{let t=new $j,o=r.newSub();oM(a,Uj(e),t,o,i),n.merge(t),r.merge(o)},u=(e,t,o)=>{let s=Uj(e),c=new $j,u=r.newSub();oM(a,s,c,u,i),r.merge(u),n.mergeProcessedProperties(c),c.hasProblems()?o&&l(o):t&&l(t)},d=Uj(t.if);if(d&&u(d,Uj(t.then),Uj(t.else)),Array.isArray(t.enum)){let e=tM(a),r=!1;for(let n of t.enum)if(hj(e,n)){r=!0;break}n.enumValues=t.enum,n.enumValueMatch=r,r||n.problems.push({location:{offset:a.offset,length:a.length},code:Tj.EnumValueMismatch,message:t.errorMessage||K(`Value is not accepted. Valid values: {0}.`,t.enum.map(e=>JSON.stringify(e)).join(`, `))})}_j(t.const)&&(hj(tM(a),t.const)?n.enumValueMatch=!0:(n.problems.push({location:{offset:a.offset,length:a.length},code:Tj.EnumValueMismatch,message:t.errorMessage||K(`Value must be {0}.`,JSON.stringify(t.const))}),n.enumValueMatch=!1),n.enumValues=[t.const]);let f=t.deprecationMessage;if(f||t.deprecated){f||=K(`Value is deprecated`);let e=a.parent?.type===`property`?a.parent:a;n.problems.push({location:{offset:e.offset,length:e.length},severity:Xv.Warning,message:f,code:Tj.Deprecated})}}function s(e){if(e.length<2)return;let t=t=>{let n=new Map;for(let r=0;r<e.length;r++){let i=t(Uj(e[r]),r);if(!i)return;i.forEach(([e,t])=>{if(t.const!==void 0){n.has(e)||n.set(e,new Map);let i=n.get(e);i.has(t.const)||i.set(t.const,[]),i.get(t.const).push(r)}})}return n},n=(t,n)=>{for(let[r,i]of t){let t=new Set;if(i.forEach(e=>e.forEach(e=>t.add(e))),t.size===e.length){let t=n(r),a=i.get(t);if(a?.length)return a.map(t=>e[t]);break}}};if(a.type===`object`&&a.properties?.length){let e=t(e=>e.properties?Object.entries(e.properties).map(([e,t])=>[e,Uj(t)]):void 0);if(e)return n(e,e=>{let t=a.properties.find(t=>t.keyNode.value===e);return t?.valueNode?.type===`string`?t.valueNode.value:void 0})}else if(a.type===`array`&&a.items?.length){let e=t(e=>{let t=e.prefixItems||(Array.isArray(e.items)?e.items:void 0);return t?t.map((e,t)=>[t,Uj(e)]):void 0});if(e)return n(e,e=>{let t=a.items[e];return t?.type===`string`?t.value:void 0})}}function c(e){let r=e.value;function i(e){let t=/^(-?\d+)(?:\.(\d+))?(?:e([-+]\d+))?$/.exec(e.toString());return t&&{value:Number(t[1]+(t[2]||``)),multiplier:(t[2]?.length||0)-(parseInt(t[3])||0)}}if(gj(t.multipleOf)){let a=-1;if(Number.isInteger(t.multipleOf))a=r%t.multipleOf;else{let e=i(t.multipleOf),n=i(r);if(e&&n){let t=10**Math.abs(n.multiplier-e.multiplier);n.multiplier<e.multiplier?n.value*=t:e.value*=t,a=n.value%e.value}}a!==0&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Value is not divisible by {0}.`,t.multipleOf)})}function a(e,t){if(gj(t))return t;if(vj(t)&&t)return e}function o(e,t){if(!vj(t)||!t)return e}let s=a(t.minimum,t.exclusiveMinimum);gj(s)&&r<=s&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Value is below the exclusive minimum of {0}.`,s)});let c=a(t.maximum,t.exclusiveMaximum);gj(c)&&r>=c&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Value is above the exclusive maximum of {0}.`,c)});let l=o(t.minimum,t.exclusiveMinimum);gj(l)&&r<l&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Value is below the minimum of {0}.`,l)});let u=o(t.maximum,t.exclusiveMaximum);gj(u)&&r>u&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Value is above the maximum of {0}.`,u)})}function l(e){if(gj(t.minLength)&&wj(e.value)<t.minLength&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`String is shorter than the minimum length of {0}.`,t.minLength)}),gj(t.maxLength)&&wj(e.value)>t.maxLength&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`String is longer than the maximum length of {0}.`,t.maxLength)}),yj(t.pattern)){let r=Cj(t.pattern);r&&!r.test(e.value)&&n.problems.push({location:{offset:e.offset,length:e.length},message:t.patternErrorMessage||t.errorMessage||K(`String does not match the pattern of "{0}".`,t.pattern)})}if(t.format)switch(t.format){case`uri`:case`uri-reference`:{let r;if(!e.value)r=K(`URI expected.`);else{let n=/^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/.exec(e.value);n?!n[2]&&t.format===`uri`&&(r=K(`URI with a scheme is expected.`)):r=K(`URI is expected.`)}r&&n.problems.push({location:{offset:e.offset,length:e.length},message:t.patternErrorMessage||t.errorMessage||K(`String is not a URI: {0}`,r)})}break;case`color-hex`:case`date-time`:case`date`:case`time`:case`email`:case`hostname`:case`ipv4`:case`ipv6`:let r=Pj[t.format];(!e.value||!r.pattern.exec(e.value))&&n.problems.push({location:{offset:e.offset,length:e.length},message:t.patternErrorMessage||t.errorMessage||r.errorMessage});default:}}function u(e){let a,o;i.schemaDraft>=Ej.v2020_12?(a=t.prefixItems,o=Array.isArray(t.items)?void 0:t.items):(a=Array.isArray(t.items)?t.items:void 0,o=Array.isArray(t.items)?t.additionalItems:t.items);let s=0;if(a!==void 0){let t=Math.min(a.length,e.items.length);for(;s<t;s++){let t=a[s],o=Uj(t),c=new $j,l=e.items[s];l&&(oM(l,o,c,r,i),n.mergePropertyMatch(c)),n.processedProperties.add(String(s))}}if(o!==void 0&&s<e.items.length)if(typeof o==`boolean`)for(o===!1&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Array has too many items according to schema. Expected {0} or fewer.`,s)});s<e.items.length;s++)n.processedProperties.add(String(s)),n.propertiesValueMatches++;else for(;s<e.items.length;s++){let t=new $j;oM(e.items[s],o,t,r,i),n.mergePropertyMatch(t),n.processedProperties.add(String(s))}let c=Uj(t.contains);if(c){let r=0;for(let t=0;t<e.items.length;t++){let a=e.items[t],o=new $j;oM(a,c,o,Qj.instance,i),o.hasProblems()||(r++,i.schemaDraft>=Ej.v2020_12&&n.processedProperties.add(String(t)))}r===0&&!gj(t.minContains)&&n.problems.push({location:{offset:e.offset,length:e.length},message:t.errorMessage||K(`Array does not contain required item.`)}),gj(t.minContains)&&r<t.minContains&&n.problems.push({location:{offset:e.offset,length:e.length},message:t.errorMessage||K(`Array has too few items that match the contains contraint. Expected {0} or more.`,t.minContains)}),gj(t.maxContains)&&r>t.maxContains&&n.problems.push({location:{offset:e.offset,length:e.length},message:t.errorMessage||K(`Array has too many items that match the contains contraint. Expected {0} or less.`,t.maxContains)})}let l=t.unevaluatedItems;if(l!==void 0)for(let a=0;a<e.items.length;a++){if(!n.processedProperties.has(String(a)))if(l===!1)n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Item does not match any validation rule from the array.`)});else{let o=new $j;oM(e.items[a],t.unevaluatedItems,o,r,i),n.mergePropertyMatch(o)}n.processedProperties.add(String(a)),n.propertiesValueMatches++}if(gj(t.minItems)&&e.items.length<t.minItems&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Array has too few items. Expected {0} or more.`,t.minItems)}),gj(t.maxItems)&&e.items.length>t.maxItems&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Array has too many items. Expected {0} or fewer.`,t.maxItems)}),t.uniqueItems===!0){let t=tM(e);function r(){for(let e=0;e<t.length-1;e++){let n=t[e];for(let r=e+1;r<t.length;r++)if(hj(n,t[r]))return!0}return!1}r()&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Array has duplicate items.`)})}}function d(e){let a=Object.create(null),o=new Set;for(let t of e.properties){let e=t.keyNode.value;a[e]=t.valueNode,o.add(e)}if(Array.isArray(t.required)){for(let r of t.required)if(!a[r]){let t=e.parent&&e.parent.type===`property`&&e.parent.keyNode,i=t?{offset:t.offset,length:t.length}:{offset:e.offset,length:1};n.problems.push({location:i,message:K(`Missing property "{0}".`,r)})}}let s=e=>{o.delete(e),n.processedProperties.add(e)};if(t.properties)for(let e of Object.keys(t.properties)){s(e);let o=t.properties[e],c=a[e];if(c)if(vj(o))if(o)n.propertiesMatches++,n.propertiesValueMatches++;else{let r=c.parent;n.problems.push({location:{offset:r.keyNode.offset,length:r.keyNode.length},message:t.errorMessage||K(`Property {0} is not allowed.`,e)})}else{let e=new $j;oM(c,o,e,r,i),n.mergePropertyMatch(e)}}if(t.patternProperties)for(let e of Object.keys(t.patternProperties)){let c=Cj(e);if(c){let l=[];for(let s of o)if(c.test(s)){l.push(s);let o=a[s];if(o){let a=t.patternProperties[e];if(vj(a))if(a)n.propertiesMatches++,n.propertiesValueMatches++;else{let e=o.parent;n.problems.push({location:{offset:e.keyNode.offset,length:e.keyNode.length},message:t.errorMessage||K(`Property {0} is not allowed.`,s)})}else{let e=new $j;oM(o,a,e,r,i),n.mergePropertyMatch(e)}}}l.forEach(s)}}let c=t.additionalProperties;if(c!==void 0)for(let e of o){s(e);let o=a[e];if(o){if(c===!1){let r=o.parent;n.problems.push({location:{offset:r.keyNode.offset,length:r.keyNode.length},message:t.errorMessage||K(`Property {0} is not allowed.`,e)})}else if(c!==!0){let e=new $j;oM(o,c,e,r,i),n.mergePropertyMatch(e)}}}let l=t.unevaluatedProperties;if(l!==void 0){let e=[];for(let s of o)if(!n.processedProperties.has(s)){e.push(s);let o=a[s];if(o){if(l===!1){let e=o.parent;n.problems.push({location:{offset:e.keyNode.offset,length:e.keyNode.length},message:t.errorMessage||K(`Property {0} is not allowed.`,s)})}else if(l!==!0){let e=new $j;oM(o,l,e,r,i),n.mergePropertyMatch(e)}}}e.forEach(s)}if(gj(t.maxProperties)&&e.properties.length>t.maxProperties&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Object has more properties than limit of {0}.`,t.maxProperties)}),gj(t.minProperties)&&e.properties.length<t.minProperties&&n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Object has fewer properties than the required number of {0}`,t.minProperties)}),t.dependentRequired)for(let e in t.dependentRequired){let n=a[e],r=t.dependentRequired[e];n&&Array.isArray(r)&&d(e,r)}if(t.dependentSchemas)for(let e in t.dependentSchemas){let n=a[e],r=t.dependentSchemas[e];n&&bj(r)&&d(e,r)}if(t.dependencies)for(let e in t.dependencies)a[e]&&d(e,t.dependencies[e]);let u=Uj(t.propertyNames);if(u)for(let t of e.properties){let e=t.keyNode;e&&oM(e,u,n,r,i)}function d(t,o){if(Array.isArray(o))for(let r of o)a[r]?n.propertiesValueMatches++:n.problems.push({location:{offset:e.offset,length:e.length},message:K(`Object is missing property {0} required by property {1}.`,r,t)});else{let t=Uj(o);if(t){let a=new $j;oM(e,t,a,r,i),n.mergePropertyMatch(a)}}}}}function sM(e,t){let n=[],r=-1,i=e.getText(),a=oj(i,!1),o=t&&t.collectComments?[]:void 0;function s(){for(;;){let t=a.scan();switch(u(),t){case 12:case 13:Array.isArray(o)&&o.push(Vv.create(e.positionAt(a.getTokenOffset()),e.positionAt(a.getTokenOffset()+a.getTokenLength())));break;case 15:case 14:break;default:return t}}}function c(t,i,a,o,s=Xv.Error){if(n.length===0||a!==r){let c=Vv.create(e.positionAt(a),e.positionAt(o));n.push($v.create(c,t,s,i,e.languageId)),r=a}}function l(e,t,n=void 0,r=[],o=[]){let l=a.getTokenOffset(),u=a.getTokenOffset()+a.getTokenLength();if(l===u&&l>0){for(l--;l>0&&/\s/.test(i.charAt(l));)l--;u=l+1}if(c(e,t,l,u),n&&d(n,!1),r.length+o.length>0){let e=a.getToken();for(;e!==17;){if(r.indexOf(e)!==-1){s();break}else if(o.indexOf(e)!==-1)break;e=s()}}return n}function u(){switch(a.getTokenError()){case 4:return l(K(`Invalid unicode sequence in string.`),Tj.InvalidUnicode),!0;case 5:return l(K(`Invalid escape character in string.`),Tj.InvalidEscapeCharacter),!0;case 3:return l(K(`Unexpected end of number.`),Tj.UnexpectedEndOfNumber),!0;case 1:return l(K(`Unexpected end of comment.`),Tj.UnexpectedEndOfComment),!0;case 2:return l(K(`Unexpected end of string.`),Tj.UnexpectedEndOfString),!0;case 6:return l(K(`Invalid characters in string. Control characters must be escaped.`),Tj.InvalidCharacter),!0}return!1}function d(e,t){return e.length=a.getTokenOffset()+a.getTokenLength()-e.offset,t&&s(),e}function f(e){if(a.getToken()!==3)return;let t=new Rj(e,a.getTokenOffset());s();let n=!1;for(;a.getToken()!==4&&a.getToken()!==17;){if(a.getToken()===5){n||l(K(`Value expected`),Tj.ValueExpected);let e=a.getTokenOffset();if(s(),a.getToken()===4){n&&c(K(`Trailing comma`),Tj.TrailingComma,e,e+1);continue}}else n&&l(K(`Expected comma`),Tj.CommaExpected);let e=y(t);e?t.items.push(e):l(K(`Value expected`),Tj.ValueExpected,void 0,[],[4,5]),n=!0}return a.getToken()===4?d(t,!0):l(K(`Expected comma or closing bracket`),Tj.CommaOrCloseBacketExpected,t)}let p=new Bj(void 0,0,0);function m(t,n){let r=new Vj(t,a.getTokenOffset(),p),i=g(r);if(!i)if(a.getToken()===16){l(K(`Property keys must be doublequoted`),Tj.PropertyKeysMustBeDoublequoted);let e=new Bj(r,a.getTokenOffset(),a.getTokenLength());e.value=a.getTokenValue(),i=e,s()}else return;if(r.keyNode=i,i.value!==`//`){let e=n[i.value];e?(c(K(`Duplicate object key`),Tj.DuplicateKey,r.keyNode.offset,r.keyNode.offset+r.keyNode.length,Xv.Warning),bj(e)&&c(K(`Duplicate object key`),Tj.DuplicateKey,e.keyNode.offset,e.keyNode.offset+e.keyNode.length,Xv.Warning),n[i.value]=!0):n[i.value]=r}if(a.getToken()===6)r.colonOffset=a.getTokenOffset(),s();else if(l(K(`Colon expected`),Tj.ColonExpected),a.getToken()===10&&e.positionAt(i.offset+i.length).line<e.positionAt(a.getTokenOffset()).line)return r.length=i.length,r;let o=y(r);return o?(r.valueNode=o,r.length=o.offset+o.length-r.offset,r):l(K(`Value expected`),Tj.ValueExpected,r,[],[2,5])}function h(e){if(a.getToken()!==1)return;let t=new Hj(e,a.getTokenOffset()),n=Object.create(null);s();let r=!1;for(;a.getToken()!==2&&a.getToken()!==17;){if(a.getToken()===5){r||l(K(`Property expected`),Tj.PropertyExpected);let e=a.getTokenOffset();if(s(),a.getToken()===2){r&&c(K(`Trailing comma`),Tj.TrailingComma,e,e+1);continue}}else r&&l(K(`Expected comma`),Tj.CommaExpected);let e=m(t,n);e?t.properties.push(e):l(K(`Property expected`),Tj.PropertyExpected,void 0,[],[2,5]),r=!0}return a.getToken()===2?d(t,!0):l(K(`Expected comma or closing brace`),Tj.CommaOrCloseBraceExpected,t)}function g(e){if(a.getToken()!==10)return;let t=new Bj(e,a.getTokenOffset());return t.value=a.getTokenValue(),d(t,!0)}function _(e){if(a.getToken()!==11)return;let t=new zj(e,a.getTokenOffset());if(a.getTokenError()===0){let e=a.getTokenValue();try{let n=JSON.parse(e);if(!gj(n))return l(K(`Invalid number format.`),Tj.Undefined,t);t.value=n}catch{return l(K(`Invalid number format.`),Tj.Undefined,t)}t.isInteger=e.indexOf(`.`)===-1}return d(t,!0)}function v(e){switch(a.getToken()){case 7:return d(new Ij(e,a.getTokenOffset()),!0);case 8:return d(new Lj(e,!0,a.getTokenOffset()),!0);case 9:return d(new Lj(e,!1,a.getTokenOffset()),!0);default:return}}function y(e){return f(e)||h(e)||g(e)||_(e)||v(e)}let b;return s()!==17&&(b=y(b),b?a.getToken()!==17&&l(K(`End of file expected.`),Tj.Undefined):l(K(`Expected a JSON object, array or literal.`),Tj.Undefined)),new iM(b,n,o)}function cM(e,t,n){if(typeof e==`object`&&e){let r=t+` `;if(Array.isArray(e)){if(e.length===0)return`[]`;let i=`[
|
|
65
|
+
`;for(let t=0;t<e.length;t++)i+=r+cM(e[t],r,n),t<e.length-1&&(i+=`,`),i+=`
|
|
66
|
+
`;return i+=t+`]`,i}else{let i=Object.keys(e);if(i.length===0)return`{}`;let a=`{
|
|
67
|
+
`;for(let t=0;t<i.length;t++){let o=i[t];a+=r+JSON.stringify(o)+`: `+cM(e[o],r,n),t<i.length-1&&(a+=`,`),a+=`
|
|
68
|
+
`}return a+=t+`}`,a}}return n(e)}var lM=class{constructor(e,t=[],n=Promise,r={}){this.schemaService=e,this.contributions=t,this.promiseConstructor=n,this.clientCapabilities=r}doResolve(e){for(let t=this.contributions.length-1;t>=0;t--){let n=this.contributions[t].resolveCompletion;if(n){let t=n(e);if(t)return t}}return this.promiseConstructor.resolve(e)}doComplete(e,t,n){let r={items:[],isIncomplete:!1},i=e.getText(),a=e.offsetAt(t),o=n.getNodeFromOffset(a,!0);if(this.isInComment(e,o?o.offset:0,a))return Promise.resolve(r);if(o&&a===o.offset+o.length&&a>0){let e=i[a-1];(o.type===`object`&&e===`}`||o.type===`array`&&e===`]`)&&(o=o.parent)}let s=this.getCurrentWord(e,a),c;if(o&&(o.type===`string`||o.type===`number`||o.type===`boolean`||o.type===`null`))c=Vv.create(e.positionAt(o.offset),e.positionAt(o.offset+o.length));else{let n=a-s.length;n>0&&i[n-1]===`"`&&n--,c=Vv.create(e.positionAt(n),t)}let l=new Map,u={add:e=>{let t=e.label,n=l.get(t);if(n)n.documentation||=e.documentation,n.detail||=e.detail,n.labelDetails||=e.labelDetails;else{if(t=t.replace(/[\n]/g,`↵`),t.length>60){let e=t.substr(0,57).trim()+`...`;l.has(e)||(t=e)}e.textEdit=ty.replace(c,e.insertText),e.label=t,l.set(t,e),r.items.push(e)}},setAsIncomplete:()=>{r.isIncomplete=!0},error:e=>{console.error(e)},getNumberOfProposals:()=>r.items.length};return this.schemaService.getSchemaForResource(e.uri,n).then(t=>{let d=[],f=!0,p=``,m;if(o&&o.type===`string`){let e=o.parent;e&&e.type===`property`&&e.keyNode===o&&(f=!e.valueNode,m=e,p=i.substr(o.offset+1,o.length-2),e&&(o=e.parent))}if(o&&o.type===`object`){if(o.offset===a)return r;o.properties.forEach(e=>{(!m||m!==e)&&l.set(e.keyNode.value,Sy.create(`__`))});let h=``;f&&(h=this.evaluateSeparatorAfter(e,e.offsetAt(c.end))),t?this.getPropertyCompletions(t,n,o,f,h,u):this.getSchemaLessPropertyCompletions(n,o,p,u);let g=nM(o);this.contributions.forEach(t=>{let n=t.collectPropertyCompletions(e.uri,g,s,f,h===``,u);n&&d.push(n)}),!t&&s.length>0&&i.charAt(a-s.length-1)!==`"`&&(u.add({kind:gy.Property,label:this.getLabelForValue(s),insertText:this.getInsertTextForProperty(s,void 0,!1,h),insertTextFormat:_y.Snippet,documentation:``}),u.setAsIncomplete())}let h={};return t?this.getValueCompletions(t,n,o,a,e,u,h):this.getSchemaLessValueCompletions(n,o,a,e,u),this.contributions.length>0&&this.getContributedValueCompletions(n,o,a,e,u,d),this.promiseConstructor.all(d).then(()=>{if(u.getNumberOfProposals()===0){let t=a;o&&(o.type===`string`||o.type===`number`||o.type===`boolean`||o.type===`null`)&&(t=o.offset+o.length);let n=this.evaluateSeparatorAfter(e,t);this.addFillerValueCompletions(h,n,u)}return r})})}getPropertyCompletions(e,t,n,r,i,a){t.getMatchingSchemas(e.schema,n.offset).forEach(e=>{if(e.node===n&&!e.inverted){let t=e.schema.properties;t&&Object.keys(t).forEach(e=>{let n=t[e];if(typeof n==`object`&&!n.deprecationMessage&&!n.doNotSuggest){let t={kind:gy.Property,label:e,insertText:this.getInsertTextForProperty(e,n,r,i),insertTextFormat:_y.Snippet,filterText:this.getFilterTextForValue(e),documentation:this.fromMarkup(n.markdownDescription)||n.description||``};n.completionDetail!==void 0&&(t.detail=n.completionDetail),n.suggestSortText!==void 0&&(t.sortText=n.suggestSortText),t.insertText&&Sj(t.insertText,`$1${i}`)&&(t.command={title:`Suggest`,command:`editor.action.triggerSuggest`}),a.add(t)}});let n=e.schema.propertyNames;if(typeof n==`object`&&!n.deprecationMessage&&!n.doNotSuggest){let e=(e,t,o,s)=>{let c={kind:gy.Property,label:e,insertText:this.getInsertTextForProperty(e,void 0,r,i),insertTextFormat:_y.Snippet,filterText:this.getFilterTextForValue(e),documentation:t||this.fromMarkup(n.markdownDescription)||n.description||``,sortText:s,detail:o};c.insertText&&Sj(c.insertText,`$1${i}`)&&(c.command={title:`Suggest`,command:`editor.action.triggerSuggest`}),a.add(c)};if(n.enum)for(let t=0;t<n.enum.length;t++){let r;n.markdownEnumDescriptions&&t<n.markdownEnumDescriptions.length?r=this.fromMarkup(n.markdownEnumDescriptions[t]):n.enumDescriptions&&t<n.enumDescriptions.length&&(r=n.enumDescriptions[t]);let i=n.enumSortTexts?.[t],a=n.enumDetails?.[t];e(n.enum[t],r,a,i)}if(n.examples)for(let t=0;t<n.examples.length;t++)e(n.examples[t],void 0,void 0,void 0);n.const&&e(n.const,void 0,n.completionDetail,n.suggestSortText)}}})}getSchemaLessPropertyCompletions(e,t,n,r){let i=e=>{e.properties.forEach(e=>{let t=e.keyNode.value;r.add({kind:gy.Property,label:t,insertText:this.getInsertTextForValue(t,``),insertTextFormat:_y.Snippet,filterText:this.getFilterTextForValue(t),documentation:``})})};if(t.parent)if(t.parent.type===`property`){let n=t.parent.keyNode.value;e.visit(e=>(e.type===`property`&&e!==t.parent&&e.keyNode.value===n&&e.valueNode&&e.valueNode.type===`object`&&i(e.valueNode),!0))}else t.parent.type===`array`&&t.parent.items.forEach(e=>{e.type===`object`&&e!==t&&i(e)});else t.type===`object`&&r.add({kind:gy.Property,label:`$schema`,insertText:this.getInsertTextForProperty(`$schema`,void 0,!0,``),insertTextFormat:_y.Snippet,documentation:``,filterText:this.getFilterTextForValue(`$schema`)})}getSchemaLessValueCompletions(e,t,n,r,i){let a=n;if(t&&(t.type===`string`||t.type===`number`||t.type===`boolean`||t.type===`null`)&&(a=t.offset+t.length,t=t.parent),!t){i.add({kind:this.getSuggestionKind(`object`),label:`Empty object`,insertText:this.getInsertTextForValue({},``),insertTextFormat:_y.Snippet,documentation:``}),i.add({kind:this.getSuggestionKind(`array`),label:`Empty array`,insertText:this.getInsertTextForValue([],``),insertTextFormat:_y.Snippet,documentation:``});return}let o=this.evaluateSeparatorAfter(r,a),s=e=>{e.parent&&!rM(e.parent,n,!0)&&i.add({kind:this.getSuggestionKind(e.type),label:this.getLabelTextForMatchingNode(e,r),insertText:this.getInsertTextForMatchingNode(e,r,o),insertTextFormat:_y.Snippet,documentation:``}),e.type===`boolean`&&this.addBooleanValueCompletion(!e.value,o,i)};if(t.type===`property`&&n>(t.colonOffset||0)){let r=t.valueNode;if(r&&(n>r.offset+r.length||r.type===`object`||r.type===`array`))return;let a=t.keyNode.value;e.visit(e=>(e.type===`property`&&e.keyNode.value===a&&e.valueNode&&s(e.valueNode),!0)),a===`$schema`&&t.parent&&!t.parent.parent&&this.addDollarSchemaCompletions(o,i)}if(t.type===`array`)if(t.parent&&t.parent.type===`property`){let n=t.parent.keyNode.value;e.visit(e=>(e.type===`property`&&e.keyNode.value===n&&e.valueNode&&e.valueNode.type===`array`&&e.valueNode.items.forEach(s),!0))}else t.items.forEach(s)}getValueCompletions(e,t,n,r,i,a,o){let s=r,c,l;if(n&&(n.type===`string`||n.type===`number`||n.type===`boolean`||n.type===`null`)&&(s=n.offset+n.length,l=n,n=n.parent),!n){this.addSchemaValueCompletions(e.schema,``,a,o);return}if(n.type===`property`&&r>(n.colonOffset||0)){let e=n.valueNode;if(e&&r>e.offset+e.length)return;c=n.keyNode.value,n=n.parent}if(n&&(c!==void 0||n.type===`array`)){let u=this.evaluateSeparatorAfter(i,s),d=t.getMatchingSchemas(e.schema,n.offset,l);for(let e of d)if(e.node===n&&!e.inverted&&e.schema){if(n.type===`array`&&e.schema.items){let t=a;if(e.schema.uniqueItems){let e=new Set;n.children.forEach(t=>{t.type!==`array`&&t.type!==`object`&&e.add(this.getLabelForValue(tM(t)))}),t={...a,add(t){e.has(t.label)||a.add(t)}}}if(Array.isArray(e.schema.items)){let a=this.findItemAtOffset(n,i,r);a<e.schema.items.length&&this.addSchemaValueCompletions(e.schema.items[a],u,t,o)}else this.addSchemaValueCompletions(e.schema.items,u,t,o)}if(c!==void 0){let t=!1;if(e.schema.properties){let n=e.schema.properties[c];n&&(t=!0,this.addSchemaValueCompletions(n,u,a,o))}if(e.schema.patternProperties&&!t){for(let n of Object.keys(e.schema.patternProperties))if(Cj(n)?.test(c)){t=!0;let r=e.schema.patternProperties[n];this.addSchemaValueCompletions(r,u,a,o)}}if(e.schema.additionalProperties&&!t){let t=e.schema.additionalProperties;this.addSchemaValueCompletions(t,u,a,o)}}}c===`$schema`&&!n.parent&&this.addDollarSchemaCompletions(u,a),o.boolean&&(this.addBooleanValueCompletion(!0,u,a),this.addBooleanValueCompletion(!1,u,a)),o.null&&this.addNullValueCompletion(u,a)}}getContributedValueCompletions(e,t,n,r,i,a){if(!t)this.contributions.forEach(e=>{let t=e.collectDefaultCompletions(r.uri,i);t&&a.push(t)});else if((t.type===`string`||t.type===`number`||t.type===`boolean`||t.type===`null`)&&(t=t.parent),t&&t.type===`property`&&n>(t.colonOffset||0)){let e=t.keyNode.value,o=t.valueNode;if((!o||n<=o.offset+o.length)&&t.parent){let n=nM(t.parent);this.contributions.forEach(t=>{let o=t.collectValueCompletions(r.uri,n,e,i);o&&a.push(o)})}}}addSchemaValueCompletions(e,t,n,r){typeof e==`object`&&(this.addEnumValueCompletions(e,t,n),this.addDefaultValueCompletions(e,t,n),this.collectTypes(e,r),Array.isArray(e.allOf)&&e.allOf.forEach(e=>this.addSchemaValueCompletions(e,t,n,r)),Array.isArray(e.anyOf)&&e.anyOf.forEach(e=>this.addSchemaValueCompletions(e,t,n,r)),Array.isArray(e.oneOf)&&e.oneOf.forEach(e=>this.addSchemaValueCompletions(e,t,n,r)))}addDefaultValueCompletions(e,t,n,r=0){let i=!1;if(_j(e.default)){let a=e.type,o=e.default;for(let e=r;e>0;e--)o=[o],a=`array`;let s={kind:this.getSuggestionKind(a),label:this.getLabelForValue(o),insertText:this.getInsertTextForValue(o,t),insertTextFormat:_y.Snippet};this.doesSupportsLabelDetails()?s.labelDetails={description:K(`Default value`)}:s.detail=K(`Default value`),n.add(s),i=!0}Array.isArray(e.examples)&&e.examples.forEach(a=>{let o=e.type,s=a;for(let e=r;e>0;e--)s=[s],o=`array`;n.add({kind:this.getSuggestionKind(o),label:this.getLabelForValue(s),insertText:this.getInsertTextForValue(s,t),insertTextFormat:_y.Snippet}),i=!0}),Array.isArray(e.defaultSnippets)&&e.defaultSnippets.forEach(a=>{let o=e.type,s=a.body,c=a.label,l,u;if(_j(s)){e.type;for(let e=r;e>0;e--)s=[s];l=this.getInsertTextForSnippetValue(s,t),u=this.getFilterTextForSnippetValue(s),c||=this.getLabelForSnippetValue(s)}else if(typeof a.bodyText==`string`){let e=``,n=``,i=``;for(let t=r;t>0;t--)e=e+i+`[
|
|
69
|
+
`,n=n+`
|
|
70
|
+
`+i+`]`,i+=` `,o=`array`;l=e+i+a.bodyText.split(`
|
|
71
|
+
`).join(`
|
|
72
|
+
`+i)+n+t,c||=l,u=l.replace(/[\n]/g,``)}else return;n.add({kind:this.getSuggestionKind(o),label:c,documentation:this.fromMarkup(a.markdownDescription)||a.description,insertText:l,insertTextFormat:_y.Snippet,filterText:u}),i=!0}),!i&&typeof e.items==`object`&&!Array.isArray(e.items)&&r<5&&this.addDefaultValueCompletions(e.items,t,n,r+1)}addEnumValueCompletions(e,t,n){if(_j(e.const)&&n.add({kind:this.getSuggestionKind(e.type),label:this.getLabelForValue(e.const),insertText:this.getInsertTextForValue(e.const,t),insertTextFormat:_y.Snippet,documentation:this.fromMarkup(e.markdownDescription)||e.description}),Array.isArray(e.enum))for(let r=0,i=e.enum.length;r<i;r++){let i=e.enum[r],a=this.fromMarkup(e.markdownDescription)||e.description;e.markdownEnumDescriptions&&r<e.markdownEnumDescriptions.length&&this.doesSupportMarkdown()?a=this.fromMarkup(e.markdownEnumDescriptions[r]):e.enumDescriptions&&r<e.enumDescriptions.length&&(a=e.enumDescriptions[r]),n.add({kind:this.getSuggestionKind(e.type),label:this.getLabelForValue(i),insertText:this.getInsertTextForValue(i,t),insertTextFormat:_y.Snippet,sortText:e.enumSortTexts?.[r],detail:e.enumDetails?.[r],documentation:a})}}collectTypes(e,t){if(Array.isArray(e.enum)||_j(e.const))return;let n=e.type;Array.isArray(n)?n.forEach(e=>t[e]=!0):n&&(t[n]=!0)}addFillerValueCompletions(e,t,n){e.object&&n.add({kind:this.getSuggestionKind(`object`),label:`{}`,insertText:this.getInsertTextForGuessedValue({},t),insertTextFormat:_y.Snippet,detail:K(`New object`),documentation:``}),e.array&&n.add({kind:this.getSuggestionKind(`array`),label:`[]`,insertText:this.getInsertTextForGuessedValue([],t),insertTextFormat:_y.Snippet,detail:K(`New array`),documentation:``})}addBooleanValueCompletion(e,t,n){n.add({kind:this.getSuggestionKind(`boolean`),label:e?`true`:`false`,insertText:this.getInsertTextForValue(e,t),insertTextFormat:_y.Snippet,documentation:``})}addNullValueCompletion(e,t){t.add({kind:this.getSuggestionKind(`null`),label:`null`,insertText:`null`+e,insertTextFormat:_y.Snippet,documentation:``})}addDollarSchemaCompletions(e,t){this.schemaService.getRegisteredSchemaIds(e=>e===`http`||e===`https`).forEach(n=>{n.startsWith(`https://json-schema.org/draft-`)&&(n+=`#`),t.add({kind:gy.Module,label:this.getLabelForValue(n),filterText:this.getFilterTextForValue(n),insertText:this.getInsertTextForValue(n,e),insertTextFormat:_y.Snippet,documentation:``})})}getLabelForValue(e){return JSON.stringify(e)}getValueFromLabel(e){return JSON.parse(e)}getFilterTextForValue(e){return JSON.stringify(e)}getFilterTextForSnippetValue(e){return JSON.stringify(e).replace(/\$\{\d+:([^}]+)\}|\$\d+/g,`$1`)}getLabelForSnippetValue(e){return JSON.stringify(e).replace(/\$\{\d+:([^}]+)\}|\$\d+/g,`$1`)}getInsertTextForPlainText(e){return e.replace(/[\\\$\}]/g,`\\$&`)}getInsertTextForValue(e,t){let n=JSON.stringify(e,null,` `);return n===`{}`?`{$1}`+t:n===`[]`?`[$1]`+t:this.getInsertTextForPlainText(n+t)}getInsertTextForSnippetValue(e,t){return cM(e,``,e=>typeof e==`string`&&e[0]===`^`?e.substr(1):JSON.stringify(e))+t}getInsertTextForGuessedValue(e,t){switch(typeof e){case`object`:return e===null?"${1:null}"+t:this.getInsertTextForValue(e,t);case`string`:let n=JSON.stringify(e);return n=n.substr(1,n.length-2),n=this.getInsertTextForPlainText(n),'"${1:'+n+`}"`+t;case`number`:case`boolean`:return"${1:"+JSON.stringify(e)+`}`+t}return this.getInsertTextForValue(e,t)}getSuggestionKind(e){if(Array.isArray(e)){let t=e;e=t.length>0?t[0]:void 0}if(!e)return gy.Value;switch(e){case`string`:return gy.Value;case`object`:return gy.Module;case`property`:return gy.Property;default:return gy.Value}}getLabelTextForMatchingNode(e,t){switch(e.type){case`array`:return`[]`;case`object`:return`{}`;default:return t.getText().substr(e.offset,e.length)}}getInsertTextForMatchingNode(e,t,n){switch(e.type){case`array`:return this.getInsertTextForValue([],n);case`object`:return this.getInsertTextForValue({},n);default:let r=t.getText().substr(e.offset,e.length)+n;return this.getInsertTextForPlainText(r)}}getInsertTextForProperty(e,t,n,r){let i=this.getInsertTextForValue(e,``);if(!n)return i;let a=i+`: `,o,s=0;if(t){if(Array.isArray(t.defaultSnippets)){if(t.defaultSnippets.length===1){let e=t.defaultSnippets[0].body;_j(e)&&(o=this.getInsertTextForSnippetValue(e,``))}s+=t.defaultSnippets.length}if(t.enum&&(!o&&t.enum.length===1&&(o=this.getInsertTextForGuessedValue(t.enum[0],``)),s+=t.enum.length),_j(t.const)&&(o||=this.getInsertTextForGuessedValue(t.const,``),s++),_j(t.default)&&(o||=this.getInsertTextForGuessedValue(t.default,``),s++),Array.isArray(t.examples)&&t.examples.length&&(o||=this.getInsertTextForGuessedValue(t.examples[0],``),s+=t.examples.length),s===0){let e=Array.isArray(t.type)?t.type[0]:t.type;switch(e||(t.properties?e=`object`:t.items&&(e=`array`)),e){case`boolean`:o=`$1`;break;case`string`:o=`"$1"`;break;case`object`:o=`{$1}`;break;case`array`:o=`[$1]`;break;case`number`:case`integer`:o="${1:0}";break;case`null`:o="${1:null}";break;default:return i}}}return(!o||s>1)&&(o=`$1`),a+o+r}getCurrentWord(e,t){let n=t-1,r=e.getText();for(;n>=0&&`
|
|
73
|
+
\r\v":{[,]}`.indexOf(r.charAt(n))===-1;)n--;return r.substring(n+1,t)}evaluateSeparatorAfter(e,t){let n=oj(e.getText(),!0);switch(n.setPosition(t),n.scan()){case 5:case 2:case 4:case 17:return``;default:return`,`}}findItemAtOffset(e,t,n){let r=oj(t.getText(),!0),i=e.items;for(let e=i.length-1;e>=0;e--){let t=i[e];if(n>t.offset+t.length)return r.setPosition(t.offset+t.length),r.scan()===5&&n>=r.getTokenOffset()+r.getTokenLength()?e+1:e;if(n>=t.offset)return e}return 0}isInComment(e,t,n){let r=oj(e.getText(),!1);r.setPosition(t);let i=r.scan();for(;i!==17&&r.getTokenOffset()+r.getTokenLength()<n;)i=r.scan();return(i===12||i===13)&&r.getTokenOffset()<=n}fromMarkup(e){if(e&&this.doesSupportMarkdown())return{kind:my.Markdown,value:e}}doesSupportMarkdown(){if(!_j(this.supportsMarkdown)){let e=this.clientCapabilities.textDocument?.completion?.completionItem?.documentationFormat;this.supportsMarkdown=Array.isArray(e)&&e.indexOf(my.Markdown)!==-1}return this.supportsMarkdown}doesSupportsCommitCharacters(){return _j(this.supportsCommitCharacters)||(this.labelDetailsSupport=this.clientCapabilities.textDocument?.completion?.completionItem?.commitCharactersSupport),this.supportsCommitCharacters}doesSupportsLabelDetails(){return _j(this.labelDetailsSupport)||(this.labelDetailsSupport=this.clientCapabilities.textDocument?.completion?.completionItem?.labelDetailsSupport),this.labelDetailsSupport}},uM=class{constructor(e,t=[],n){this.schemaService=e,this.contributions=t,this.promise=n||Promise}doHover(e,t,n){let r=e.offsetAt(t),i=n.getNodeFromOffset(r);if(!i||(i.type===`object`||i.type===`array`)&&r>i.offset+1&&r<i.offset+i.length-1)return this.promise.resolve(null);let a=i;if(i.type===`string`){let e=i.parent;if(e&&e.type===`property`&&e.keyNode===i&&(i=e.valueNode,!i))return this.promise.resolve(null)}let o=Vv.create(e.positionAt(a.offset),e.positionAt(a.offset+a.length)),s=e=>({contents:e,range:o}),c=nM(i);for(let t=this.contributions.length-1;t>=0;t--){let n=this.contributions[t].getInfoContribution(e.uri,c);if(n)return n.then(e=>s(e))}return this.schemaService.getSchemaForResource(e.uri,n).then(e=>{if(!e)return null;let t,r,a,o,c=n.getMatchingSchemas(e.schema,i.offset).filter(e=>e.node===i&&!e.inverted).map(e=>e.schema);for(let e of c)if(t||=e.title,r=r||e.markdownDescription||dM(e.description),e.enum){let t=e.enum.indexOf(tM(i));e.markdownEnumDescriptions?a=e.markdownEnumDescriptions[t]:e.enumDescriptions&&(a=dM(e.enumDescriptions[t])),a&&(o=e.enum[t],typeof o!=`string`&&(o=JSON.stringify(o)))}let l=``;return t&&(l=dM(t)),r&&(l.length>0&&(l+=`
|
|
74
|
+
|
|
75
|
+
`),l+=r),a&&(l.length>0&&(l+=`
|
|
76
|
+
|
|
77
|
+
`),l+=`\`${fM(o)}\`: ${a}`),s([l])})}};function dM(e){if(e)return e.trim().replace(/[\\`*_{}[\]()<>#+\-.!]/g,`\\$&`).replace(/(^ +)/gm,(e,t)=>` `.repeat(t.length)).replace(/( {2,})/g,(e,t)=>` `+` `.repeat(t.length-1)).replace(/(\t+)/g,(e,t)=>` `.repeat(t.length*4)).replace(/\n/g,`\\
|
|
78
|
+
`)}function fM(e){return e.indexOf("`")===-1?e:"`` "+e+" ``"}var pM=class{constructor(e,t){this.jsonSchemaService=e,this.promise=t,this.validationEnabled=!0}configure(e){e&&(this.validationEnabled=e.validate!==!1,this.commentSeverity=e.allowComments?void 0:Xv.Error)}doValidation(e,t,n,r){if(!this.validationEnabled)return this.promise.resolve([]);let i=[],a={},o=e=>{let t=e.range.start.line+` `+e.range.start.character+` `+e.message;a[t]||(a[t]=!0,i.push(e))},s=r=>{let a=n?.trailingCommas?_M(n.trailingCommas):Xv.Error,s=n?.comments?_M(n.comments):this.commentSeverity,c=n?.schemaValidation?_M(n.schemaValidation):Xv.Warning,l=n?.schemaRequest?_M(n.schemaRequest):Xv.Warning;if(r){let i=(n,r,i)=>{if(t.root&&l){let a=t.root,s=a.type===`object`?a.properties[0]:void 0;if(s&&s.keyNode.value===`$schema`){let t=s.valueNode||s,a=Vv.create(e.positionAt(t.offset),e.positionAt(t.offset+t.length));o($v.create(a,n,l,r,`json`,i))}else{let t=Vv.create(e.positionAt(a.offset),e.positionAt(a.offset+1));o($v.create(t,n,l,r,`json`,i))}}};if(r.errors.length){let e=r.errors[0];i(e.message,e.code,e.relatedInformation)}else if(c){for(let e of r.warnings)i(e.message,e.code,e.relatedInformation);let a=t.validate(e,r.schema,c,n?.schemaDraft);a&&a.forEach(o)}hM(r.schema)&&(s=void 0),gM(r.schema)&&(a=void 0)}for(let e of t.syntaxErrors){if(e.code===Tj.TrailingComma){if(typeof a!=`number`)continue;e.severity=a}o(e)}if(typeof s==`number`){let e=K(`Comments are not permitted in JSON.`);t.comments.forEach(t=>{o($v.create(t,e,s,Tj.CommentNotPermitted))})}return i};if(r){let e=r.id||`schemaservice://untitled/`+ mM++;return this.jsonSchemaService.registerExternalSchema({uri:e,schema:r}).getResolvedSchema().then(e=>s(e))}return this.jsonSchemaService.getSchemaForResource(e.uri,t).then(e=>s(e))}getLanguageStatus(e,t){return{schemas:this.jsonSchemaService.getSchemaURIsForResource(e.uri,t)}}},mM=0;function hM(e){if(e&&typeof e==`object`){if(vj(e.allowComments))return e.allowComments;if(e.allOf)for(let t of e.allOf){let e=hM(t);if(vj(e))return e}}}function gM(e){if(e&&typeof e==`object`){if(vj(e.allowTrailingCommas))return e.allowTrailingCommas;let t=e;if(vj(t.allowsTrailingCommas))return t.allowsTrailingCommas;if(e.allOf)for(let t of e.allOf){let e=gM(t);if(vj(e))return e}}}function _M(e){switch(e){case`error`:return Xv.Error;case`warning`:return Xv.Warning;case`ignore`:return}}var vM=48,yM=57,bM=65,xM=97,SM=102;function CM(e){return e<vM?0:e<=yM?e-vM:(e<xM&&(e+=xM-bM),e>=xM&&e<=SM?e-xM+10:0)}function wM(e){if(e[0]===`#`)switch(e.length){case 4:return{red:CM(e.charCodeAt(1))*17/255,green:CM(e.charCodeAt(2))*17/255,blue:CM(e.charCodeAt(3))*17/255,alpha:1};case 5:return{red:CM(e.charCodeAt(1))*17/255,green:CM(e.charCodeAt(2))*17/255,blue:CM(e.charCodeAt(3))*17/255,alpha:CM(e.charCodeAt(4))*17/255};case 7:return{red:(CM(e.charCodeAt(1))*16+CM(e.charCodeAt(2)))/255,green:(CM(e.charCodeAt(3))*16+CM(e.charCodeAt(4)))/255,blue:(CM(e.charCodeAt(5))*16+CM(e.charCodeAt(6)))/255,alpha:1};case 9:return{red:(CM(e.charCodeAt(1))*16+CM(e.charCodeAt(2)))/255,green:(CM(e.charCodeAt(3))*16+CM(e.charCodeAt(4)))/255,blue:(CM(e.charCodeAt(5))*16+CM(e.charCodeAt(6)))/255,alpha:(CM(e.charCodeAt(7))*16+CM(e.charCodeAt(8)))/255}}}var TM=class{constructor(e){this.schemaService=e}findDocumentSymbols(e,t,n={resultLimit:Number.MAX_VALUE}){let r=t.root;if(!r)return[];let i=n.resultLimit||Number.MAX_VALUE,a=e.uri;if((a===`vscode://defaultsettings/keybindings.json`||Sj(a.toLowerCase(),`/user/keybindings.json`))&&r.type===`array`){let t=[];for(let o of r.items)if(o.type===`object`){for(let r of o.properties)if(r.keyNode.value===`key`&&r.valueNode){let s=Hv.create(e.uri,EM(e,o));if(t.push({name:DM(r.valueNode),kind:Ay.Function,location:s}),i--,i<=0)return n&&n.onResultLimitExceeded&&n.onResultLimitExceeded(a),t}}return t}let o=[{node:r,containerName:``}],s=0,c=!1,l=[],u=(t,n)=>{t.type===`array`?t.items.forEach(e=>{e&&o.push({node:e,containerName:n})}):t.type===`object`&&t.properties.forEach(t=>{let r=t.valueNode;if(r)if(i>0){i--;let a=Hv.create(e.uri,EM(e,t)),s=n?n+`.`+t.keyNode.value:t.keyNode.value;l.push({name:this.getKeyLabel(t),kind:this.getSymbolKind(r.type),location:a,containerName:n}),o.push({node:r,containerName:s})}else c=!0})};for(;s<o.length;){let e=o[s++];u(e.node,e.containerName)}return c&&n&&n.onResultLimitExceeded&&n.onResultLimitExceeded(a),l}findDocumentSymbols2(e,t,n={resultLimit:Number.MAX_VALUE}){let r=t.root;if(!r)return[];let i=n.resultLimit||Number.MAX_VALUE,a=e.uri;if((a===`vscode://defaultsettings/keybindings.json`||Sj(a.toLowerCase(),`/user/keybindings.json`))&&r.type===`array`){let t=[];for(let o of r.items)if(o.type===`object`){for(let r of o.properties)if(r.keyNode.value===`key`&&r.valueNode){let s=EM(e,o),c=EM(e,r.keyNode);if(t.push({name:DM(r.valueNode),kind:Ay.Function,range:s,selectionRange:c}),i--,i<=0)return n&&n.onResultLimitExceeded&&n.onResultLimitExceeded(a),t}}return t}let o=[],s=[{node:r,result:o}],c=0,l=!1,u=(t,n)=>{t.type===`array`?t.items.forEach((t,r)=>{if(t)if(i>0){i--;let a=EM(e,t),o=a,c={name:String(r),kind:this.getSymbolKind(t.type),range:a,selectionRange:o,children:[]};n.push(c),s.push({result:c.children,node:t})}else l=!0}):t.type===`object`&&t.properties.forEach(t=>{let r=t.valueNode;if(r)if(i>0){i--;let a=EM(e,t),o=EM(e,t.keyNode),c=[],l={name:this.getKeyLabel(t),kind:this.getSymbolKind(r.type),range:a,selectionRange:o,children:c,detail:this.getDetail(r)};n.push(l),s.push({result:c,node:r})}else l=!0})};for(;c<s.length;){let e=s[c++];u(e.node,e.result)}return l&&n&&n.onResultLimitExceeded&&n.onResultLimitExceeded(a),o}getSymbolKind(e){switch(e){case`object`:return Ay.Module;case`string`:return Ay.String;case`number`:return Ay.Number;case`array`:return Ay.Array;case`boolean`:return Ay.Boolean;default:return Ay.Variable}}getKeyLabel(e){let t=e.keyNode.value;return t&&=t.replace(/[\n]/g,`↵`),t&&t.trim()?t:`"${t}"`}getDetail(e){if(e){if(e.type===`boolean`||e.type===`number`||e.type===`null`||e.type===`string`)return String(e.value);if(e.type===`array`)return e.children.length?void 0:`[]`;if(e.type===`object`)return e.children.length?void 0:`{}`}}findDocumentColors(e,t,n){return this.schemaService.getSchemaForResource(e.uri,t).then(r=>{let i=[];if(r){let a=n&&typeof n.resultLimit==`number`?n.resultLimit:Number.MAX_VALUE,o=t.getMatchingSchemas(r.schema),s={};for(let t of o)if(!t.inverted&&t.schema&&(t.schema.format===`color`||t.schema.format===`color-hex`)&&t.node&&t.node.type===`string`){let r=String(t.node.offset);if(!s[r]){let o=wM(tM(t.node));if(o){let n=EM(e,t.node);i.push({color:o,range:n})}if(s[r]=!0,a--,a<=0)return n&&n.onResultLimitExceeded&&n.onResultLimitExceeded(e.uri),i}}}return i})}getColorPresentations(e,t,n,r){let i=[],a=Math.round(n.red*255),o=Math.round(n.green*255),s=Math.round(n.blue*255);function c(e){let t=e.toString(16);return t.length===2?t:`0`+t}let l;return l=n.alpha===1?`#${c(a)}${c(o)}${c(s)}`:`#${c(a)}${c(o)}${c(s)}${c(Math.round(n.alpha*255))}`,i.push({label:l,textEdit:ty.replace(r,JSON.stringify(l))}),i}};function EM(e,t){return Vv.create(e.positionAt(t.offset),e.positionAt(t.offset+t.length))}function DM(e){return tM(e)||K(`<empty>`)}var OM={schemaAssociations:[],schemas:{"https://json-schema.org/draft-04/schema":{definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},positiveInteger:{type:`integer`,minimum:0},positiveIntegerDefault0:{allOf:[{$ref:`#/definitions/positiveInteger`},{default:0}]},simpleTypes:{type:`string`,enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},minItems:1,uniqueItems:!0}},type:`object`,properties:{id:{type:`string`,format:`uri`},$schema:{type:`string`,format:`uri`},title:{type:`string`},description:{type:`string`},default:{},multipleOf:{type:`number`,minimum:0,exclusiveMinimum:!0},maximum:{type:`number`},exclusiveMaximum:{type:`boolean`,default:!1},minimum:{type:`number`},exclusiveMinimum:{type:`boolean`,default:!1},maxLength:{allOf:[{$ref:`#/definitions/positiveInteger`}]},minLength:{allOf:[{$ref:`#/definitions/positiveIntegerDefault0`}]},pattern:{type:`string`,format:`regex`},additionalItems:{anyOf:[{type:`boolean`},{$ref:`#`}],default:{}},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:{}},maxItems:{allOf:[{$ref:`#/definitions/positiveInteger`}]},minItems:{allOf:[{$ref:`#/definitions/positiveIntegerDefault0`}]},uniqueItems:{type:`boolean`,default:!1},maxProperties:{allOf:[{$ref:`#/definitions/positiveInteger`}]},minProperties:{allOf:[{$ref:`#/definitions/positiveIntegerDefault0`}]},required:{allOf:[{$ref:`#/definitions/stringArray`}]},additionalProperties:{anyOf:[{type:`boolean`},{$ref:`#`}],default:{}},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},enum:{type:`array`,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{anyOf:[{type:`string`,enum:[`date-time`,`uri`,`email`,`hostname`,`ipv4`,`ipv6`,`regex`]},{type:`string`}]},allOf:{allOf:[{$ref:`#/definitions/schemaArray`}]},anyOf:{allOf:[{$ref:`#/definitions/schemaArray`}]},oneOf:{allOf:[{$ref:`#/definitions/schemaArray`}]},not:{allOf:[{$ref:`#`}]}},dependencies:{exclusiveMaximum:[`maximum`],exclusiveMinimum:[`minimum`]},default:{}},"https://json-schema.org/draft-07/schema":{definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0},"https://json-schema.org/draft/2020-12/schema":{$id:`https://json-schema.org/draft/2020-12/schema`,$schema:`https://json-schema.org/draft/2020-12/schema`,title:`(Flattened static) Core and Validation specifications meta-schema`,type:[`object`,`boolean`],properties:{definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$ref:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/$defs/stringArray`}]}},$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},$ref:{type:`string`,format:`uri-reference`},$dynamicRef:{type:`string`,format:`uri-reference`},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$ref:`#`},default:{}},prefixItems:{$ref:`#/$defs/schemaArray`},items:{$ref:`#`},contains:{$ref:`#`},additionalProperties:{$ref:`#`},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$ref:`#`}},propertyNames:{$ref:`#`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$ref:`#`},unevaluatedItems:{$ref:`#`},unevaluatedProperties:{$ref:`#`},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$ref:`#`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}},"https://json-schema.org/draft/2019-09/schema":{$id:`https://json-schema.org/draft/2019-09/schema`,$schema:`https://json-schema.org/draft/2019-09/schema`,title:`(Flattened static) Core and Validation specifications meta-schema`,type:[`object`,`boolean`],properties:{definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$ref:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/$defs/stringArray`}]}},$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z][-A-Za-z0-9.:_]*$`},$ref:{type:`string`,format:`uri-reference`},$recursiveAnchor:{type:`boolean`,default:!1},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$ref:`#`},default:{}},additionalItems:{$ref:`#`},unevaluatedItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/$defs/schemaArray`}]},contains:{$ref:`#`},additionalProperties:{$ref:`#`},unevaluatedProperties:{$ref:`#`},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$ref:`#`}},propertyNames:{$ref:`#`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$ref:`#`},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$ref:`#`}},$defs:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}}}}},kM={id:K(`A unique identifier for the schema.`),$schema:K(`The schema to verify this document against.`),title:K(`A descriptive title of the schema.`),description:K(`A long description of the schema. Used in hover menus and suggestions.`),default:K(`A default value. Used by suggestions.`),multipleOf:K(`A number that should cleanly divide the current value (i.e. have no remainder).`),maximum:K(`The maximum numerical value, inclusive by default.`),exclusiveMaximum:K(`Makes the maximum property exclusive.`),minimum:K(`The minimum numerical value, inclusive by default.`),exclusiveMinimum:K(`Makes the minimum property exclusive.`),maxLength:K(`The maximum length of a string.`),minLength:K(`The minimum length of a string.`),pattern:K(`A regular expression to match the string against. It is not implicitly anchored.`),additionalItems:K(`For arrays, only when items is set as an array. If items are a schema, this schema validates items after the ones specified by the items schema. If false, additional items will cause validation to fail.`),items:K(`For arrays. Can either be a schema to validate every element against or an array of schemas to validate each item against in order (the first schema will validate the first element, the second schema will validate the second element, and so on.`),maxItems:K(`The maximum number of items that can be inside an array. Inclusive.`),minItems:K(`The minimum number of items that can be inside an array. Inclusive.`),uniqueItems:K(`If all of the items in the array must be unique. Defaults to false.`),maxProperties:K(`The maximum number of properties an object can have. Inclusive.`),minProperties:K(`The minimum number of properties an object can have. Inclusive.`),required:K(`An array of strings that lists the names of all properties required on this object.`),additionalProperties:K(`Either a schema or a boolean. If a schema, used to validate all properties not matched by 'properties', 'propertyNames', or 'patternProperties'. If false, any properties not defined by the adjacent keywords will cause this schema to fail.`),definitions:K(`Not used for validation. Place subschemas here that you wish to reference inline with $ref.`),properties:K(`A map of property names to schemas for each property.`),patternProperties:K(`A map of regular expressions on property names to schemas for matching properties.`),dependencies:K(`A map of property names to either an array of property names or a schema. An array of property names means the property named in the key depends on the properties in the array being present in the object in order to be valid. If the value is a schema, then the schema is only applied to the object if the property in the key exists on the object.`),enum:K(`The set of literal values that are valid.`),type:K(`Either a string of one of the basic schema types (number, integer, null, array, object, boolean, string) or an array of strings specifying a subset of those types.`),format:K(`Describes the format expected for the value. By default, not used for validation`),allOf:K(`An array of schemas, all of which must match.`),anyOf:K(`An array of schemas, where at least one must match.`),oneOf:K(`An array of schemas, exactly one of which must match.`),not:K(`A schema which must not match.`),$id:K(`A unique identifier for the schema.`),$ref:K(`Reference a definition hosted on any location.`),$comment:K(`Comments from schema authors to readers or maintainers of the schema.`),readOnly:K(`Indicates that the value of the instance is managed exclusively by the owning authority.`),examples:K(`Sample JSON values associated with a particular schema, for the purpose of illustrating usage.`),contains:K(`An array instance is valid against "contains" if at least one of its elements is valid against the given schema.`),propertyNames:K(`If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema.`),const:K(`An instance validates successfully against this keyword if its value is equal to the value of the keyword.`),contentMediaType:K(`Describes the media type of a string property.`),contentEncoding:K(`Describes the content encoding of a string property.`),if:K(`The validation outcome of the "if" subschema controls which of the "then" or "else" keywords are evaluated.`),then:K(`The "then" subschema is used for validation when the "if" subschema succeeds.`),else:K(`The "else" subschema is used for validation when the "if" subschema fails.`)};for(let e in OM.schemas){let t=OM.schemas[e];for(let e in t.properties){let n=t.properties[e];typeof n==`boolean`&&(n=t.properties[e]={});let r=kM[e];r&&(n.description=r)}}function AM(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string`);let n=String(e),r=``,i=t?!!t.extended:!1,a=t?!!t.globstar:!1,o=!1,s=t&&typeof t.flags==`string`?t.flags:``,c;for(let e=0,t=n.length;e<t;e++)switch(c=n[e],c){case`/`:case`$`:case`^`:case`+`:case`.`:case`(`:case`)`:case`=`:case`!`:case`|`:r+=`\\`+c;break;case`?`:if(i){r+=`.`;break}case`[`:case`]`:if(i){r+=c;break}case`{`:if(i){o=!0,r+=`(`;break}case`}`:if(i){o=!1,r+=`)`;break}case`,`:if(o){r+=`|`;break}r+=`\\`+c;break;case`*`:let t=n[e-1],s=1;for(;n[e+1]===`*`;)s++,e++;let l=n[e+1];a?s>1&&(t===`/`||t===void 0||t===`{`||t===`,`)&&(l===`/`||l===void 0||l===`,`||l===`}`)?(l===`/`?e++:t===`/`&&r.endsWith(`\\/`)&&(r=r.substr(0,r.length-2)),r+=`((?:[^/]*(?:/|$))*)`):r+=`([^/]*)`:r+=`.*`;break;default:r+=c}return(!s||!~s.indexOf(`g`))&&(r=`^`+r+`$`),new RegExp(r,s)}var jM=`!`,MM=`/`,NM=class{constructor(e,t,n){this.folderUri=t,this.uris=n,this.globWrappers=[];try{for(let t of e){let e=t[0]!==jM;e||(t=t.substring(1)),t.length>0&&(t[0]===MM&&(t=t.substring(1)),this.globWrappers.push({regexp:AM(`**/`+t,{extended:!0,globstar:!0}),include:e}))}t&&(t=BM(t),t.endsWith(`/`)||(t+=`/`),this.folderUri=t)}catch{this.globWrappers.length=0,this.uris=[]}}matchesPattern(e){if(this.folderUri&&!e.startsWith(this.folderUri))return!1;let t=!1;for(let{regexp:n,include:r}of this.globWrappers)n.test(e)&&(t=r);return t}getURIs(){return this.uris}},PM=class{constructor(e,t,n){this.service=e,this.uri=t,this.dependencies=new Set,this.anchors=void 0,n&&(this.unresolvedSchema=this.service.promise.resolve(new FM(n)))}getUnresolvedSchema(){return this.unresolvedSchema||=this.service.loadSchema(this.uri),this.unresolvedSchema}getResolvedSchema(){return this.resolvedSchema||=this.getUnresolvedSchema().then(e=>this.service.resolveSchemaContent(e,this)),this.resolvedSchema}clearSchema(){let e=!!this.unresolvedSchema;return this.resolvedSchema=void 0,this.unresolvedSchema=void 0,this.dependencies.clear(),this.anchors=void 0,e}},FM=class{constructor(e,t=[]){this.schema=e,this.errors=t}};function IM(e,t,n){return{message:e,code:t,relatedInformation:n?[{location:{uri:n,range:Vv.create(0,0,0,0)},message:e}]:void 0}}var LM=class{constructor(e,t=[],n=[],r){this.schema=e,this.errors=t,this.warnings=n,this.schemaDraft=r}getSection(e){let t=this.getSectionRecursive(e,this.schema);if(t)return Uj(t)}getSectionRecursive(e,t){if(!t||typeof t==`boolean`||e.length===0)return t;let n=e.shift();if(t.properties&&typeof t.properties[n])return this.getSectionRecursive(e,t.properties[n]);if(t.patternProperties){for(let r of Object.keys(t.patternProperties))if(Cj(r)?.test(n))return this.getSectionRecursive(e,t.patternProperties[r])}else if(typeof t.additionalProperties==`object`)return this.getSectionRecursive(e,t.additionalProperties);else if(n.match(`[0-9]+`)){if(Array.isArray(t.items)){let r=parseInt(n,10);if(!isNaN(r)&&t.items[r])return this.getSectionRecursive(e,t.items[r])}else if(t.items)return this.getSectionRecursive(e,t.items)}}},RM=class{constructor(e,t,n){this.contextService=t,this.requestService=e,this.promiseConstructor=n||Promise,this.callOnDispose=[],this.contributionSchemas={},this.contributionAssociations=[],this.schemasById={},this.filePatternAssociations=[],this.registeredSchemasIds={}}getRegisteredSchemaIds(e){return Object.keys(this.registeredSchemasIds).filter(t=>{let n=kj.parse(t).scheme;return n!==`schemaservice`&&(!e||e(n))})}get promise(){return this.promiseConstructor}dispose(){for(;this.callOnDispose.length>0;)this.callOnDispose.pop()()}onResourceChange(e){this.cachedSchemaForResource=void 0;let t=!1;e=qj(e);let n=[e],r=Object.keys(this.schemasById).map(e=>this.schemasById[e]);for(;n.length;){let e=n.pop();for(let i=0;i<r.length;i++){let a=r[i];a&&(a.uri===e||a.dependencies.has(e))&&(a.uri!==e&&n.push(a.uri),a.clearSchema()&&(t=!0),r[i]=void 0)}}return t}setSchemaContributions(e){if(e.schemas){let t=e.schemas;for(let e in t){let n=qj(e);this.contributionSchemas[n]=this.addSchemaHandle(n,t[e])}}if(Array.isArray(e.schemaAssociations)){let t=e.schemaAssociations;for(let e of t){let t=e.uris.map(qj),n=this.addFilePatternAssociation(e.pattern,e.folderUri,t);this.contributionAssociations.push(n)}}}addSchemaHandle(e,t){let n=new PM(this,e,t);return this.schemasById[e]=n,n}getOrAddSchemaHandle(e,t){return this.schemasById[e]||this.addSchemaHandle(e,t)}addFilePatternAssociation(e,t,n){let r=new NM(e,t,n);return this.filePatternAssociations.push(r),r}registerExternalSchema(e){let t=qj(e.uri);return this.registeredSchemasIds[t]=!0,this.cachedSchemaForResource=void 0,e.fileMatch&&e.fileMatch.length&&this.addFilePatternAssociation(e.fileMatch,e.folderUri,[t]),e.schema?this.addSchemaHandle(t,e.schema):this.getOrAddSchemaHandle(t)}clearExternalSchemas(){this.schemasById={},this.filePatternAssociations=[],this.registeredSchemasIds={},this.cachedSchemaForResource=void 0;for(let e in this.contributionSchemas)this.schemasById[e]=this.contributionSchemas[e],this.registeredSchemasIds[e]=!0;for(let e of this.contributionAssociations)this.filePatternAssociations.push(e)}getResolvedSchema(e){let t=qj(e),n=this.schemasById[t];return n?n.getResolvedSchema():this.promise.resolve(void 0)}loadSchema(e){if(!this.requestService){let t=K(`Unable to load schema from '{0}'. No schema request service available`,VM(e));return this.promise.resolve(new FM({},[IM(t,Tj.SchemaResolveError,e)]))}return this.requestService(e).then(t=>{if(!t)return new FM({},[IM(K(`Unable to load schema from '{0}': No content.`,VM(e)),Tj.SchemaResolveError,e)]);let n=[];t.charCodeAt(0)===65279&&(n.push(IM(K(`Problem reading content from '{0}': UTF-8 with BOM detected, only UTF 8 is allowed.`,VM(e)),Tj.SchemaResolveError,e)),t=t.trimStart());let r={},i=[];return r=lj(t,i),i.length&&n.push(IM(K(`Unable to parse content from '{0}': Parse error at offset {1}.`,VM(e),i[0].offset),Tj.SchemaResolveError,e)),new FM(r,n)},t=>{let{message:n,code:r}=t;if(typeof n!=`string`){let e=t.toString(),r=t.toString().split(`Error: `);r.length>1&&(e=r[1]),Sj(e,`.`)&&(e=e.substr(0,e.length-1)),n=e}let i=Tj.SchemaResolveError;return typeof r==`number`&&r<65536&&(i+=r),new FM({},[IM(K(`Unable to load schema from '{0}': {1}.`,VM(e),n),i,e)])})}resolveSchemaContent(e,t){let n=e.errors.slice(0),r=e.schema,i=r.$schema?Jj(r.$schema):void 0;if(i===Ej.v3)return this.promise.resolve(new LM({},[IM(K(`Draft-03 schemas are not supported.`),Tj.SchemaUnsupportedFeature)],[],i));let a=new Set,o=this.contextService,s=(e,t)=>{t=decodeURIComponent(t);let n=e;return t[0]===`/`&&(t=t.substring(1)),t.split(`/`).some(e=>(e=e.replace(/~1/g,`/`).replace(/~0/g,`~`),n=n[e],!n)),n},c=(e,t,n)=>(t.anchors||=p(e),t.anchors.get(n)),l=(e,t)=>{for(let n in t)t.hasOwnProperty(n)&&n!==`id`&&n!==`$id`&&(e[n]=t[n])},u=(e,t,r,i)=>{let a;if(a=i===void 0||i.length===0?t:i.charAt(0)===`/`?s(t,i):c(t,r,i),a)l(e,a);else{let e=K(`$ref '{0}' in '{1}' can not be resolved.`,i||``,r.uri);n.push(IM(e,Tj.SchemaResolveError))}},d=(e,t,r,i)=>{o&&!/^[A-Za-z][A-Za-z0-9+\-.+]*:\/.*/.test(t)&&(t=o.resolveRelativePath(t,i.uri)),t=qj(t);let a=this.getOrAddSchemaHandle(t);return a.getUnresolvedSchema().then(o=>{if(i.dependencies.add(t),o.errors.length){let e=o.errors[0];r&&t+``+r;let i=r?K(`Problems loading reference '{0}': {1}`,r,e.message):e.message;n.push(IM(i,e.code,t))}return u(e,o.schema,a,r),f(e,o.schema,a)})},f=(e,t,n)=>{let r=[];return this.traverseNodes(e,e=>{let i=new Set;for(;e.$ref;){let a=e.$ref,o=a.split(`#`,2);if(delete e.$ref,o[0].length>0){r.push(d(e,o[0],o[1],n));return}else if(!i.has(a)){let r=o[1];u(e,t,n,r),i.add(a)}}e.$recursiveRef&&a.add(`$recursiveRef`),e.$dynamicRef&&a.add(`$dynamicRef`)}),this.promise.all(r)},p=e=>{let t=new Map;return this.traverseNodes(e,e=>{let r=e.$id||e.id,i=yj(r)&&r.charAt(0)===`#`?r.substring(1):e.$anchor;i&&(t.has(i)?n.push(IM(K(`Duplicate anchor declaration: '{0}'`,i),Tj.SchemaResolveError)):t.set(i,e)),e.$recursiveAnchor&&a.add(`$recursiveAnchor`),e.$dynamicAnchor&&a.add(`$dynamicAnchor`)}),t};return f(r,r,t).then(e=>{let t=[];return a.size&&t.push(IM(K(`The schema uses meta-schema features ({0}) that are not yet supported by the validator.`,Array.from(a.keys()).join(`, `)),Tj.SchemaUnsupportedFeature)),new LM(r,n,t,i)})}traverseNodes(e,t){if(!e||typeof e!=`object`)return Promise.resolve(null);let n=new Set,r=(...e)=>{for(let t of e)bj(t)&&s.push(t)},i=(...e)=>{for(let t of e)if(bj(t))for(let e in t){let n=t[e];bj(n)&&s.push(n)}},a=(...e)=>{for(let t of e)if(Array.isArray(t))for(let e of t)bj(e)&&s.push(e)},o=e=>{if(Array.isArray(e))for(let t of e)bj(t)&&s.push(t);else bj(e)&&s.push(e)},s=[e],c=s.pop();for(;c;)n.has(c)||(n.add(c),t(c),r(c.additionalItems,c.additionalProperties,c.not,c.contains,c.propertyNames,c.if,c.then,c.else,c.unevaluatedItems,c.unevaluatedProperties),i(c.definitions,c.$defs,c.properties,c.patternProperties,c.dependencies,c.dependentSchemas),a(c.anyOf,c.allOf,c.oneOf,c.prefixItems),o(c.items)),c=s.pop()}getSchemaFromProperty(e,t){if(t.root?.type===`object`){for(let n of t.root.properties)if(n.keyNode.value===`$schema`&&n.valueNode?.type===`string`){let t=n.valueNode.value;return this.contextService&&!/^\w[\w\d+.-]*:/.test(t)&&(t=this.contextService.resolveRelativePath(t,e)),t}}}getAssociatedSchemas(e){let t=Object.create(null),n=[],r=BM(e);for(let e of this.filePatternAssociations)if(e.matchesPattern(r))for(let r of e.getURIs())t[r]||(n.push(r),t[r]=!0);return n}getSchemaURIsForResource(e,t){let n=t&&this.getSchemaFromProperty(e,t);return n?[n]:this.getAssociatedSchemas(e)}getSchemaForResource(e,t){if(t){let n=this.getSchemaFromProperty(e,t);if(n){let e=qj(n);return this.getOrAddSchemaHandle(e).getResolvedSchema()}}if(this.cachedSchemaForResource&&this.cachedSchemaForResource.resource===e)return this.cachedSchemaForResource.resolvedSchema;let n=this.getAssociatedSchemas(e),r=n.length>0?this.createCombinedSchema(e,n).getResolvedSchema():this.promise.resolve(void 0);return this.cachedSchemaForResource={resource:e,resolvedSchema:r},r}createCombinedSchema(e,t){if(t.length===1)return this.getOrAddSchemaHandle(t[0]);{let n=`schemaservice://combinedSchema/`+encodeURIComponent(e),r={allOf:t.map(e=>({$ref:e}))};return this.addSchemaHandle(n,r)}}getMatchingSchemas(e,t,n){if(n){let e=n.id||`schemaservice://untitled/matchingSchemas/`+ zM++;return this.addSchemaHandle(e,n).getResolvedSchema().then(e=>t.getMatchingSchemas(e.schema).filter(e=>!e.inverted))}return this.getSchemaForResource(e.uri,t).then(e=>e?t.getMatchingSchemas(e.schema).filter(e=>!e.inverted):[])}},zM=0;function BM(e){try{return kj.parse(e).with({fragment:null,query:null}).toString(!0)}catch{return e}}function VM(e){try{let t=kj.parse(e);if(t.scheme===`file`)return t.fsPath}catch{}return e}function HM(e,t){let n=[],r=[],i=[],a=-1,o=oj(e.getText(),!1),s=o.scan();function c(e){n.push(e),r.push(i.length)}for(;s!==17;){switch(s){case 1:case 3:{let t=e.positionAt(o.getTokenOffset()).line,n={startLine:t,endLine:t,kind:s===1?`object`:`array`};i.push(n);break}case 2:case 4:{let t=s===2?`object`:`array`;if(i.length>0&&i[i.length-1].kind===t){let t=i.pop(),n=e.positionAt(o.getTokenOffset()).line;t&&n>t.startLine+1&&a!==t.startLine&&(t.endLine=n-1,c(t),a=t.startLine)}break}case 13:{let t=e.positionAt(o.getTokenOffset()).line,n=e.positionAt(o.getTokenOffset()+o.getTokenLength()).line;o.getTokenError()===1&&t+1<e.lineCount?o.setPosition(e.offsetAt(Bv.create(t+1,0))):t<n&&(c({startLine:t,endLine:n,kind:qv.Comment}),a=t);break}case 12:{let t=e.getText().substr(o.getTokenOffset(),o.getTokenLength()).match(/^\/\/\s*#(region\b)|(endregion\b)/);if(t){let n=e.positionAt(o.getTokenOffset()).line;if(t[1]){let e={startLine:n,endLine:n,kind:qv.Region};i.push(e)}else{let e=i.length-1;for(;e>=0&&i[e].kind!==qv.Region;)e--;if(e>=0){let t=i[e];i.length=e,n>t.startLine&&a!==t.startLine&&(t.endLine=n,c(t),a=t.startLine)}}}break}}s=o.scan()}let l=t&&t.rangeLimit;if(typeof l!=`number`||n.length<=l)return n;t&&t.onRangeLimitExceeded&&t.onRangeLimitExceeded(e.uri);let u=[];for(let e of r)e<30&&(u[e]=(u[e]||0)+1);let d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t){if(t+d>l){f=e;break}d+=t}}let p=[];for(let e=0;e<n.length;e++){let t=r[e];typeof t==`number`&&(t<f||t===f&&d++<l)&&p.push(n[e])}return p}function UM(e,t,n){function r(t){let r=e.offsetAt(t),a=n.getNodeFromOffset(r,!0),s=[];for(;a;){switch(a.type){case`string`:case`object`:case`array`:let e=a.offset+1,t=a.offset+a.length-1;e<t&&r>=e&&r<=t&&s.push(i(e,t)),s.push(i(a.offset,a.offset+a.length));break;case`number`:case`boolean`:case`null`:case`property`:s.push(i(a.offset,a.offset+a.length));break}if(a.type===`property`||a.parent&&a.parent.type===`array`){let e=o(a.offset+a.length,5);e!==-1&&s.push(i(a.offset,e))}a=a.parent}let c;for(let e=s.length-1;e>=0;e--)c=Hy.create(s[e],c);return c||=Hy.create(Vv.create(t,t)),c}function i(t,n){return Vv.create(e.positionAt(t),e.positionAt(n))}let a=oj(e.getText(),!0);function o(e,t){return a.setPosition(e),a.scan()===t?a.getTokenOffset()+a.getTokenLength():-1}return t.map(r)}function WM(e,t,n){let r;if(n){let t=e.offsetAt(n.start);r={offset:t,length:e.offsetAt(n.end)-t}}let i={tabSize:t?t.tabSize:4,insertSpaces:t?.insertSpaces===!0,insertFinalNewline:t?.insertFinalNewline===!0,eol:`
|
|
79
|
+
`,keepLines:t?.keepLines===!0};return mj(e.getText(),r,i).map(t=>ty.replace(Vv.create(e.positionAt(t.offset),e.positionAt(t.offset+t.length)),t.content))}var GM;(function(e){e[e.Object=0]=`Object`,e[e.Array=1]=`Array`})(GM||={});var KM=class{constructor(e,t){this.propertyName=e??``,this.beginningLineNumber=t,this.childrenProperties=[],this.lastProperty=!1,this.noKeyName=!1}addChildProperty(e){if(e.parent=this,this.childrenProperties.length>0){let t=0;t=e.noKeyName?this.childrenProperties.length:JM(this.childrenProperties,e,qM),t<0&&(t=t*-1-1),this.childrenProperties.splice(t,0,e)}else this.childrenProperties.push(e);return e}};function qM(e,t){let n=e.propertyName.toLowerCase(),r=t.propertyName.toLowerCase();return n<r?-1:+(n>r)}function JM(e,t,n){let r=t.propertyName.toLowerCase(),i=e[0].propertyName.toLowerCase(),a=e[e.length-1].propertyName.toLowerCase();if(r<i)return 0;if(r>a)return e.length;let o=0,s=e.length-1;for(;o<=s;){let r=s+o>>1,i=n(t,e[r]);if(i>0)o=r+1;else if(i<0)s=r-1;else return r}return-o-1}function YM(e,t){let n={...t,keepLines:!1},r=Ev.applyEdits(e,WM(e,n,void 0)),i=Ev.create(`test://test.json`,`json`,0,r),a=ZM(i,XM(i)),o=WM(a,n,void 0),s=Ev.applyEdits(a,o);return[ty.replace(Vv.create(Bv.create(0,0),e.positionAt(e.getText().length)),s)]}function XM(e){let t=oj(e.getText(),!1),n=new KM,r=n,i=n,a=n,o,s=0,c=0,l,u,d=-1,f=-1,p=0,m=0,h=[],g=!1,_=!1;for(;(o=t.scan())!==17;){if(g===!0&&o!==14&&o!==15&&o!==12&&o!==13&&i.endLineNumber===void 0){let e=t.getTokenStartLine();u===2||u===4?a.endLineNumber=e-1:i.endLineNumber=e-1,p=e,g=!1}if(_===!0&&o!==14&&o!==15&&o!==12&&o!==13&&(p=t.getTokenStartLine(),_=!1),t.getTokenStartLine()!==s){for(let n=s;n<t.getTokenStartLine();n++){let t=e.getText(Vv.create(Bv.create(n,0),Bv.create(n+1,0))).length;c+=t}s=t.getTokenStartLine()}switch(o){case 10:if(l===void 0||l===1||l===5&&h[h.length-1]===GM.Object){let e=new KM(t.getTokenValue(),p);a=i,i=r.addChildProperty(e)}break;case 3:if(n.beginningLineNumber===void 0&&(n.beginningLineNumber=t.getTokenStartLine()),h[h.length-1]===GM.Object)r=i;else if(h[h.length-1]===GM.Array){let e=new KM(t.getTokenValue(),p);e.noKeyName=!0,a=i,i=r.addChildProperty(e),r=i}h.push(GM.Array),i.type=GM.Array,p=t.getTokenStartLine(),p++;break;case 1:if(n.beginningLineNumber===void 0)n.beginningLineNumber=t.getTokenStartLine();else if(h[h.length-1]===GM.Array){let e=new KM(t.getTokenValue(),p);e.noKeyName=!0,a=i,i=r.addChildProperty(e)}i.type=GM.Object,h.push(GM.Object),r=i,p=t.getTokenStartLine(),p++;break;case 4:m=t.getTokenStartLine(),h.pop(),i.endLineNumber===void 0&&(l===2||l===4)&&(i.endLineNumber=m-1,i.lastProperty=!0,i.lineWhereToAddComma=d,i.indexWhereToAddComa=f,a=i,i=i?i.parent:void 0,r=i),n.endLineNumber=m,p=m+1;break;case 2:m=t.getTokenStartLine(),h.pop(),l!==1&&(i.endLineNumber===void 0&&(i.endLineNumber=m-1,i.lastProperty=!0,i.lineWhereToAddComma=d,i.indexWhereToAddComa=f),a=i,i=i?i.parent:void 0,r=i),n.endLineNumber=t.getTokenStartLine(),p=m+1;break;case 5:m=t.getTokenStartLine(),i.endLineNumber===void 0&&(h[h.length-1]===GM.Object||h[h.length-1]===GM.Array&&(l===2||l===4))&&(i.endLineNumber=m,i.commaIndex=t.getTokenOffset()-c,i.commaLine=m),(l===2||l===4)&&(a=i,i=i?i.parent:void 0,r=i),p=m+1;break;case 13:l===5&&d===t.getTokenStartLine()&&(h[h.length-1]===GM.Array&&(u===2||u===4)||h[h.length-1]===GM.Object)&&(h[h.length-1]===GM.Array&&(u===2||u===4)||h[h.length-1]===GM.Object)&&(i.endLineNumber=void 0,g=!0),(l===1||l===3)&&d===t.getTokenStartLine()&&(_=!0);break}o!==14&&o!==13&&o!==12&&o!==15&&(u=l,l=o,d=t.getTokenStartLine(),f=t.getTokenOffset()+t.getTokenLength()-c)}return n}function ZM(e,t){if(t.childrenProperties.length===0)return e;let n=Ev.create(`test://test.json`,`json`,0,e.getText()),r=[];for($M(r,t,t.beginningLineNumber);r.length>0;){let t=r.shift(),i=t.propertyTreeArray,a=t.beginningLineNumber;for(let t=0;t<i.length;t++){let o=i[t],s=Vv.create(Bv.create(o.beginningLineNumber,0),Bv.create(o.endLineNumber+1,0)),c=e.getText(s),l=Ev.create(`test://test.json`,`json`,0,c);if(o.lastProperty===!0&&t!==i.length-1){let e=o.lineWhereToAddComma-o.beginningLineNumber,t=o.indexWhereToAddComa,n={range:Vv.create(Bv.create(e,t),Bv.create(e,t)),text:`,`};Ev.update(l,[n],1)}else if(o.lastProperty===!1&&t===i.length-1){let e=o.commaIndex,t=o.commaLine-o.beginningLineNumber,n={range:Vv.create(Bv.create(t,e),Bv.create(t,e+1)),text:``};Ev.update(l,[n],1)}let u=o.endLineNumber-o.beginningLineNumber+1,d={range:Vv.create(Bv.create(a,0),Bv.create(a+u,0)),text:l.getText()};Ev.update(n,[d],1),$M(r,o,a),a+=u}}return n}function QM(e){e.sort((e,t)=>e.propertyName.localeCompare(t.propertyName))}function $M(e,t,n){if(t.childrenProperties.length!==0)if(t.type===GM.Object){let r=1/0;for(let e of t.childrenProperties)e.beginningLineNumber<r&&(r=e.beginningLineNumber);let i=r-t.beginningLineNumber;n+=i,QM(t.childrenProperties),e.push(new tN(n,t.childrenProperties))}else t.type===GM.Array&&eN(e,t,n)}function eN(e,t,n){for(let r of t.childrenProperties){if(r.type===GM.Object){let i=1/0;for(let e of r.childrenProperties)e.beginningLineNumber<i&&(i=e.beginningLineNumber);let a=i-r.beginningLineNumber;e.push(new tN(n+r.beginningLineNumber-t.beginningLineNumber+a,r.childrenProperties))}r.type===GM.Array&&eN(e,r,n+r.beginningLineNumber-t.beginningLineNumber)}}var tN=class{constructor(e,t){this.beginningLineNumber=e,this.propertyTreeArray=t}};function nN(e,t){let n=[];return t.visit(r=>{if(r.type===`property`&&r.keyNode.value===`$ref`&&r.valueNode?.type===`string`){let i=r.valueNode.value,a=iN(t,i);if(a){let t=e.positionAt(a.offset);n.push({target:`${e.uri}#${t.line+1},${t.character+1}`,range:rN(e,r.valueNode)})}}return!0}),Promise.resolve(n)}function rN(e,t){return Vv.create(e.positionAt(t.offset+1),e.positionAt(t.offset+t.length-1))}function iN(e,t){let n=oN(t);return n?aN(n,e.root):null}function aN(e,t){if(!t)return null;if(e.length===0)return t;let n=e.shift();if(t&&t.type===`object`){let r=t.properties.find(e=>e.keyNode.value===n);return r?aN(e,r.valueNode):null}else if(t&&t.type===`array`&&n.match(/^(0|[1-9][0-9]*)$/)){let r=Number.parseInt(n),i=t.items[r];return i?aN(e,i):null}return null}function oN(e){return e===`#`?[]:e[0]!==`#`||e[1]!==`/`?null:e.substring(2).split(/\//).map(sN)}function sN(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function cN(e){let t=e.promiseConstructor||Promise,n=new RM(e.schemaRequestService,e.workspaceContext,t);n.setSchemaContributions(OM);let r=new lM(n,e.contributions,t,e.clientCapabilities),i=new uM(n,e.contributions,t),a=new TM(n),o=new pM(n,t);return{configure:e=>{n.clearExternalSchemas(),e.schemas?.forEach(n.registerExternalSchema.bind(n)),o.configure(e)},resetSchema:e=>n.onResourceChange(e),doValidation:o.doValidation.bind(o),getLanguageStatus:o.getLanguageStatus.bind(o),parseJSONDocument:e=>sM(e,{collectComments:!0}),newJSONDocument:(e,t,n)=>eM(e,t,n),getMatchingSchemas:n.getMatchingSchemas.bind(n),doResolve:r.doResolve.bind(r),doComplete:r.doComplete.bind(r),findDocumentSymbols:a.findDocumentSymbols.bind(a),findDocumentSymbols2:a.findDocumentSymbols2.bind(a),findDocumentColors:a.findDocumentColors.bind(a),getColorPresentations:a.getColorPresentations.bind(a),doHover:i.doHover.bind(i),getFoldingRanges:HM,getSelectionRanges:UM,findDefinition:()=>Promise.resolve([]),findLinks:nN,format:(e,t,n)=>WM(e,n,t),sort:(e,t)=>YM(e,t)}}function lN(e){let t=cN({schemaRequestService:async e=>{try{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);return await t.text()}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`Failed to fetch schema from ${e}: ${n}`)}}});return t.configure({schemas:[{uri:`inmemory://schema.json`,fileMatch:[`*`],schema:e}],validate:!0,allowComments:!1}),{schema:e,languageService:t}}var uN=({schema:e,value:t=``,options:n={},hideGutter:r,...i})=>{let a=typeof t==`object`?JSON.stringify(t,null,2):t,o=(0,N.useMemo)(()=>e?lN(e):null,[e]);return(0,ye.jsx)(hv,{value:a,extensions:(0,N.useMemo)(()=>[FA(),LA({hideGutter:r}),RA,...o?[Fv(o),nA(o)]:[],rA()],[o,r]),options:{lineNumbers:n.lineNumbers??!1,lineWrapping:n.lineWrapping??!0,autocompletion:!o,foldGutter:n.foldGutter??!1,...n},...i})},dN=BigInt(2**32-1),fN=BigInt(32);function pN(e,t=!1){return t?{h:Number(e&dN),l:Number(e>>fN&dN)}:{h:Number(e>>fN&dN)|0,l:Number(e&dN)|0}}function mN(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=pN(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var hN=(e,t,n)=>e<<n|t>>>32-n,gN=(e,t,n)=>t<<n|e>>>32-n,_N=(e,t,n)=>t<<n-32|e>>>64-n,vN=(e,t,n)=>e<<n-32|t>>>64-n;function yN(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function bN(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw RangeError(`${n}expected integer >= 0, got ${e}`)}}function xN(e,t,n=``){let r=yN(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`,l=o+`expected Uint8Array`+s+`, got `+c;throw r?RangeError(l):TypeError(l)}return e}function SN(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function CN(e,t){xN(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw RangeError(`"digestInto() output" expected to be of length >=`+n)}function wN(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function TN(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var EN=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function DN(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ON(e){for(let t=0;t<e.length;t++)e[t]=DN(e[t]);return e}var kN=EN?e=>e:ON;typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function AN(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}var jN=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),MN=BigInt(0),NN=BigInt(1),PN=BigInt(2),FN=BigInt(7),IN=BigInt(256),LN=BigInt(113),RN=[],zN=[],BN=[];for(let e=0,t=NN,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],RN.push(2*(5*r+n)),zN.push((e+1)*(e+2)/2%64);let i=MN;for(let e=0;e<7;e++)t=(t<<NN^(t>>FN)*LN)%IN,t&PN&&(i^=NN<<(NN<<BigInt(e))-NN);BN.push(i)}var VN=mN(BN,!0),HN=VN[0],UN=VN[1],WN=(e,t,n)=>n>32?_N(e,t,n):hN(e,t,n),GN=(e,t,n)=>n>32?vN(e,t,n):gN(e,t,n);function KN(e,t=24){if(bN(t,`rounds`),t<1||t>24)throw Error(`"rounds" expected integer 1..24`);let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=WN(a,o,1)^n[r],c=GN(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=zN[n],a=WN(t,i,r),o=GN(t,i,r),s=RN[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=HN[r],e[1]^=UN[r]}TN(n)}var qN=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,n,r=!1,i=24){if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.canXOF=r,this.rounds=i,bN(n,`outputLen`),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=wN(this.state)}clone(){return this._cloneInto()}keccak(){kN(this.state32),KN(this.state32,this.rounds),kN(this.state32),this.posOut=0,this.pos=0}update(e){SN(this),xN(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){SN(this,!1),xN(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return bN(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(CN(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,TN(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}},JN=((e,t,n,r={})=>AN(()=>new qN(t,e,n),r))(6,72,64,jN(10)),YN=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,XN=Math.ceil,ZN=Math.floor,QN=`[BigNumber Error] `,$N=QN+`Number primitive has more than 15 significant digits: `,eP=0x5af3107a4000,tP=14,nP=9007199254740991,rP=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],iP=1e7,aP=1e9;function oP(e){var t,n,r,i=v.prototype={constructor:v,toString:null,valueOf:null},a=new v(1),o=20,s=4,c=-7,l=21,u=-1e7,d=1e7,f=!1,p=1,m=0,h={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=!0;function v(e,t){var i,a,c,l,f,p,m,h,y=this;if(!(y instanceof v))return new v(e,t);if(t==null){if(e&&e._isBigNumber===!0){y.s=e.s,!e.c||e.e>d?y.c=y.e=null:e.e<u?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);l>d?y.c=y.e=null:(y.e=l,y.c=[e]);return}h=String(e)}else{if(!YN.test(h=String(e)))return r(y,h,p);y.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(l=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(l<0&&(l=f),l+=+h.slice(f+1),h=h.substring(0,f)):l<0&&(l=h.length)}else{if(uP(t,2,g.length,`Base`),t==10&&_)return y=new v(e),S(y,o+y.e+1,s);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return r(y,h,p,t);if(y.s=1/e<0?(h=h.slice(1),-1):1,v.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error($N+e)}else y.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=g.slice(0,t),l=f=0,m=h.length;f<m;f++)if(i.indexOf(a=h.charAt(f))<0){if(a==`.`){if(f>l){l=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,l=0;continue}return r(y,String(e),p,t)}p=!1,h=n(h,t,10,y.s),(l=h.indexOf(`.`))>-1?h=h.replace(`.`,``):l=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&v.DEBUG&&m>15&&(e>nP||e!==ZN(e)))throw Error($N+y.s*e);if((l=l-f-1)>d)y.c=y.e=null;else if(l<u)y.c=[y.e=0];else{if(y.e=l,y.c=[],f=(l+1)%tP,l<0&&(f+=tP),f<m){for(f&&y.c.push(+h.slice(0,f)),m-=tP;f<m;)y.c.push(+h.slice(f,f+=tP));f=tP-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);y.c.push(+h)}}else y.c=[y.e=0]}v.clone=oP,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(e){var t,n;if(e!=null)if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],uP(n,0,aP,t),o=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],uP(n,0,8,t),s=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(uP(n[0],-aP,0,t),uP(n[1],0,aP,t),c=n[0],l=n[1]):(uP(n,-aP,aP,t),c=-(l=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`))if(n=e[t],n&&n.pop)uP(n[0],-aP,-1,t),uP(n[1],1,aP,t),u=n[0],d=n[1];else if(uP(n,-aP,aP,t),n)u=-(d=n<0?-n:n);else throw Error(QN+t+` cannot be zero: `+n);if(e.hasOwnProperty(t=`CRYPTO`))if(n=e[t],n===!!n)if(n)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=n;else throw f=!n,Error(QN+`crypto unavailable`);else f=n;else throw Error(QN+t+` not true or false: `+n);if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],uP(n,0,9,t),p=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],uP(n,0,aP,t),m=n),e.hasOwnProperty(t=`FORMAT`))if(n=e[t],typeof n==`object`)h=n;else throw Error(QN+t+` not an object: `+n);if(e.hasOwnProperty(t=`ALPHABET`))if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))_=n.slice(0,10)==`0123456789`,g=n;else throw Error(QN+t+` invalid: `+n)}else throw Error(QN+`Object expected: `+e);return{DECIMAL_PLACES:o,ROUNDING_MODE:s,EXPONENTIAL_AT:[c,l],RANGE:[u,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:m,FORMAT:h,ALPHABET:g}},v.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var t,n,r=e.c,i=e.e,a=e.s;out:if({}.toString.call(r)==`[object Array]`){if((a===1||a===-1)&&i>=-aP&&i<=aP&&i===ZN(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%tP,t<1&&(t+=tP),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=eP||n!==ZN(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(a===null||a===1||a===-1))return!0;throw Error(QN+`Invalid BigNumber: `+e)},v.maximum=v.max=function(){return b(arguments,-1)},v.minimum=v.min=function(){return b(arguments,1)},v.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return ZN(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,s,c,l=0,u=[],d=new v(a);if(e==null?e=o:uP(e,0,aP),s=XN(e/tP),f)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)c=n[l]*131072+(n[l+1]>>>11),c>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(c%0x5af3107a4000),l+=2);l=s/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(s*=7);l<s;)c=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],c>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(c%0x5af3107a4000),l+=7);l=s/7}else throw f=!1,Error(QN+`crypto unavailable`);if(!f)for(;l<s;)c=t(),c<9e15&&(u[l++]=c%0x5af3107a4000);for(s=u[--l],e%=tP,s&&e&&(c=rP[tP-e],u[l]=ZN(s/c)*c);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=tP);for(l=1,c=u[0];c>=10;c/=10,l++);l<tP&&(i-=tP-l)}return d.e=i,d.c=u,d}})(),v.sum=function(){for(var e=1,t=arguments,n=new v(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,c,l){var u,d,f,p,h,_,y,b,x=r.indexOf(`.`),S=o,C=s;for(x>=0&&(p=m,m=0,r=r.replace(`.`,``),b=new v(i),_=b.pow(r.length-x),m=p,b.c=n(pP(cP(_.c),_.e,`0`),10,a,e),b.e=b.c.length),y=n(r,i,a,l?(u=g,e):(u=e,g)),f=p=y.length;y[--p]==0;y.pop());if(!y[0])return u.charAt(0);if(x<0?--f:(_.c=y,_.e=f,_.s=c,_=t(_,b,S,C,a),y=_.c,h=_.r,f=_.e),d=f+S+1,x=y[d],p=a/2,h=h||d<0||y[d+1]!=null,h=C<4?(x!=null||h)&&(C==0||C==(_.s<0?3:2)):x>p||x==p&&(C==4||h||C==6&&y[d-1]&1||C==(_.s<0?8:7)),d<1||!y[0])r=h?pP(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(y.length=d,h)for(--a;++y[--d]>a;)y[d]=0,d||(++f,y=[1].concat(y));for(p=y.length;!y[--p];);for(x=0,r=``;x<=p;r+=u.charAt(y[x++]));r=pP(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%iP,u=t/iP|0;for(e=e.slice();c--;)a=e[c]%iP,o=e[c]/iP|0,r=u*a+o*l,i=l*a+r%iP*iP+s,s=(i/n|0)+(r/iP|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,y,b,x,C,w,T,E,ee=r.s==i.s?1:-1,D=r.c,O=i.c;if(!D||!D[0]||!O||!O[0])return new v(!r.s||!i.s||(D?O&&D[0]==O[0]:!O)?NaN:D&&D[0]==0||!O?ee*0:ee/0);for(h=new v(ee),g=h.c=[],l=r.e-i.e,ee=a+l+1,s||(s=eP,l=sP(r.e/tP)-sP(i.e/tP),ee=ee/tP|0),u=0;O[u]==(D[u]||0);u++);if(O[u]>(D[u]||0)&&l--,ee<0)g.push(1),d=!0;else{for(C=D.length,T=O.length,u=0,ee+=2,f=ZN(s/(O[0]+1)),f>1&&(O=e(O,f,s),D=e(D,f,s),T=O.length,C=D.length),x=T,_=D.slice(0,T),y=_.length;y<T;_[y++]=0);E=O.slice(),E=[0].concat(E),w=O[0],O[1]>=s/2&&w++;do{if(f=0,c=t(O,_,T,y),c<0){if(b=_[0],T!=y&&(b=b*s+(_[1]||0)),f=ZN(b/w),f>1)for(f>=s&&(f=s-1),p=e(O,f,s),m=p.length,y=_.length;t(p,_,m,y)==1;)f--,n(p,T<m?E:O,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=O.slice(),m=p.length;if(m<y&&(p=[0].concat(p)),n(_,p,y,s),y=_.length,c==-1)for(;t(O,_,T,y)<1;)f++,n(_,T<y?E:O,y,s),y=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[y++]=D[x]||0:(_=[D[x]],y=1)}while((x++<C||_[0]!=null)&&ee--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==eP){for(u=1,ee=g[0];ee>=10;ee/=10,u++);S(h,a+(h.e=u+l*tP-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function y(e,t,n,r){var i,a,o,u,d;if(n==null?n=s:uP(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)d=cP(e.c),d=r==1||r==2&&(o<=c||o>=l)?fP(d,o):pP(d,o,`0`);else if(e=S(new v(e),t,n),a=e.e,d=cP(e.c),u=d.length,r==1||r==2&&(t<=a||a<=c)){for(;u<t;d+=`0`,u++);d=fP(d,a)}else if(t-=o+(r===2&&a>o),d=pP(d,a,`0`),a+1>u){if(--t>0)for(d+=`.`;t--;d+=`0`);}else if(t+=a-u,t>0)for(a+1==u&&(d+=`.`);t--;d+=`0`);return e.s<0&&i?`-`+d:d}function b(e,t){for(var n,r,i=1,a=new v(e[0]);i<e.length;i++)r=new v(e[i]),(!r.s||(n=lP(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function x(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*tP-1)>d?e.c=e.e=null:n<u?e.c=[e.e=0]:(e.e=n,e.c=t),e}r=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,s,c){var l,u=s?o:o.replace(i,``);if(r.test(u))a.s=isNaN(u)?null:u<0?-1:1;else{if(!s&&(u=u.replace(e,function(e,t,n){return l=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!c||c==l?t:e}),c&&(l=c,u=u.replace(t,`$1`).replace(n,`0.$1`)),o!=u))return new v(u,l);if(v.DEBUG)throw Error(QN+`Not a`+(c?` base `+c:``)+` number: `+o);a.s=null}a.c=a.e=null}})();function S(e,t,n,r){var i,a,o,s,c,l,f,p=e.c,m=rP;if(p){out:{for(i=1,s=p[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=tP,o=t,c=p[l=0],f=ZN(c/m[i-o-1]%10);else if(l=XN((a+1)/tP),l>=p.length)if(r){for(;p.length<=l;p.push(0));c=f=0,i=1,a%=tP,o=a-tP+1}else break out;else{for(c=s=p[l],i=1;s>=10;s/=10,i++);a%=tP,o=a-tP+i,f=o<0?0:ZN(c/m[i-o-1]%10)}if(r=r||t<0||p[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(f||r)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:p[l-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,r?(t-=e.e+1,p[0]=m[(tP-t%tP)%tP],e.e=-t||0):p[0]=e.e=0,e;if(a==0?(p.length=l,s=1,l--):(p.length=l+1,s=m[tP-a],p[l]=o>0?ZN(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=p[0];o>=10;o/=10,a++);for(o=p[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,p[0]==eP&&(p[0]=1));break}else{if(p[l]+=s,p[l]!=eP)break;p[l--]=0,s=1}for(a=p.length;p[--a]===0;p.pop());}e.e>d?e.c=e.e=null:e.e<u&&(e.c=[e.e=0])}return e}function C(e){var t,n=e.e;return n===null?e.toString():(t=cP(e.c),t=n<=c||n>=l?fP(t,n):pP(t,n,`0`),e.s<0?`-`+t:t)}return i.absoluteValue=i.abs=function(){var e=new v(this);return e.s<0&&(e.s=1),e},i.comparedTo=function(e,t){return lP(this,new v(e,t))},i.decimalPlaces=i.dp=function(e,t){var n,r,i,a=this;if(e!=null)return uP(e,0,aP),t==null?t=s:uP(t,0,8),S(new v(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-sP(this.e/tP))*tP,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},i.dividedBy=i.div=function(e,n){return t(this,new v(e,n),o,s)},i.dividedToIntegerBy=i.idiv=function(e,n){return t(this,new v(e,n),0,1)},i.exponentiatedBy=i.pow=function(e,t){var n,r,i,o,c,l,u,d,f,p=this;if(e=new v(e),e.c&&!e.isInteger())throw Error(QN+`Exponent not an integer: `+C(e));if(t!=null&&(t=new v(t)),l=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new v(C(p)**(l?e.s*(2-dP(e)):+C(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new v(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return o=p.s<0&&dP(e)?-0:0,p.e>-1&&(o=1/o),new v(u?1/o:o);else m&&(o=XN(m/tP+2));for(l?(n=new v(.5),u&&(e.s=1),d=dP(e)):(i=Math.abs(+C(e)),d=i%2),f=new v(a);;){if(d){if(f=f.times(p),!f.c)break;o?f.c.length>o&&(f.c.length=o):r&&(f=f.mod(t))}if(i){if(i=ZN(i/2),i===0)break;d=i%2}else if(e=e.times(n),S(e,e.e+1,1),e.e>14)d=dP(e);else{if(i=+C(e),i===0)break;d=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}return r?f:(u&&(f=a.div(f)),t?f.mod(t):o?S(f,m,s,c):f)},i.integerValue=function(e){var t=new v(this);return e==null?e=s:uP(e,0,8),S(t,t.e+1,e)},i.isEqualTo=i.eq=function(e,t){return lP(this,new v(e,t))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(e,t){return lP(this,new v(e,t))>0},i.isGreaterThanOrEqualTo=i.gte=function(e,t){return(t=lP(this,new v(e,t)))===1||t===0},i.isInteger=function(){return!!this.c&&sP(this.e/tP)>this.c.length-2},i.isLessThan=i.lt=function(e,t){return lP(this,new v(e,t))<0},i.isLessThanOrEqualTo=i.lte=function(e,t){return(t=lP(this,new v(e,t)))===-1||t===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(e,t){var n,r,i,a,o=this,c=o.s;if(e=new v(e,t),t=e.s,!c||!t)return new v(NaN);if(c!=t)return e.s=-t,o.plus(e);var l=o.e/tP,u=e.e/tP,d=o.c,f=e.c;if(!l||!u){if(!d||!f)return d?(e.s=-t,e):new v(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new v(d[0]?o:s==3?-0:0)}if(l=sP(l),u=sP(u),d=d.slice(),c=l-u){for((a=c<0)?(c=-c,i=d):(u=l,i=f),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(a=(c=d.length)<(t=f.length))?c:t,c=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=eP-1;r>c;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=eP}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?x(e,d,u):(e.s=s==3?-1:1,e.c=[e.e=0],e)},i.modulo=i.mod=function(e,n){var r,i,a=this;return e=new v(e,n),!a.c||!e.s||e.c&&!e.c[0]?new v(NaN):!e.c||a.c&&!a.c[0]?new v(a):(p==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,p),e=a.minus(r.times(e)),!e.c[0]&&p==1&&(e.s=a.s),e)},i.multipliedBy=i.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,y=_.c,b=(e=new v(e,t)).c;if(!y||!b||!y[0]||!b[0])return!_.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=_.s,!y||!b?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=sP(_.e/tP)+sP(e.e/tP),e.s*=_.s,c=y.length,d=b.length,c<d&&(m=y,y=b,b=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=eP,g=iP,i=d;--i>=0;){for(n=0,f=b[i]%g,p=b[i]/g|0,o=c,a=i+o;a>i;)l=y[--o]%g,u=y[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),x(e,m,r)},i.negated=function(){var e=new v(this);return e.s=-e.s||null,e},i.plus=function(e,t){var n,r=this,i=r.s;if(e=new v(e,t),t=e.s,!i||!t)return new v(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/tP,o=e.e/tP,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new v(i/0);if(!s[0]||!c[0])return c[0]?e:new v(s[0]?r:i*0)}if(a=sP(a),o=sP(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/eP|0,s[t]=eP===s[t]?0:s[t]%eP;return i&&(s=[i].concat(s),++o),x(e,s,o)},i.precision=i.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return uP(e,1,aP),t==null?t=s:uP(t,0,8),S(new v(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*tP+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},i.shiftedBy=function(e){return uP(e,-nP,nP),this.times(`1e`+e)},i.squareRoot=i.sqrt=function(){var e,n,r,i,a,c=this,l=c.c,u=c.s,d=c.e,f=o+4,p=new v(`0.5`);if(u!==1||!l||!l[0])return new v(!u||u<0&&(!l||l[0])?NaN:l?c:1/0);if(u=Math.sqrt(+C(c)),u==0||u==1/0?(n=cP(l),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=sP((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new v(n)):r=new v(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(c,a,f,1))),cP(a.c).slice(0,u)===(n=cP(r.c)).slice(0,u))if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(S(a,a.e+o+2,0),a.times(a).eq(c))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(S(r,r.e+o+2,1),e=!r.times(r).eq(c));break}}return S(r,r.e+o+1,s,e)},i.toExponential=function(e,t){return e!=null&&(uP(e,0,aP),e++),y(this,e,t,1)},i.toFixed=function(e,t){return e!=null&&(uP(e,0,aP),e=e+this.e+1),y(this,e,t)},i.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=h;else if(typeof n!=`object`)throw Error(QN+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,o=r.split(`.`),s=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||``,u=o[0],d=o[1],f=i.s<0,p=f?u.slice(1):u,m=p.length;if(c&&(a=s,s=c,c=a,m-=a),s>0&&m>0){for(a=m%s||s,u=p.substr(0,a);a<m;a+=s)u+=l+p.substr(a,s);c>0&&(u+=l+p.slice(a)),f&&(u=`-`+u)}r=d?u+(n.decimalSeparator||``)+((c=+n.fractionGroupSize)?d.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):d):u}return(n.prefix||``)+r+(n.suffix||``)},i.toFraction=function(e){var n,r,i,o,c,l,u,f,p,m,h,g,_=this,y=_.c;if(e!=null&&(u=new v(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(a)))throw Error(QN+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+C(u));if(!y)return new v(_);for(n=new v(a),p=r=new v(a),i=f=new v(a),g=cP(y),c=n.e=g.length-_.e-1,n.c[0]=rP[(l=c%tP)<0?tP+l:l],e=!e||u.comparedTo(n)>0?c>0?n:p:u,l=d,d=1/0,u=new v(g),f.c[0]=0;m=t(u,n,0,1),o=r.plus(m.times(i)),o.comparedTo(e)!=1;)r=i,i=o,p=f.plus(m.times(o=p)),f=o,n=u.minus(m.times(o=n)),u=o;return o=t(e.minus(r),i,0,1),f=f.plus(o.times(p)),r=r.plus(o.times(i)),f.s=p.s=_.s,c*=2,h=t(p,i,c,s).minus(_).abs().comparedTo(t(f,r,c,s).minus(_).abs())<1?[p,i]:[f,r],d=l,h},i.toNumber=function(){return+C(this)},i.toPrecision=function(e,t){return e!=null&&uP(e,1,aP),y(this,e,t,2)},i.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=c||a>=l?fP(cP(r.c),a):pP(cP(r.c),a,`0`):e===10&&_?(r=S(new v(r),o+a+1,s),t=pP(cP(r.c),r.e,`0`)):(uP(e,2,g.length,`Base`),t=n(pP(cP(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},i.valueOf=i.toJSON=function(){return C(this)},i._isBigNumber=!0,i[Symbol.toStringTag]=`BigNumber`,i[Symbol.for(`nodejs.util.inspect.custom`)]=i.valueOf,e!=null&&v.set(e),v}function sP(e){var t=e|0;return e>0||e===t?t:t-1}function cP(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=tP-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function lP(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function uP(e,t,n,r){if(e<t||e>n||e!==ZN(e))throw Error(QN+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function dP(e){var t=e.c.length-1;return sP(e.e/tP)==t&&e.c[t]%2!=0}function fP(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function pP(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}var mP=oP(),hP=24,gP=32,_P=typeof globalThis<`u`&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues==`function`?()=>{let e=new Uint32Array(1);return globalThis.crypto.getRandomValues(e),e[0]/4294967296}:Math.random,vP=(e=4,t=_P)=>{let n=``;for(;n.length<e;)n+=Math.floor(t()*36).toString(36);return n};function yP(e){let t=new mP(0);for(let n of e.values())t=t.multipliedBy(256).plus(n);return t}var bP=(e=``)=>yP(JN(new TextEncoder().encode(e))).toString(36).slice(1),xP=Array.from({length:26},(e,t)=>String.fromCharCode(t+97)),SP=e=>xP[Math.floor(e()*xP.length)],CP=({globalObj:e=typeof global<`u`?global:typeof window<`u`?window:{},random:t=_P}={})=>{let n=Object.keys(e).toString();return bP(n.length?n+vP(gP,t):vP(gP,t)).substring(0,gP)},wP=e=>()=>e++,TP=476782367,EP=DP(({random:e=_P,counter:t=wP(Math.floor(e()*TP)),length:n=hP,fingerprint:r=CP({random:e})}={})=>{if(n>gP)throw Error(`Length must be between 2 and ${gP}. Received: ${n}`);return function(){let i=SP(e),a=Date.now().toString(36),o=t().toString(36);return`${i+bP(`${a+vP(n,e)+o+r}`).substring(1,n)}`}});function DP(e){let t;return()=>(t||=e(),t())}var OP=d(),kP=k({type:s(`text`),text:y(),state:v([`streaming`,`done`]).optional(),providerMetadata:OP.optional()}),AP=k({type:s(`reasoning`),text:y(),state:v([`streaming`,`done`]).optional(),providerMetadata:OP.optional()}),jP=k({type:y().regex(/^tool-/),toolCallId:y()}),MP=jP.extend({state:s(`input-streaming`),input:d().optional(),providerExecuted:r().optional()}),NP=jP.extend({state:s(`input-available`),input:d(),providerExecuted:r().optional(),callProviderMetadata:OP.optional()}),PP=jP.extend({state:s(`output-available`),input:d(),output:d(),providerExecuted:r().optional(),callProviderMetadata:OP.optional(),preliminary:r().optional()}),FP=jP.extend({state:s(`output-error`),input:d().optional(),rawInput:d().optional(),errorText:y(),providerExecuted:r().optional(),callProviderMetadata:OP.optional()}),IP=k({id:y(),approved:r().optional(),reason:y().optional()}),LP=k({id:y(),approved:r(),reason:y().optional()}),RP=p(`state`,[MP,NP,PP,FP,jP.extend({state:s(`approval-requested`),input:d(),callProviderMetadata:OP.optional(),providerExecuted:r().optional(),approval:IP}),jP.extend({state:s(`approval-responded`),input:d(),callProviderMetadata:OP.optional(),providerExecuted:r().optional(),approval:LP}),jP.extend({state:s(`output-denied`),input:d(),callProviderMetadata:OP.optional(),providerExecuted:r().optional(),approval:LP})]),zP=k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y()}),BP=c([kP,AP,RP,p(`state`,[zP.extend({state:s(`input-streaming`),input:d().optional()}),zP.extend({state:s(`input-available`),input:d(),callProviderMetadata:OP.optional()}),zP.extend({state:s(`output-available`),input:d(),output:d(),callProviderMetadata:OP.optional(),preliminary:r().optional()}),zP.extend({state:s(`output-error`),input:d(),errorText:y()}),zP.extend({state:s(`approval-requested`),input:d(),callProviderMetadata:OP.optional(),approval:IP}),zP.extend({state:s(`approval-responded`),input:d(),callProviderMetadata:OP.optional(),approval:LP}),zP.extend({state:s(`output-denied`),input:d(),callProviderMetadata:OP.optional(),approval:LP})]),k({type:s(`step-start`)}),k({type:s(`source-url`),sourceId:y(),url:y(),title:y().optional(),providerMetadata:OP.optional()}),k({type:s(`source-document`),sourceId:y(),mediaType:y(),title:y(),filename:y().optional(),providerMetadata:OP.optional()}),k({type:s(`file`),mediaType:y(),filename:y().optional(),url:y().optional(),data:y().optional(),providerMetadata:OP.optional()}),k({type:y().regex(/^data-/),id:y().optional(),data:d()})]),VP=k({id:y(),role:v([`system`,`user`,`assistant`]),metadata:d().optional(),parts:E(BP)});function HP(e){return typeof e==`object`&&!!e&&`ollamaBaseUrl`in e&&!(`baseUrl`in e)}function UP(e){let{ollamaBaseUrl:t,...n}=e;return{...n,baseUrl:t}}function WP(e){return typeof e==`object`&&!!e&&`toolCallMessages`in e&&`parts`in e}function GP(e){if(!WP(e))return e;let t=e.parts,n=[];for(let e of t)if(e.type===`text`){let t=e.text;n.push({type:`text`,text:t})}else if(e.type===`tool`){let t=e.toolCallMessages;for(let e of t){let t=e.toolCallId,r=e.toolName,i=e.args,a=e.isCompleted,o=e.llmResult,s=e.additionalData,c={toolCallId:t,toolName:r,args:i,state:a?`result`:`call`,result:o};n.push({type:`tool-invocation`,toolInvocation:c,additionalData:s,isCompleted:a})}}return{parts:n}}function KP(e){if(typeof e!=`object`||!e||!(`analysisResults`in e))return!1;let t=e.analysisResults;return Array.isArray(t)?t.some(e=>e&&typeof e==`object`&&`streamMessage`in e?WP(e.streamMessage):!1):!1}function qP(e){if(!KP(e))return e;let t=e,n=t.analysisResults.map(e=>{if(e&&typeof e==`object`&&`streamMessage`in e){let t=e.streamMessage;if(WP(t))return{...e,streamMessage:GP(t)}}return e});return{...t,analysisResults:n}}function JP(e){return typeof e==`object`&&!!e}function YP(e){if(!JP(e))return!1;let t=e,n=`uiMessages`in t,r=`analysisResults`in t,i=`toolAdditionalData`in t;return!n||r||i}function XP(e){let t={},n=e.errorMessage,r=JP(n)?n.error:void 0;return typeof r==`string`&&(t.errorMessage={error:r}),typeof e.isCompleted==`boolean`&&(t.isCompleted=e.isCompleted),Object.keys(t).length>0?t:void 0}function ZP(e,t){if(!t)return e;let n=JP(e.metadata)?e.metadata:{},r=JP(n.sqlrooms)?n.sqlrooms:{};return{...e,metadata:{...n,sqlrooms:{...r,...t}}}}function QP(e){let t={...e};delete t.toolAdditionalData;let n=t.analysisResults||[],r=t.uiMessages||[],{analysisResults:i,...a}=t,o=[...r],s=[],c=!(`uiMessages`in e);for(let e of n){if(!JP(e))continue;let t=e.id||``,n=e.prompt||``,r=(e.streamMessage||{}).parts||[],i=XP(e);if(!c){let e=o.findIndex(e=>e.id===t&&e.role===`user`);if(e!==-1){let t=o[e];if(!t)continue;o[e]=ZP(t,i)}continue}n&&s.push(ZP({id:t,role:`user`,parts:[{type:`text`,text:n}]},i));let a=[];for(let e of r)if(e.type===`text`){let t=e.text;a.push({type:`text`,text:t})}else if(e.type===`tool-invocation`){let t=e.toolInvocation;if(JP(t)){let e=t.toolCallId,n=t.toolName,r=t.state,i=t.args,o=t.result;r===`call`?a.push({type:`tool-${n}`,toolCallId:e,state:`input-available`,input:i}):a.push({type:`tool-${n}`,toolCallId:e,state:`output-available`,input:i,output:o})}}a.length>0&&s.push({id:`${t}-assistant`,role:`assistant`,parts:a})}return{...a,uiMessages:[...o,...s],prompt:typeof a.prompt==`string`?a.prompt:``,isRunning:!1}}var $P=k({error:y()});k({id:y(),prompt:y(),errorMessage:$P.optional(),isCompleted:r()});var eF=k({kind:y(),id:y(),title:y(),type:y().optional(),subtitle:y().optional()}).passthrough(),tF=i(e=>{if(e&&typeof e==`object`&&!Array.isArray(e)&&`kind`in e&&`id`in e&&`title`in e&&!(`items`in e)){let{capturedAt:t,...n}=e;return{items:[n],capturedAt:typeof t==`number`?t:0}}return e},k({items:E(eF),primaryItemId:y().optional(),primaryItemKind:y().optional(),capturedAt:_()}).passthrough());function nF(e,t){return e&&typeof e==`object`&&t in e&&typeof e[t]==`string`?e[t]:void 0}function rF(e){if(!e||typeof e!=`object`)return[];if(`items`in e&&Array.isArray(e.items))return e.items.map(e=>eF.safeParse(e)).filter(e=>e.success).map(e=>e.data);let t=eF.safeParse(e);return t.success?[t.data]:[]}function iF(e){let t=rF(e);if(t.length===0)return;let n=nF(e,`primaryItemId`),r=nF(e,`primaryItemKind`);return n&&r?t.find(e=>e.id===n&&e.kind===r)??t[0]:n?t.find(e=>e.id===n)??t[0]:t[0]}function aF(e,t){let n=tF.safeParse(e),r=n.success?n.data:void 0,i=rF(e).filter(e=>!(e.kind===t.kind&&e.id===t.id));return{...r??{},items:[t,...i],primaryItemId:t.id,primaryItemKind:t.kind,capturedAt:r?.capturedAt??Date.now()}}var oF=k({agentName:y().optional(),parentToolCallId:y(),availableTools:E(k({name:y(),description:y().optional(),hasExecute:r().optional(),hasRenderer:r().optional(),needsApproval:r().optional()})),settings:k({maxSteps:_().int().optional(),model:y().optional(),provider:y().optional()}).optional(),startedAt:_()}).passthrough(),sF=i(e=>{let t=e;return HP(t)&&(t=UP(t)),KP(t)&&(t=qP(t)),YP(t)&&(t=QP(t)),t},k({id:y(),name:y(),modelProvider:y(),model:y(),customModelName:y().optional(),baseUrl:y().optional(),createdAt:te().optional(),uiMessages:E(VP),messagesRevision:_().optional().default(0),prompt:y().default(``),draftContextItemIds:E(y()).optional(),isRunning:r().default(!1),lastOpenedAt:_().optional(),runContext:tF.optional(),agentProgress:b(y(),E(d())).optional(),agentSnapshots:b(y(),oF).optional()})),cF=k({sourceSessionId:y(),sourceMessageId:y().optional(),sourceTurnId:y().optional(),sourceMessageIndex:_().int().nonnegative().optional(),legacySourceAnalysisResultId:y().optional(),sourceSessionNameAtFork:y(),createdAt:_()}),lF=k({sessions:E(sF),currentSessionId:y().optional(),openSessionTabs:E(y()).optional(),sessionForks:b(y(),cF).default({})});function uF(e){let t=EP();return{sessions:[{id:t,name:`Untitled`,modelProvider:`openai`,model:`gpt-4.1`,createdAt:new Date,uiMessages:[],messagesRevision:0,prompt:``,isRunning:!1,lastOpenedAt:Date.now()}],currentSessionId:t,openSessionTabs:[t],sessionForks:{},...e}}var dF=`vercel.ai.error`,fF=Symbol.for(dF),pF,mF,hF=class e extends (mF=Error,pF=fF,mF){constructor({name:e,message:t,cause:n}){super(t),this[pF]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,dF)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},gF=`AI_APICallError`,_F=`vercel.ai.error.${gF}`,vF=Symbol.for(_F),yF,bF,xF=class extends (bF=hF,yF=vF,bF){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:gF,message:e,cause:o}),this[yF]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return hF.hasMarker(e,_F)}},SF=`AI_EmptyResponseBodyError`,CF=`vercel.ai.error.${SF}`,wF=Symbol.for(CF),TF,EF,DF=class extends (EF=hF,TF=wF,EF){constructor({message:e=`Empty response body`}={}){super({name:SF,message:e}),this[TF]=!0}static isInstance(e){return hF.hasMarker(e,CF)}};function OF(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var kF=`AI_InvalidArgumentError`,AF=`vercel.ai.error.${kF}`,jF=Symbol.for(AF),MF,NF,PF=class extends (NF=hF,MF=jF,NF){constructor({message:e,cause:t,argument:n}){super({name:kF,message:e,cause:t}),this[MF]=!0,this.argument=n}static isInstance(e){return hF.hasMarker(e,AF)}},FF=`AI_InvalidPromptError`,IF=`vercel.ai.error.${FF}`,LF=Symbol.for(IF),RF,zF,BF=class extends (zF=hF,RF=LF,zF){constructor({prompt:e,message:t,cause:n}){super({name:FF,message:`Invalid prompt: ${t}`,cause:n}),this[RF]=!0,this.prompt=e}static isInstance(e){return hF.hasMarker(e,IF)}},VF=`AI_JSONParseError`,HF=`vercel.ai.error.${VF}`,UF=Symbol.for(HF),WF,GF,KF=class extends (GF=hF,WF=UF,GF){constructor({text:e,cause:t}){super({name:VF,message:`JSON parsing failed: Text: ${e}.
|
|
80
|
+
Error message: ${OF(t)}`,cause:t}),this[WF]=!0,this.text=e}static isInstance(e){return hF.hasMarker(e,HF)}},qF=`AI_TypeValidationError`,JF=`vercel.ai.error.${qF}`,YF=Symbol.for(JF),XF,ZF,QF=class e extends (ZF=hF,XF=YF,ZF){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:qF,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
81
|
+
Error message: ${OF(t)}`,cause:t}),this[XF]=!0,this.value=e,this.context=n}static isInstance(e){return hF.hasMarker(e,JF)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},$F=`AI_UnsupportedFunctionalityError`,eI=`vercel.ai.error.${$F}`,tI=Symbol.for(eI),nI,rI,iI=class extends (rI=hF,nI=tI,rI){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:$F,message:t}),this[nI]=!0,this.functionality=e}static isInstance(e){return hF.hasMarker(e,eI)}},aI;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(aI||={});var oI;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(oI||={});var q=aI.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),sI=e=>{switch(typeof e){case`undefined`:return q.undefined;case`string`:return q.string;case`number`:return Number.isNaN(e)?q.nan:q.number;case`boolean`:return q.boolean;case`function`:return q.function;case`bigint`:return q.bigint;case`symbol`:return q.symbol;case`object`:return Array.isArray(e)?q.array:e===null?q.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?q.promise:typeof Map<`u`&&e instanceof Map?q.map:typeof Set<`u`&&e instanceof Set?q.set:typeof Date<`u`&&e instanceof Date?q.date:q.object;default:return q.unknown}},J=aI.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),cI=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,aI.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};cI.create=e=>new cI(e);var lI=(e,t)=>{let n;switch(e.code){case J.invalid_type:n=e.received===q.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case J.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,aI.jsonStringifyReplacer)}`;break;case J.unrecognized_keys:n=`Unrecognized key(s) in object: ${aI.joinValues(e.keys,`, `)}`;break;case J.invalid_union:n=`Invalid input`;break;case J.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${aI.joinValues(e.options)}`;break;case J.invalid_enum_value:n=`Invalid enum value. Expected ${aI.joinValues(e.options)}, received '${e.received}'`;break;case J.invalid_arguments:n=`Invalid function arguments`;break;case J.invalid_return_type:n=`Invalid function return type`;break;case J.invalid_date:n=`Invalid date`;break;case J.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:aI.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case J.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case J.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case J.custom:n=`Invalid input`;break;case J.invalid_intersection_types:n=`Intersection results could not be merged`;break;case J.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case J.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,aI.assertNever(e)}return{message:n}},uI=lI;function dI(){return uI}var fI=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function Y(e,t){let n=dI(),r=fI({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===lI?void 0:lI].filter(e=>!!e)});e.common.issues.push(r)}var pI=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return X;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return X;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},X=Object.freeze({status:`aborted`}),mI=e=>({status:`dirty`,value:e}),hI=e=>({status:`valid`,value:e}),gI=e=>e.status===`aborted`,_I=e=>e.status===`dirty`,vI=e=>e.status===`valid`,yI=e=>typeof Promise<`u`&&e instanceof Promise,Z;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(Z||={});var bI=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},xI=(e,t)=>{if(vI(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new cI(e.common.issues);return this._error=t,this._error}}};function SI(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var CI=class{get description(){return this._def.description}_getType(e){return sI(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:sI(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pI,ctx:{common:e.parent.common,data:e.data,parsedType:sI(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(yI(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sI(e)};return xI(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sI(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return vI(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>vI(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:sI(e)},r=this._parse({data:e,path:n.path,parent:n});return xI(n,await(yI(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:J.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new EL({schema:this,typeName:Q.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return DL.create(this,this._def)}nullable(){return OL.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return sL.create(this)}promise(){return TL.create(this,this._def)}or(e){return uL.create([this,e],this._def)}and(e){return mL.create(this,e,this._def)}transform(e){return new EL({...SI(this._def),schema:this,typeName:Q.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new kL({...SI(this._def),innerType:this,defaultValue:t,typeName:Q.ZodDefault})}brand(){return new ML({typeName:Q.ZodBranded,type:this,...SI(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new AL({...SI(this._def),innerType:this,catchValue:t,typeName:Q.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return NL.create(this,e)}readonly(){return PL.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wI=/^c[^\s-]{8,}$/i,TI=/^[0-9a-z]+$/,EI=/^[0-9A-HJKMNP-TV-Z]{26}$/i,DI=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,OI=/^[a-z0-9_-]{21}$/i,kI=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,AI=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,jI=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,MI=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,NI,PI=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FI=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,II=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,LI=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,RI=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,zI=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,BI=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,VI=RegExp(`^${BI}$`);function HI(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function UI(e){return RegExp(`^${HI(e)}$`)}function WI(e){let t=`${BI}T${HI(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function GI(e,t){return!!((t===`v4`||!t)&&PI.test(e)||(t===`v6`||!t)&&II.test(e))}function KI(e,t){if(!kI.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function qI(e,t){return!!((t===`v4`||!t)&&FI.test(e)||(t===`v6`||!t)&&LI.test(e))}var JI=class e extends CI{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==q.string){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.string,received:t.parsedType}),X}let t=new pI,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),Y(n,{code:J.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),Y(n,{code:J.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?Y(n,{code:J.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&Y(n,{code:J.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)jI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`email`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)NI||=new RegExp(MI,`u`),NI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`emoji`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)DI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`uuid`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)OI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`nanoid`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)wI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`cuid`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)TI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`cuid2`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)EI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`ulid`,code:J.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),Y(n,{validation:`url`,code:J.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`regex`,code:J.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),Y(n,{code:J.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),Y(n,{code:J.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),Y(n,{code:J.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?WI(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{code:J.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?VI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{code:J.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?UI(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{code:J.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?AI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`duration`,code:J.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?GI(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`ip`,code:J.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?KI(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`jwt`,code:J.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?qI(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`cidr`,code:J.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?RI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`base64`,code:J.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?zI.test(e.data)||(n=this._getOrReturnCtx(e,n),Y(n,{validation:`base64url`,code:J.invalid_string,message:r.message}),t.dirty()):aI.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:J.invalid_string,...Z.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...Z.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...Z.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...Z.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...Z.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...Z.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...Z.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...Z.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...Z.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Z.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...Z.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...Z.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...Z.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...Z.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...Z.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...Z.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...Z.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...Z.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...Z.errToObj(t)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};JI.create=e=>new JI({checks:[],typeName:Q.ZodString,coerce:e?.coerce??!1,...SI(e)});function YI(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var XI=class e extends CI{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==q.number){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.number,received:t.parsedType}),X}let t,n=new pI;for(let r of this._def.checks)r.kind===`int`?aI.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Y(t,{code:J.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:J.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:J.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?YI(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),Y(t,{code:J.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Y(t,{code:J.not_finite,message:r.message}),n.dirty()):aI.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,Z.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Z.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Z.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Z.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Z.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:Z.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Z.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:Z.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:Z.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:Z.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&aI.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};XI.create=e=>new XI({checks:[],typeName:Q.ZodNumber,coerce:e?.coerce||!1,...SI(e)});var ZI=class e extends CI{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==q.bigint)return this._getInvalidInput(e);let t,n=new pI;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:J.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:J.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:J.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):aI.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.bigint,received:t.parsedType}),X}gte(e,t){return this.setLimit(`min`,e,!0,Z.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,Z.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,Z.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,Z.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:Z.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:Z.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ZI.create=e=>new ZI({checks:[],typeName:Q.ZodBigInt,coerce:e?.coerce??!1,...SI(e)});var QI=class extends CI{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==q.boolean){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.boolean,received:t.parsedType}),X}return hI(e.data)}};QI.create=e=>new QI({typeName:Q.ZodBoolean,coerce:e?.coerce||!1,...SI(e)});var $I=class e extends CI{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==q.date){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.date,received:t.parsedType}),X}if(Number.isNaN(e.data.getTime()))return Y(this._getOrReturnCtx(e),{code:J.invalid_date}),X;let t=new pI,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),Y(n,{code:J.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),Y(n,{code:J.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):aI.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:Z.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:Z.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};$I.create=e=>new $I({checks:[],coerce:e?.coerce||!1,typeName:Q.ZodDate,...SI(e)});var eL=class extends CI{_parse(e){if(this._getType(e)!==q.symbol){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.symbol,received:t.parsedType}),X}return hI(e.data)}};eL.create=e=>new eL({typeName:Q.ZodSymbol,...SI(e)});var tL=class extends CI{_parse(e){if(this._getType(e)!==q.undefined){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.undefined,received:t.parsedType}),X}return hI(e.data)}};tL.create=e=>new tL({typeName:Q.ZodUndefined,...SI(e)});var nL=class extends CI{_parse(e){if(this._getType(e)!==q.null){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.null,received:t.parsedType}),X}return hI(e.data)}};nL.create=e=>new nL({typeName:Q.ZodNull,...SI(e)});var rL=class extends CI{constructor(){super(...arguments),this._any=!0}_parse(e){return hI(e.data)}};rL.create=e=>new rL({typeName:Q.ZodAny,...SI(e)});var iL=class extends CI{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hI(e.data)}};iL.create=e=>new iL({typeName:Q.ZodUnknown,...SI(e)});var aL=class extends CI{_parse(e){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.never,received:t.parsedType}),X}};aL.create=e=>new aL({typeName:Q.ZodNever,...SI(e)});var oL=class extends CI{_parse(e){if(this._getType(e)!==q.undefined){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.void,received:t.parsedType}),X}return hI(e.data)}};oL.create=e=>new oL({typeName:Q.ZodVoid,...SI(e)});var sL=class e extends CI{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==q.array)return Y(t,{code:J.invalid_type,expected:q.array,received:t.parsedType}),X;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(Y(t,{code:e?J.too_big:J.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(Y(t,{code:J.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(Y(t,{code:J.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new bI(t,e,t.path,n)))).then(e=>pI.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new bI(t,e,t.path,n)));return pI.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:Z.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:Z.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:Z.toString(n)}})}nonempty(e){return this.min(1,e)}};sL.create=(e,t)=>new sL({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Q.ZodArray,...SI(t)});function cL(e){if(e instanceof lL){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=DL.create(cL(r))}return new lL({...e._def,shape:()=>t})}else if(e instanceof sL)return new sL({...e._def,type:cL(e.element)});else if(e instanceof DL)return DL.create(cL(e.unwrap()));else if(e instanceof OL)return OL.create(cL(e.unwrap()));else if(e instanceof hL)return hL.create(e.items.map(e=>cL(e)));else return e}var lL=class e extends CI{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=aI.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==q.object){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.object,received:t.parsedType}),X}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof aL&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new bI(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof aL){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(Y(n,{code:J.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new bI(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>pI.mergeObjectSync(t,e)):pI.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return Z.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:Z.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Q.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of aI.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of aI.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return cL(this)}partial(t){let n={};for(let e of aI.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of aI.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof DL;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return SL(aI.objectKeys(this.shape))}};lL.create=(e,t)=>new lL({shape:()=>e,unknownKeys:`strip`,catchall:aL.create(),typeName:Q.ZodObject,...SI(t)}),lL.strictCreate=(e,t)=>new lL({shape:()=>e,unknownKeys:`strict`,catchall:aL.create(),typeName:Q.ZodObject,...SI(t)}),lL.lazycreate=(e,t)=>new lL({shape:e,unknownKeys:`strip`,catchall:aL.create(),typeName:Q.ZodObject,...SI(t)});var uL=class extends CI{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new cI(e.ctx.common.issues));return Y(t,{code:J.invalid_union,unionErrors:n}),X}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new cI(e));return Y(t,{code:J.invalid_union,unionErrors:i}),X}}get options(){return this._def.options}};uL.create=(e,t)=>new uL({options:e,typeName:Q.ZodUnion,...SI(t)});var dL=e=>e instanceof bL?dL(e.schema):e instanceof EL?dL(e.innerType()):e instanceof xL?[e.value]:e instanceof CL?e.options:e instanceof wL?aI.objectValues(e.enum):e instanceof kL?dL(e._def.innerType):e instanceof tL?[void 0]:e instanceof nL?[null]:e instanceof DL?[void 0,...dL(e.unwrap())]:e instanceof OL?[null,...dL(e.unwrap())]:e instanceof ML||e instanceof PL?dL(e.unwrap()):e instanceof AL?dL(e._def.innerType):[],fL=class e extends CI{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==q.object)return Y(t,{code:J.invalid_type,expected:q.object,received:t.parsedType}),X;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(Y(t,{code:J.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),X)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=dL(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Q.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...SI(r)})}};function pL(e,t){let n=sI(e),r=sI(t);if(e===t)return{valid:!0,data:e};if(n===q.object&&r===q.object){let n=aI.objectKeys(t),r=aI.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=pL(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===q.array&&r===q.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pL(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===q.date&&r===q.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var mL=class extends CI{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(gI(e)||gI(r))return X;let i=pL(e.value,r.value);return i.valid?((_I(e)||_I(r))&&t.dirty(),{status:t.value,value:i.data}):(Y(n,{code:J.invalid_intersection_types}),X)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};mL.create=(e,t,n)=>new mL({left:e,right:t,typeName:Q.ZodIntersection,...SI(n)});var hL=class e extends CI{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==q.array)return Y(n,{code:J.invalid_type,expected:q.array,received:n.parsedType}),X;if(n.data.length<this._def.items.length)return Y(n,{code:J.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),X;!this._def.rest&&n.data.length>this._def.items.length&&(Y(n,{code:J.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new bI(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>pI.mergeArray(t,e)):pI.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};hL.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new hL({items:e,typeName:Q.ZodTuple,rest:null,...SI(t)})};var gL=class e extends CI{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==q.object)return Y(n,{code:J.invalid_type,expected:q.object,received:n.parsedType}),X;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new bI(n,e,n.path,e)),value:a._parse(new bI(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?pI.mergeObjectAsync(t,r):pI.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof CI?new e({keyType:t,valueType:n,typeName:Q.ZodRecord,...SI(r)}):new e({keyType:JI.create(),valueType:t,typeName:Q.ZodRecord,...SI(n)})}},_L=class extends CI{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==q.map)return Y(n,{code:J.invalid_type,expected:q.map,received:n.parsedType}),X;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new bI(n,e,n.path,[a,`key`])),value:i._parse(new bI(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return X;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return X;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};_L.create=(e,t,n)=>new _L({valueType:t,keyType:e,typeName:Q.ZodMap,...SI(n)});var vL=class e extends CI{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==q.set)return Y(n,{code:J.invalid_type,expected:q.set,received:n.parsedType}),X;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(Y(n,{code:J.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(Y(n,{code:J.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return X;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new bI(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:Z.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:Z.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};vL.create=(e,t)=>new vL({valueType:e,minSize:null,maxSize:null,typeName:Q.ZodSet,...SI(t)});var yL=class e extends CI{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==q.function)return Y(t,{code:J.invalid_type,expected:q.function,received:t.parsedType}),X;function n(e,n){return fI({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dI(),lI].filter(e=>!!e),issueData:{code:J.invalid_arguments,argumentsError:n}})}function r(e,n){return fI({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,dI(),lI].filter(e=>!!e),issueData:{code:J.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof TL){let e=this;return hI(async function(...t){let o=new cI([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return hI(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new cI([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new cI([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:hL.create(t).rest(iL.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||hL.create([]).rest(iL.create()),returns:n||iL.create(),typeName:Q.ZodFunction,...SI(r)})}},bL=class extends CI{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};bL.create=(e,t)=>new bL({getter:e,typeName:Q.ZodLazy,...SI(t)});var xL=class extends CI{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return Y(t,{received:t.data,code:J.invalid_literal,expected:this._def.value}),X}return{status:`valid`,value:e.data}}get value(){return this._def.value}};xL.create=(e,t)=>new xL({value:e,typeName:Q.ZodLiteral,...SI(t)});function SL(e,t){return new CL({values:e,typeName:Q.ZodEnum,...SI(t)})}var CL=class e extends CI{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return Y(t,{expected:aI.joinValues(n),received:t.parsedType,code:J.invalid_type}),X}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return Y(t,{received:t.data,code:J.invalid_enum_value,options:n}),X}return hI(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};CL.create=SL;var wL=class extends CI{_parse(e){let t=aI.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==q.string&&n.parsedType!==q.number){let e=aI.objectValues(t);return Y(n,{expected:aI.joinValues(e),received:n.parsedType,code:J.invalid_type}),X}if(this._cache||=new Set(aI.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=aI.objectValues(t);return Y(n,{received:n.data,code:J.invalid_enum_value,options:e}),X}return hI(e.data)}get enum(){return this._def.values}};wL.create=(e,t)=>new wL({values:e,typeName:Q.ZodNativeEnum,...SI(t)});var TL=class extends CI{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==q.promise&&t.common.async===!1?(Y(t,{code:J.invalid_type,expected:q.promise,received:t.parsedType}),X):hI((t.parsedType===q.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};TL.create=(e,t)=>new TL({type:e,typeName:Q.ZodPromise,...SI(t)});var EL=class extends CI{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{Y(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return X;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?X:r.status===`dirty`||t.value===`dirty`?mI(r.value):r});{if(t.value===`aborted`)return X;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?X:r.status===`dirty`||t.value===`dirty`?mI(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?X:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?X:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!vI(e))return X;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>vI(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):X);aI.assertNever(r)}};EL.create=(e,t,n)=>new EL({schema:e,typeName:Q.ZodEffects,effect:t,...SI(n)}),EL.createWithPreprocess=(e,t,n)=>new EL({schema:t,effect:{type:`preprocess`,transform:e},typeName:Q.ZodEffects,...SI(n)});var DL=class extends CI{_parse(e){return this._getType(e)===q.undefined?hI(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};DL.create=(e,t)=>new DL({innerType:e,typeName:Q.ZodOptional,...SI(t)});var OL=class extends CI{_parse(e){return this._getType(e)===q.null?hI(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};OL.create=(e,t)=>new OL({innerType:e,typeName:Q.ZodNullable,...SI(t)});var kL=class extends CI{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===q.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};kL.create=(e,t)=>new kL({innerType:e,typeName:Q.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...SI(t)});var AL=class extends CI{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return yI(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new cI(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new cI(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};AL.create=(e,t)=>new AL({innerType:e,typeName:Q.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...SI(t)});var jL=class extends CI{_parse(e){if(this._getType(e)!==q.nan){let t=this._getOrReturnCtx(e);return Y(t,{code:J.invalid_type,expected:q.nan,received:t.parsedType}),X}return{status:`valid`,value:e.data}}};jL.create=e=>new jL({typeName:Q.ZodNaN,...SI(e)});var ML=class extends CI{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},NL=class e extends CI{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?X:e.status===`dirty`?(t.dirty(),mI(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?X:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Q.ZodPipeline})}},PL=class extends CI{_parse(e){let t=this._def.innerType._parse(e),n=e=>(vI(e)&&(e.value=Object.freeze(e.value)),e);return yI(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};PL.create=(e,t)=>new PL({innerType:e,typeName:Q.ZodReadonly,...SI(t)}),lL.lazycreate;var Q;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Q||={}),JI.create,XI.create,jL.create,ZI.create,QI.create,$I.create,eL.create,tL.create,nL.create,rL.create,iL.create,aL.create,oL.create,sL.create,lL.create,lL.strictCreate,uL.create,fL.create,mL.create,hL.create,gL.create,_L.create,vL.create,yL.create,bL.create,xL.create,CL.create,wL.create,TL.create,EL.create,DL.create,OL.create,EL.createWithPreprocess,NL.create;var FL=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},IL=10,LL=13,RL=32;function zL(e){}function BL(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=zL,onError:n=zL,onRetry:r=zL,onComment:i}=e,a=[],o=!0,s,c=``,l=0,u;function d(e){if(o&&(o=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),a.length===0){let t=f(e);t!==``&&a.push(t);return}if(e.indexOf(`
|
|
82
|
+
`)===-1&&e.indexOf(`\r`)===-1){a.push(e);return}a.push(e);let t=a.join(``);a.length=0;let n=f(t);n!==``&&a.push(n)}function f(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|
|
83
|
+
`,n);for(;r!==-1;){if(n===r){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0,n=r+1,r=e.indexOf(`
|
|
84
|
+
`,n);continue}let i=e.charCodeAt(n);if(VL(e,n,i)){let i=e.charCodeAt(n+5)===RL?n+6:n+5,a=e.slice(i,r);if(l===0&&e.charCodeAt(r+1)===IL){t({id:s,event:u,data:a}),s=void 0,c=``,u=void 0,n=r+2,r=e.indexOf(`
|
|
85
|
+
`,n);continue}c=l===0?a:`${c}
|
|
86
|
+
${a}`,l++}else HL(e,n,i)?u=e.slice(e.charCodeAt(n+6)===RL?n+7:n+6,r)||void 0:p(e,n,r);n=r+1,r=e.indexOf(`
|
|
87
|
+
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
88
|
+
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;p(e,n,i),n=i+1,e.charCodeAt(n-1)===LL&&e.charCodeAt(n)===IL&&n++}return e.slice(n)}function p(e,t,n){if(t===n){h();return}let r=e.charCodeAt(t);if(VL(e,t,r)){let r=e.charCodeAt(t+5)===RL?t+6:t+5,i=e.slice(r,n);c=l===0?i:`${c}
|
|
89
|
+
${i}`,l++;return}if(HL(e,t,r)){u=e.slice(e.charCodeAt(t+6)===RL?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===RL?t+4:t+3,n);s=r.includes(`\0`)?void 0:r;return}if(r===58){i&&i(e.slice(t,n).slice(e.charCodeAt(t+1)===RL?2:1));return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){m(a,``,a);return}let d=a.slice(0,o),f=a.charCodeAt(o+1)===RL?2:1;m(d,a.slice(o+f),a)}function m(e,t,i){switch(e){case`event`:u=t||void 0;break;case`data`:c=l===0?t:`${c}
|
|
90
|
+
${t}`,l++;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new FL(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new FL(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function h(){l>0&&t({id:s,event:u,data:c}),s=void 0,c=``,l=0,u=void 0}function g(e={}){if(e.consume&&a.length>0){let e=a.join(``);p(e,0,e.length)}o=!0,s=void 0,c=``,l=0,u=void 0,a.length=0}return{feed:d,reset:g}}function VL(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function HL(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var UL=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=BL({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};function WL(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}async function GL(e,t){if(e==null)return Promise.resolve();let n=t?.abortSignal;return new Promise((t,r)=>{if(n?.aborted){r(KL());return}let i=setTimeout(()=>{a(),t()},e),a=()=>{clearTimeout(i),n?.removeEventListener(`abort`,o)},o=()=>{a(),r(KL())};n?.addEventListener(`abort`,o)})}function KL(){return new DOMException(`Delay was aborted`,`AbortError`)}var qL=class{constructor(){this.status={type:`pending`},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise||=new Promise((e,t)=>{this.status.type===`resolved`?e(this.status.value):this.status.type===`rejected`&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise}resolve(e){var t;this.status={type:`resolved`,value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:`rejected`,error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}isResolved(){return this.status.type===`resolved`}isRejected(){return this.status.type===`rejected`}isPending(){return this.status.type===`pending`}};function JL(e){return Object.fromEntries([...e.headers])}var{btoa:YL,atob:XL}=globalThis;function ZL(e){let t=XL(e.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.codePointAt(0))}function QL(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return YL(t)}var $L=`AI_DownloadError`,eR=`vercel.ai.error.${$L}`,tR=Symbol.for(eR),nR,rR,iR=class extends (rR=hF,nR=tR,rR){constructor({url:e,statusCode:t,statusText:n,cause:r,message:i=r==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${r}`}){super({name:$L,message:i,cause:r}),this[nR]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return hF.hasMarker(e,eR)}},aR=2*1024*1024*1024;async function oR({response:e,url:t,maxBytes:n=aR}){let r=e.headers.get(`content-length`);if(r!=null){let e=parseInt(r,10);if(!isNaN(e)&&e>n)throw new iR({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes (Content-Length: ${e}).`})}let i=e.body;if(i==null)return new Uint8Array;let a=i.getReader(),o=[],s=0;try{for(;;){let{done:e,value:r}=await a.read();if(e)break;if(s+=r.length,s>n)throw new iR({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes.`});o.push(r)}}finally{try{await a.cancel()}finally{a.releaseLock()}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}function sR(e){let t;try{t=new URL(e)}catch{throw new iR({url:e,message:`Invalid URL: ${e}`})}if(t.protocol===`data:`)return;if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new iR({url:e,message:`URL scheme must be http, https, or data, got ${t.protocol}`});let n=t.hostname;if(!n)throw new iR({url:e,message:`URL must have a hostname`});if(n===`localhost`||n.endsWith(`.local`)||n.endsWith(`.localhost`))throw new iR({url:e,message:`URL with hostname ${n} is not allowed`});if(n.startsWith(`[`)&&n.endsWith(`]`)){if(uR(n.slice(1,-1)))throw new iR({url:e,message:`URL with IPv6 address ${n} is not allowed`});return}if(cR(n)){if(lR(n))throw new iR({url:e,message:`URL with IP address ${n} is not allowed`});return}}function cR(e){let t=e.split(`.`);return t.length===4?t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e}):!1}function lR(e){let[t,n]=e.split(`.`).map(Number);return t===0||t===10||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===168}function uR(e){let t=e.toLowerCase();if(t===`::1`||t===`::`)return!0;if(t.startsWith(`::ffff:`)){let e=t.slice(7);if(cR(e))return lR(e);let n=e.split(`:`);if(n.length===2){let e=parseInt(n[0],16),t=parseInt(n[1],16);if(!isNaN(e)&&!isNaN(t))return lR(`${e>>8&255}.${e&255}.${t>>8&255}.${t&255}`)}}return!!(t.startsWith(`fc`)||t.startsWith(`fd`)||t.startsWith(`fe80`))}var dR=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new PF({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},fR=dR();function pR(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}function mR(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var hR=[`fetch failed`,`failed to fetch`],gR=[`ConnectionRefused`,`ConnectionClosed`,`FailedToOpenSocket`,`ECONNRESET`,`ECONNREFUSED`,`ETIMEDOUT`,`EPIPE`];function _R(e){if(!(e instanceof Error))return!1;let t=e.code;return!!(typeof t==`string`&&gR.includes(t))}function vR({error:e,url:t,requestBodyValues:n}){if(mR(e))return e;if(e instanceof TypeError&&hR.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new xF({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return _R(e)?new xF({message:`Cannot connect to API: ${e.message}`,cause:e,url:t,requestBodyValues:n,isRetryable:!0}):e}function yR(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function bR(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function xR(e,...t){let n=new Headers(bR(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var SR=`4.0.27`,CR=()=>globalThis.fetch,wR=async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:r,abortSignal:i,fetch:a=CR()})=>{try{let o=await a(e,{method:`GET`,headers:xR(t,`ai-sdk/provider-utils/${SR}`,yR()),signal:i}),s=JL(o);if(!o.ok){let t;try{t=await r({response:o,url:e,requestBodyValues:{}})}catch(t){throw mR(t)||xF.isInstance(t)?t:new xF({message:`Failed to process error response`,cause:t,statusCode:o.status,url:e,responseHeaders:s,requestBodyValues:{}})}throw t.value}try{return await n({response:o,url:e,requestBodyValues:{}})}catch(t){throw t instanceof Error&&(mR(t)||xF.isInstance(t))?t:new xF({message:`Failed to process successful response`,cause:t,statusCode:o.status,url:e,responseHeaders:s,requestBodyValues:{}})}}catch(t){throw vR({error:t,url:e,requestBodyValues:{}})}};function TR(e){return e!=null}function ER({mediaType:e,url:t,supportedUrls:n}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(n).map(([e,t])=>{let n=e.toLowerCase();return n===`*`||n===`*/*`?{mediaTypePrefix:``,regexes:t}:{mediaTypePrefix:n.replace(/\*/,``),regexes:t}}).filter(({mediaTypePrefix:t})=>e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>e.test(t))}function DR({settingValue:e,environmentVariableName:t}){if(typeof e==`string`||!(e!=null||typeof process>`u`)&&(e={}[t],!(e==null||typeof e!=`string`)))return e}var OR=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,kR=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function AR(e){let t=JSON.parse(e);return typeof t!=`object`||!t||OR.test(e)===!1&&kR.test(e)===!1?t:jR(t)}function jR(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function MR(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return AR(e)}try{return AR(e)}finally{Error.stackTraceLimit=t}}function NR(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){e.additionalProperties=!1;let{properties:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=PR(t[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(PR):PR(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(PR)),e.allOf!=null&&(e.allOf=e.allOf.map(PR)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(PR));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=PR(t[e]);return e}function PR(e){return typeof e==`boolean`?e:NR(e)}var FR=Symbol(`Let zodToJsonSchema decide on which parser to use`),IR={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},LR=e=>typeof e==`string`?{...IR,name:e}:{...IR,...e};function RR(){return{}}function zR(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==Q.ZodAny&&(n.items=Az(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function BR(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function VR(){return{type:`boolean`}}function HR(e,t){return Az(e.type._def,t)}var UR=(e,t)=>Az(e.innerType._def,t);function WR(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>WR(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return GR(e)}}var GR=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value;break}return t};function KR(e,t){return{...Az(e.innerType._def,t),default:e.defaultValue()}}function qR(e,t){return t.effectStrategy===`input`?Az(e.schema._def,t):RR()}function JR(e){return{type:`string`,enum:Array.from(e.values)}}var YR=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function XR(e,t){let n=[Az(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Az(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(YR(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function ZR(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var QR=void 0,$R={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(QR===void 0&&(QR=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),QR),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ez(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:iz(n,`email`,r.message,t);break;case`format:idn-email`:iz(n,`idn-email`,r.message,t);break;case`pattern:zod`:az(n,$R.email,r.message,t);break}break;case`url`:iz(n,`uri`,r.message,t);break;case`uuid`:iz(n,`uuid`,r.message,t);break;case`regex`:az(n,r.regex,r.message,t);break;case`cuid`:az(n,$R.cuid,r.message,t);break;case`cuid2`:az(n,$R.cuid2,r.message,t);break;case`startsWith`:az(n,RegExp(`^${tz(r.value,t)}`),r.message,t);break;case`endsWith`:az(n,RegExp(`${tz(r.value,t)}$`),r.message,t);break;case`datetime`:iz(n,`date-time`,r.message,t);break;case`date`:iz(n,`date`,r.message,t);break;case`time`:iz(n,`time`,r.message,t);break;case`duration`:iz(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:az(n,RegExp(tz(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&iz(n,`ipv4`,r.message,t),r.version!==`v4`&&iz(n,`ipv6`,r.message,t);break;case`base64url`:az(n,$R.base64url,r.message,t);break;case`jwt`:az(n,$R.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&az(n,$R.ipv4Cidr,r.message,t),r.version!==`v4`&&az(n,$R.ipv6Cidr,r.message,t);break;case`emoji`:az(n,$R.emoji(),r.message,t);break;case`ulid`:az(n,$R.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:iz(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:az(n,$R.base64,r.message,t);break}break;case`nanoid`:az(n,$R.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:}return n}function tz(e,t){return t.patternStrategy===`escape`?rz(e):e}var nz=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function rz(e){let t=``;for(let n=0;n<e.length;n++)nz.has(e[n])||(t+=`\\`),t+=e[n];return t}function iz(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function az(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:oz(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=oz(t,r)}function oz(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
91
|
+
]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
|
|
92
|
+
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r
|
|
93
|
+
`:`[${r[e]}\r
|
|
94
|
+
]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function sz(e,t){let n={type:`object`,additionalProperties:Az(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===Q.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=ez(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===Q.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===Q.ZodBranded&&e.keyType._def.type._def.typeName===Q.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=HR(e.keyType._def,t);return{...n,propertyNames:i}}return n}function cz(e,t){return t.mapStrategy===`record`?sz(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Az(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||RR(),Az(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||RR()],minItems:2,maxItems:2}}}function lz(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function uz(){return{not:RR()}}function dz(){return{type:`null`}}var fz={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function pz(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in fz&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=fz[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return mz(e,t)}var mz=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Az(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function hz(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[fz[e.innerType._def.typeName],`null`]};let n=Az(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function gz(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value;break}return t}function _z(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=yz(a),s=Az(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=vz(e,t);return a!==void 0&&(n.additionalProperties=a),n}function vz(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Az(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function yz(e){try{return e.isOptional()}catch{return!0}}var bz=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Az(e.innerType._def,t);let n=Az(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:RR()},n]}:RR()},xz=(e,t)=>{if(t.pipeStrategy===`input`)return Az(e.in._def,t);if(t.pipeStrategy===`output`)return Az(e.out._def,t);let n=Az(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Az(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Sz(e,t){return Az(e.type._def,t)}function Cz(e,t){let n={type:`array`,uniqueItems:!0,items:Az(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function wz(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Az(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Az(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Az(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Tz(){return{not:RR()}}function Ez(){return RR()}var Dz=(e,t)=>Az(e.innerType._def,t),Oz=(e,t,n)=>{switch(t){case Q.ZodString:return ez(e,n);case Q.ZodNumber:return gz(e);case Q.ZodObject:return _z(e,n);case Q.ZodBigInt:return BR(e);case Q.ZodBoolean:return VR();case Q.ZodDate:return WR(e,n);case Q.ZodUndefined:return Tz();case Q.ZodNull:return dz();case Q.ZodArray:return zR(e,n);case Q.ZodUnion:case Q.ZodDiscriminatedUnion:return pz(e,n);case Q.ZodIntersection:return XR(e,n);case Q.ZodTuple:return wz(e,n);case Q.ZodRecord:return sz(e,n);case Q.ZodLiteral:return ZR(e);case Q.ZodEnum:return JR(e);case Q.ZodNativeEnum:return lz(e);case Q.ZodNullable:return hz(e,n);case Q.ZodOptional:return bz(e,n);case Q.ZodMap:return cz(e,n);case Q.ZodSet:return Cz(e,n);case Q.ZodLazy:return()=>e.getter()._def;case Q.ZodPromise:return Sz(e,n);case Q.ZodNaN:case Q.ZodNever:return uz();case Q.ZodEffects:return qR(e,n);case Q.ZodAny:return RR();case Q.ZodUnknown:return Ez();case Q.ZodDefault:return KR(e,n);case Q.ZodBranded:return HR(e,n);case Q.ZodReadonly:return Dz(e,n);case Q.ZodCatch:return UR(e,n);case Q.ZodPipeline:return xz(e,n);case Q.ZodFunction:case Q.ZodVoid:case Q.ZodSymbol:return;default:return(e=>void 0)(t)}},kz=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Az(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==FR)return i}if(r&&!n){let e=jz(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Oz(e,e.typeName,t),o=typeof a==`function`?Az(a(),t):a;if(o&&Mz(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var jz=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:kz(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),RR()):t.$refStrategy===`seen`?RR():void 0}},Mz=(e,t,n)=>(e.description&&(n.description=e.description),n),Nz=e=>{let t=LR(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},Pz=(e,t)=>{let n=Nz(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Az(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??RR()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Az(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??RR(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},Fz=Symbol.for(`vercel.ai.schema`);function Iz(e){let t;return()=>(t??=e(),t)}function Lz(e,{validate:t}={}){return{[Fz]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function Rz(e){return typeof e==`object`&&!!e&&Fz in e&&e[Fz]===!0&&`jsonSchema`in e&&`validate`in e}function zz(e){return e==null?Lz({properties:{},additionalProperties:!1}):Rz(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?Wz(e):Bz(e):e()}function Bz(e){return Lz(()=>NR(e[`~standard`].jsonSchema.input({target:`draft-07`})),{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new QF({value:t,cause:n.issues})}}})}function Vz(e,t){let n=t?.useReferences??!1;return Lz(()=>Pz(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Hz(e,t){let n=t?.useReferences??!1;return Lz(()=>NR(u(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await D(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Uz(e){return`_zod`in e}function Wz(e,t){return Uz(e)?Hz(e,t):Vz(e,t)}async function Gz({value:e,schema:t,context:n}){let r=await Kz({value:e,schema:t,context:n});if(!r.success)throw QF.wrap({value:e,cause:r.error,context:n});return r.value}async function Kz({value:e,schema:t,context:n}){let r=zz(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:QF.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:QF.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function qz({text:e,schema:t}){try{let n=MR(e);return t==null?n:Gz({value:n,schema:t})}catch(t){throw KF.isInstance(t)||QF.isInstance(t)?t:new KF({text:e,cause:t})}}async function Jz({text:e,schema:t}){try{let n=MR(e);return t==null?{success:!0,value:n,rawValue:n}:await Kz({value:n,schema:t})}catch(t){return{success:!1,error:KF.isInstance(t)?t:new KF({text:e,cause:t}),rawValue:void 0}}}function Yz({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new UL).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await Jz({text:e,schema:t}))}}))}var Xz=()=>globalThis.fetch,Zz=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>Qz({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),Qz=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=Xz()})=>{try{let s=await o(e,{method:`POST`,headers:xR(t,`ai-sdk/provider-utils/${SR}`,yR()),body:n.content,signal:a}),c=JL(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw mR(t)||xF.isInstance(t)?t:new xF({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(mR(t)||xF.isInstance(t))?t:new xF({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw vR({error:t,url:e,requestBodyValues:n.values})}};function $z(e){return e}function eB({id:e,inputSchema:t,outputSchema:n,supportsDeferredResults:r}){return({execute:i,needsApproval:a,toModelOutput:o,onInputStart:s,onInputDelta:c,onInputAvailable:l,...u})=>$z({type:`provider`,id:e,args:u,inputSchema:t,outputSchema:n,execute:i,needsApproval:a,toModelOutput:o,onInputStart:s,onInputDelta:c,onInputAvailable:l,supportsDeferredResults:r})}async function tB(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var nB=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await r.text(),s=JL(r);if(o.trim()===``)return{responseHeaders:s,value:new xF({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await qz({text:o,schema:e});return{responseHeaders:s,value:new xF({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new xF({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},rB=e=>async({response:t})=>{let n=JL(t);if(t.body==null)throw new DF({});return{responseHeaders:n,value:Yz({stream:t.body,schema:e})}},iB=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await t.text(),a=await Jz({text:i,schema:e}),o=JL(t);if(!a.success)throw new xF({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}};function aB(e){return e?.replace(/\/$/,``)}function oB(e){return e!=null&&typeof e[Symbol.asyncIterator]==`function`}async function*sB({execute:e,input:t,options:n}){let r=e(t,n);if(oB(r)){let e;for await(let t of r)e=t,yield{type:`preliminary`,output:t};yield{type:`final`,output:e}}else yield{type:`final`,output:await r}}var cB=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);var u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}})),lB=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}}})),uB=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>d.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>d.RefreshAccessTokenFailedError,getContext:()=>u.getContext,getVercelOidcToken:()=>f,getVercelOidcTokenSync:()=>p,getVercelToken:()=>m}),t.exports=c(l);var u=cB(),d=lB();async function f(){return``}function p(){return``}async function m(){throw Error(`getVercelToken is not supported in browser environments`)}}))(),dB=Symbol.for(`vercel.ai.gateway.error`),fB,pB,mB=class e extends (pB=Error,fB=dB,pB){constructor({message:e,statusCode:t=500,cause:n,generationId:r}){super(r?`${e} [${r}]`:e),this[fB]=!0,this.statusCode=t,this.cause=n,this.generationId=r}static isInstance(t){return e.hasMarker(t)}static hasMarker(e){return typeof e==`object`&&!!e&&dB in e&&e[dB]===!0}},hB=`GatewayAuthenticationError`,gB=`vercel.ai.gateway.error.${hB}`,_B=Symbol.for(gB),vB,yB,bB=class e extends (yB=mB,vB=_B,yB){constructor({message:e=`Authentication failed`,statusCode:t=401,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[vB]=!0,this.name=hB,this.type=`authentication_error`}static isInstance(e){return mB.hasMarker(e)&&_B in e}static createContextualError({apiKeyProvided:t,oidcTokenProvided:n,message:r=`Authentication failed`,statusCode:i=401,cause:a,generationId:o}){let s;return s=t?`AI Gateway authentication failed: Invalid API key.
|
|
95
|
+
|
|
96
|
+
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
97
|
+
|
|
98
|
+
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`:n?`AI Gateway authentication failed: Invalid OIDC token.
|
|
99
|
+
|
|
100
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.
|
|
101
|
+
|
|
102
|
+
Alternatively, use an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys`:`AI Gateway authentication failed: No authentication provided.
|
|
103
|
+
|
|
104
|
+
Option 1 - API key:
|
|
105
|
+
Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
106
|
+
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
107
|
+
|
|
108
|
+
Option 2 - OIDC token:
|
|
109
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new e({message:s,statusCode:i,cause:a,generationId:o})}},xB=`GatewayInvalidRequestError`,SB=`vercel.ai.gateway.error.${xB}`,CB=Symbol.for(SB),wB,TB,EB=class extends (TB=mB,wB=CB,TB){constructor({message:e=`Invalid request`,statusCode:t=400,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[wB]=!0,this.name=xB,this.type=`invalid_request_error`}static isInstance(e){return mB.hasMarker(e)&&CB in e}},DB=`GatewayRateLimitError`,OB=`vercel.ai.gateway.error.${DB}`,kB=Symbol.for(OB),AB,jB,MB=class extends (jB=mB,AB=kB,jB){constructor({message:e=`Rate limit exceeded`,statusCode:t=429,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[AB]=!0,this.name=DB,this.type=`rate_limit_exceeded`}static isInstance(e){return mB.hasMarker(e)&&kB in e}},NB=`GatewayModelNotFoundError`,PB=`vercel.ai.gateway.error.${NB}`,FB=Symbol.for(PB),IB=Iz(()=>Wz(k({modelId:y()}))),LB,RB,zB=class extends (RB=mB,LB=FB,RB){constructor({message:e=`Model not found`,statusCode:t=404,modelId:n,cause:r,generationId:i}={}){super({message:e,statusCode:t,cause:r,generationId:i}),this[LB]=!0,this.name=NB,this.type=`model_not_found`,this.modelId=n}static isInstance(e){return mB.hasMarker(e)&&FB in e}},BB=`GatewayInternalServerError`,VB=`vercel.ai.gateway.error.${BB}`,HB=Symbol.for(VB),UB,WB,GB=class extends (WB=mB,UB=HB,WB){constructor({message:e=`Internal server error`,statusCode:t=500,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[UB]=!0,this.name=BB,this.type=`internal_server_error`}static isInstance(e){return mB.hasMarker(e)&&HB in e}},KB=`GatewayResponseError`,qB=`vercel.ai.gateway.error.${KB}`,JB=Symbol.for(qB),YB,XB,ZB=class extends (XB=mB,YB=JB,XB){constructor({message:e=`Invalid response from Gateway`,statusCode:t=502,response:n,validationError:r,cause:i,generationId:a}={}){super({message:e,statusCode:t,cause:i,generationId:a}),this[YB]=!0,this.name=KB,this.type=`response_error`,this.response=n,this.validationError=r}static isInstance(e){return mB.hasMarker(e)&&JB in e}};async function QB({response:e,statusCode:t,defaultMessage:n=`Gateway request failed`,cause:r,authMethod:i}){let a=await Kz({value:e,schema:$B});if(!a.success){let i=typeof e==`object`&&e&&`generationId`in e?e.generationId:void 0;return new ZB({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:a.error,cause:r,generationId:i})}let o=a.value,s=o.error.type,c=o.error.message,l=o.generationId??void 0;switch(s){case`authentication_error`:return bB.createContextualError({apiKeyProvided:i===`api-key`,oidcTokenProvided:i===`oidc`,statusCode:t,cause:r,generationId:l});case`invalid_request_error`:return new EB({message:c,statusCode:t,cause:r,generationId:l});case`rate_limit_exceeded`:return new MB({message:c,statusCode:t,cause:r,generationId:l});case`model_not_found`:{let e=await Kz({value:o.error.param,schema:IB});return new zB({message:c,statusCode:t,modelId:e.success?e.value.modelId:void 0,cause:r,generationId:l})}case`internal_server_error`:return new GB({message:c,statusCode:t,cause:r,generationId:l});default:return new GB({message:c,statusCode:t,cause:r,generationId:l})}}var $B=Iz(()=>Wz(k({error:k({message:y(),type:y().nullish(),param:d().nullish(),code:c([y(),_()]).nullish()}),generationId:y().nullish()})));function eV(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}var tV=`GatewayTimeoutError`,nV=`vercel.ai.gateway.error.${tV}`,rV=Symbol.for(nV),iV,aV,oV=class e extends (aV=mB,iV=rV,aV){constructor({message:e=`Request timed out`,statusCode:t=408,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[iV]=!0,this.name=tV,this.type=`timeout_error`}static isInstance(e){return mB.hasMarker(e)&&rV in e}static createTimeoutError({originalMessage:t,statusCode:n=408,cause:r,generationId:i}){return new e({message:`Gateway request timed out: ${t}
|
|
110
|
+
|
|
111
|
+
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`,statusCode:n,cause:r,generationId:i})}};function sV(e){if(!(e instanceof Error))return!1;let t=e.code;return typeof t==`string`?[`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CONNECT_TIMEOUT`].includes(t):!1}async function cV(e,t){return mB.isInstance(e)?e:sV(e)?oV.createTimeoutError({originalMessage:e instanceof Error?e.message:`Unknown error`,cause:e}):xF.isInstance(e)?e.cause&&sV(e.cause)?oV.createTimeoutError({originalMessage:e.message,cause:e}):await QB({response:eV(e),statusCode:e.statusCode??500,defaultMessage:`Gateway request failed`,cause:e,authMethod:t}):await QB({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:`Unknown Gateway error`,cause:e,authMethod:t})}var lV=`ai-gateway-auth-method`;async function uV(e){let t=await Kz({value:e[lV],schema:dV});return t.success?t.value:void 0}var dV=Iz(()=>Wz(c([s(`api-key`),s(`oidc`)]))),fV=[`embedding`,`image`,`language`,`reranking`,`video`],pV=class{constructor(e){this.config=e}async getAvailableModels(){try{let{value:e}=await wR({url:`${this.config.baseURL}/config`,headers:await tB(this.config.headers()),successfulResponseHandler:iB(mV),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),fetch:this.config.fetch});return e}catch(e){throw await cV(e)}}async getCredits(){try{let{value:e}=await wR({url:`${new URL(this.config.baseURL).origin}/v1/credits`,headers:await tB(this.config.headers()),successfulResponseHandler:iB(hV),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),fetch:this.config.fetch});return e}catch(e){throw await cV(e)}}},mV=Iz(()=>Wz(k({models:E(k({id:y(),name:y(),description:y().nullish(),pricing:k({input:y(),output:y(),input_cache_read:y().nullish(),input_cache_write:y().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:r})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...r?{cacheCreationInputTokens:r}:{}})).nullish(),specification:k({specificationVersion:s(`v3`),provider:y(),modelId:y()}),modelType:y().nullish()})).transform(e=>e.filter(e=>e.modelType==null||fV.includes(e.modelType)))}))),hV=Iz(()=>Wz(k({balance:y(),total_used:y()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),gV=class{constructor(e){this.config=e}async getSpendReport(e){try{let t=new URL(this.config.baseURL),n=new URLSearchParams;n.set(`start_date`,e.startDate),n.set(`end_date`,e.endDate),e.groupBy&&n.set(`group_by`,e.groupBy),e.datePart&&n.set(`date_part`,e.datePart),e.userId&&n.set(`user_id`,e.userId),e.model&&n.set(`model`,e.model),e.provider&&n.set(`provider`,e.provider),e.credentialType&&n.set(`credential_type`,e.credentialType),e.tags&&e.tags.length>0&&n.set(`tags`,e.tags.join(`,`));let{value:r}=await wR({url:`${t.origin}/v1/report?${n.toString()}`,headers:await tB(this.config.headers()),successfulResponseHandler:iB(_V),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),fetch:this.config.fetch});return r}catch(e){throw await cV(e)}}},_V=Iz(()=>Wz(k({results:E(k({day:y().optional(),hour:y().optional(),user:y().optional(),model:y().optional(),tag:y().optional(),provider:y().optional(),credential_type:v([`byok`,`system`]).optional(),total_cost:_(),market_cost:_().optional(),input_tokens:_().optional(),output_tokens:_().optional(),cached_input_tokens:_().optional(),cache_creation_input_tokens:_().optional(),reasoning_tokens:_().optional(),request_count:_().optional()}).transform(({credential_type:e,total_cost:t,market_cost:n,input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:o,reasoning_tokens:s,request_count:c,...l})=>({...l,...e===void 0?{}:{credentialType:e},totalCost:t,...n===void 0?{}:{marketCost:n},...r===void 0?{}:{inputTokens:r},...i===void 0?{}:{outputTokens:i},...a===void 0?{}:{cachedInputTokens:a},...o===void 0?{}:{cacheCreationInputTokens:o},...s===void 0?{}:{reasoningTokens:s},...c===void 0?{}:{requestCount:c}})))}))),vV=class{constructor(e){this.config=e}async getGenerationInfo(e){try{let{value:t}=await wR({url:`${new URL(this.config.baseURL).origin}/v1/generation?id=${encodeURIComponent(e.id)}`,headers:await tB(this.config.headers()),successfulResponseHandler:iB(yV),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),fetch:this.config.fetch});return t}catch(e){throw await cV(e)}}},yV=Iz(()=>Wz(k({data:k({id:y(),total_cost:_(),upstream_inference_cost:_(),usage:_(),created_at:y(),model:y(),is_byok:r(),provider_name:y(),streamed:r(),finish_reason:y(),latency:_(),generation_time:_(),native_tokens_prompt:_(),native_tokens_completion:_(),native_tokens_reasoning:_(),native_tokens_cached:_(),native_tokens_cache_creation:_(),billable_web_search_calls:_()}).transform(({total_cost:e,upstream_inference_cost:t,created_at:n,is_byok:r,provider_name:i,finish_reason:a,generation_time:o,native_tokens_prompt:s,native_tokens_completion:c,native_tokens_reasoning:l,native_tokens_cached:u,native_tokens_cache_creation:d,billable_web_search_calls:f,...p})=>({...p,totalCost:e,upstreamInferenceCost:t,createdAt:n,isByok:r,providerName:i,finishReason:a,generationTime:o,promptTokens:s,completionTokens:c,reasoningTokens:l,cachedTokens:u,cacheCreationTokens:d,billableWebSearchCalls:f}))}).transform(({data:e})=>e))),bV=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v3`,this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){let{abortSignal:t,...n}=e;return{args:this.maybeEncodeFileParts(n),warnings:[]}}async doGenerate(e){let{args:t,warnings:n}=await this.getArgs(e),{abortSignal:r}=e,i=await tB(this.config.headers());try{let{responseHeaders:a,value:o,rawValue:s}=await Zz({url:this.getUrl(),headers:WL(i,e.headers,this.getModelConfigHeaders(this.modelId,!1),await tB(this.config.o11yHeaders)),body:t,successfulResponseHandler:iB(m()),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),...r&&{abortSignal:r},fetch:this.config.fetch});return{...o,request:{body:t},response:{headers:a,body:s},warnings:n}}catch(e){throw await cV(e,await uV(i))}}async doStream(e){let{args:t,warnings:n}=await this.getArgs(e),{abortSignal:r}=e,i=await tB(this.config.headers());try{let{value:a,responseHeaders:o}=await Zz({url:this.getUrl(),headers:WL(i,e.headers,this.getModelConfigHeaders(this.modelId,!0),await tB(this.config.o11yHeaders)),body:t,successfulResponseHandler:rB(m()),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),...r&&{abortSignal:r},fetch:this.config.fetch});return{stream:a.pipeThrough(new TransformStream({start(e){n.length>0&&e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(t.success){let r=t.value;if(r.type===`raw`&&!e.includeRawChunks)return;r.type===`response-metadata`&&r.timestamp&&typeof r.timestamp==`string`&&(r.timestamp=new Date(r.timestamp)),n.enqueue(r)}else n.error(t.error)}})),request:{body:t},response:{headers:o}}}catch(e){throw await cV(e,await uV(i))}}isFilePart(e){return e&&typeof e==`object`&&`type`in e&&e.type===`file`}maybeEncodeFileParts(e){for(let t of e.prompt)for(let e of t.content)if(this.isFilePart(e)){let t=e;if(t.data instanceof Uint8Array){let e=Uint8Array.from(t.data),n=Buffer.from(e).toString(`base64`);t.data=new URL(`data:${t.mediaType||`application/octet-stream`};base64,${n}`)}}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":`3`,"ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},xV=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v3`,this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:r}){let i=await tB(this.config.headers());try{let{responseHeaders:a,value:o,rawValue:s}=await Zz({url:this.getUrl(),headers:WL(i,t??{},this.getModelConfigHeaders(),await tB(this.config.o11yHeaders)),body:{values:e,...r?{providerOptions:r}:{}},successfulResponseHandler:iB(SV),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),...n&&{abortSignal:n},fetch:this.config.fetch});return{embeddings:o.embeddings,usage:o.usage??void 0,providerMetadata:o.providerMetadata,response:{headers:a,body:s},warnings:[]}}catch(e){throw await cV(e,await uV(i))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":`3`,"ai-model-id":this.modelId}}},SV=Iz(()=>Wz(k({embeddings:E(E(_())),usage:k({tokens:_()}).nullish(),providerMetadata:b(y(),b(y(),d())).optional()}))),CV=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v3`,this.maxImagesPerCall=2**53-1}get provider(){return this.config.provider}async doGenerate({prompt:e,n:t,size:n,aspectRatio:r,seed:i,files:a,mask:o,providerOptions:s,headers:c,abortSignal:l}){let u=await tB(this.config.headers());try{let{responseHeaders:d,value:f,rawValue:p}=await Zz({url:this.getUrl(),headers:WL(u,c??{},this.getModelConfigHeaders(),await tB(this.config.o11yHeaders)),body:{prompt:e,n:t,...n&&{size:n},...r&&{aspectRatio:r},...i&&{seed:i},...s&&{providerOptions:s},...a&&{files:a.map(e=>wV(e))},...o&&{mask:wV(o)}},successfulResponseHandler:iB(OV),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),...l&&{abortSignal:l},fetch:this.config.fetch});return{images:f.images,warnings:f.warnings??[],providerMetadata:f.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:d},...f.usage!=null&&{usage:{inputTokens:f.usage.inputTokens??void 0,outputTokens:f.usage.outputTokens??void 0,totalTokens:f.usage.totalTokens??void 0}}}}catch(e){throw await cV(e,await uV(u))}}getUrl(){return`${this.config.baseURL}/image-model`}getModelConfigHeaders(){return{"ai-image-model-specification-version":`3`,"ai-model-id":this.modelId}}};function wV(e){return e.type===`file`&&e.data instanceof Uint8Array?{...e,data:QL(e.data)}:e}var TV=k({images:E(d()).optional()}).catchall(d()),EV=p(`type`,[k({type:s(`unsupported`),feature:y(),details:y().optional()}),k({type:s(`compatibility`),feature:y(),details:y().optional()}),k({type:s(`other`),message:y()})]),DV=k({inputTokens:_().nullish(),outputTokens:_().nullish(),totalTokens:_().nullish()}),OV=k({images:E(y()),warnings:E(EV).optional(),providerMetadata:b(y(),TV).optional(),usage:DV.optional()}),kV=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v3`,this.maxVideosPerCall=2**53-1}get provider(){return this.config.provider}async doGenerate({prompt:e,n:t,aspectRatio:n,resolution:r,duration:i,fps:a,seed:o,image:s,providerOptions:c,headers:l,abortSignal:u}){let d=await tB(this.config.headers());try{let{responseHeaders:f,value:p}=await Zz({url:this.getUrl(),headers:WL(d,l??{},this.getModelConfigHeaders(),await tB(this.config.o11yHeaders),{accept:`text/event-stream`}),body:{prompt:e,n:t,...n&&{aspectRatio:n},...r&&{resolution:r},...i&&{duration:i},...a&&{fps:a},...o&&{seed:o},...c&&{providerOptions:c},...s&&{image:AV(s)}},successfulResponseHandler:async({response:e,url:t,requestBodyValues:n})=>{if(e.body==null)throw new xF({message:`SSE response body is empty`,url:t,requestBodyValues:n,statusCode:e.status});let r=Yz({stream:e.body,schema:PV}).getReader(),{done:i,value:a}=await r.read();if(r.releaseLock(),i||!a)throw new xF({message:`SSE stream ended without a data event`,url:t,requestBodyValues:n,statusCode:e.status});if(!a.success)throw new xF({message:`Failed to parse video SSE event`,cause:a.error,url:t,requestBodyValues:n,statusCode:e.status});let o=a.value;if(o.type===`error`)throw new xF({message:o.message,statusCode:o.statusCode,url:t,requestBodyValues:n,responseHeaders:Object.fromEntries([...e.headers]),responseBody:JSON.stringify(o),data:{error:{message:o.message,type:o.errorType,param:o.param}}});return{value:{videos:o.videos,warnings:o.warnings,providerMetadata:o.providerMetadata},responseHeaders:Object.fromEntries([...e.headers])}},failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),...u&&{abortSignal:u},fetch:this.config.fetch});return{videos:p.videos,warnings:p.warnings??[],providerMetadata:p.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:f}}}catch(e){throw await cV(e,await uV(d))}}getUrl(){return`${this.config.baseURL}/video-model`}getModelConfigHeaders(){return{"ai-video-model-specification-version":`3`,"ai-model-id":this.modelId}}};function AV(e){return e.type===`file`&&e.data instanceof Uint8Array?{...e,data:QL(e.data)}:e}var jV=k({videos:E(d()).optional()}).catchall(d()),MV=c([k({type:s(`url`),url:y(),mediaType:y()}),k({type:s(`base64`),data:y(),mediaType:y()})]),NV=p(`type`,[k({type:s(`unsupported`),feature:y(),details:y().optional()}),k({type:s(`compatibility`),feature:y(),details:y().optional()}),k({type:s(`other`),message:y()})]),PV=p(`type`,[k({type:s(`result`),videos:E(MV),warnings:E(NV).optional(),providerMetadata:b(y(),jV).optional()}),k({type:s(`error`),message:y(),errorType:y(),statusCode:_(),param:d().nullable()})]),FV=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v3`}get provider(){return this.config.provider}async doRerank({documents:e,query:t,topN:n,headers:r,abortSignal:i,providerOptions:a}){let o=await tB(this.config.headers());try{let{responseHeaders:s,value:c,rawValue:l}=await Zz({url:this.getUrl(),headers:WL(o,r??{},this.getModelConfigHeaders(),await tB(this.config.o11yHeaders)),body:{documents:e,query:t,...n==null?{}:{topN:n},...a?{providerOptions:a}:{}},successfulResponseHandler:iB(IV),failedResponseHandler:nB({errorSchema:m(),errorToMessage:e=>e}),...i&&{abortSignal:i},fetch:this.config.fetch});return{ranking:c.ranking,providerMetadata:c.providerMetadata,response:{headers:s,body:l},warnings:[]}}catch(e){throw await cV(e,await uV(o))}}getUrl(){return`${this.config.baseURL}/reranking-model`}getModelConfigHeaders(){return{"ai-reranking-model-specification-version":`3`,"ai-model-id":this.modelId}}},IV=Iz(()=>Wz(k({ranking:E(k({index:_(),relevanceScore:_()})),providerMetadata:b(y(),b(y(),d())).optional()}))),LV=eB({id:`gateway.parallel_search`,inputSchema:Iz(()=>Wz(k({objective:y().describe(`Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters.`),search_queries:E(y()).optional().describe(`Optional search queries to supplement the objective. Maximum 200 characters per query.`),mode:v([`one-shot`,`agentic`]).optional().describe(`Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.`),max_results:_().optional().describe(`Maximum number of results to return (1-20). Defaults to 10 if not specified.`),source_policy:k({include_domains:E(y()).optional().describe(`List of domains to include in search results.`),exclude_domains:E(y()).optional().describe(`List of domains to exclude from search results.`),after_date:y().optional().describe(`Only include results published after this date (ISO 8601 format).`)}).optional().describe(`Source policy for controlling which domains to include/exclude and freshness.`),excerpts:k({max_chars_per_result:_().optional().describe(`Maximum characters per result.`),max_chars_total:_().optional().describe(`Maximum total characters across all results.`)}).optional().describe(`Excerpt configuration for controlling result length.`),fetch_policy:k({max_age_seconds:_().optional().describe(`Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.`)}).optional().describe(`Fetch policy for controlling content freshness.`)}))),outputSchema:Iz(()=>Wz(c([k({searchId:y(),results:E(k({url:y(),title:y(),excerpt:y(),publishDate:y().nullable().optional(),relevanceScore:_().optional()}))}),k({error:v([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`configuration_error`,`unknown`]),statusCode:_().optional(),message:y()})])))}),RV=(e={})=>LV(e),zV=eB({id:`gateway.perplexity_search`,inputSchema:Iz(()=>Wz(k({query:c([y(),E(y())]).describe(`Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries.`),max_results:_().optional().describe(`Maximum number of search results to return (1-20, default: 10)`),max_tokens_per_page:_().optional().describe(`Maximum number of tokens to extract per search result page (256-2048, default: 2048)`),max_tokens:_().optional().describe(`Maximum total tokens across all search results (default: 25000, max: 1000000)`),country:y().optional().describe(`Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')`),search_domain_filter:E(y()).optional().describe(`List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']`),search_language_filter:E(y()).optional().describe(`List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']`),search_after_date:y().optional().describe(`Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter.`),search_before_date:y().optional().describe(`Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter.`),last_updated_after_filter:y().optional().describe(`Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter.`),last_updated_before_filter:y().optional().describe(`Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter.`),search_recency_filter:v([`day`,`week`,`month`,`year`]).optional().describe(`Filter results by relative time period. Cannot be used with search_after_date or search_before_date.`)}))),outputSchema:Iz(()=>Wz(c([k({results:E(k({title:y(),url:y(),snippet:y(),date:y().optional(),lastUpdated:y().optional()})),id:y()}),k({error:v([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`unknown`]),statusCode:_().optional(),message:y()})])))}),BV={parallelSearch:RV,perplexitySearch:(e={})=>zV(e)};async function VV(){return(0,uB.getContext)().headers?.[`x-vercel-id`]}var HV=`3.0.112`,UV=`0.0.1`;function WV(e={}){let t=null,n=null,r=e.metadataCacheRefreshMillis??1e3*60*5,i=0,a=aB(e.baseURL)??`https://ai-gateway.vercel.sh/v3/ai`,o=async()=>{try{let t=await KV(e);return xR({Authorization:`Bearer ${t.token}`,"ai-gateway-protocol-version":UV,[lV]:t.authMethod,...e.headers},`ai-sdk/gateway/${HV}`)}catch(e){throw bB.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},s=()=>{let e=DR({settingValue:void 0,environmentVariableName:`VERCEL_DEPLOYMENT_ID`}),t=DR({settingValue:void 0,environmentVariableName:`VERCEL_ENV`}),n=DR({settingValue:void 0,environmentVariableName:`VERCEL_REGION`}),r=DR({settingValue:void 0,environmentVariableName:`VERCEL_PROJECT_ID`});return async()=>{let i=await VV();return{...e&&{"ai-o11y-deployment-id":e},...t&&{"ai-o11y-environment":t},...n&&{"ai-o11y-region":n},...i&&{"ai-o11y-request-id":i},...r&&{"ai-o11y-project-id":r}}}},c=t=>new bV(t,{provider:`gateway`,baseURL:a,headers:o,fetch:e.fetch,o11yHeaders:s()}),l=async()=>{var s;let c=((s=e._internal)?.currentDate)?.call(s).getTime()??Date.now();return(!t||c-i>r)&&(i=c,t=new pV({baseURL:a,headers:o,fetch:e.fetch}).getAvailableModels().then(e=>(n=e,e)).catch(async e=>{throw await cV(e,await uV(await o()))})),n?Promise.resolve(n):t},u=async()=>new pV({baseURL:a,headers:o,fetch:e.fetch}).getCredits().catch(async e=>{throw await cV(e,await uV(await o()))}),d=async t=>new gV({baseURL:a,headers:o,fetch:e.fetch}).getSpendReport(t).catch(async e=>{throw await cV(e,await uV(await o()))}),f=async t=>new vV({baseURL:a,headers:o,fetch:e.fetch}).getGenerationInfo(t).catch(async e=>{throw await cV(e,await uV(await o()))}),p=function(e){if(new.target)throw Error(`The Gateway Provider model function cannot be called with the new keyword.`);return c(e)};p.specificationVersion=`v3`,p.getAvailableModels=l,p.getCredits=u,p.getSpendReport=d,p.getGenerationInfo=f,p.imageModel=t=>new CV(t,{provider:`gateway`,baseURL:a,headers:o,fetch:e.fetch,o11yHeaders:s()}),p.languageModel=c;let m=t=>new xV(t,{provider:`gateway`,baseURL:a,headers:o,fetch:e.fetch,o11yHeaders:s()});p.embeddingModel=m,p.textEmbeddingModel=m,p.videoModel=t=>new kV(t,{provider:`gateway`,baseURL:a,headers:o,fetch:e.fetch,o11yHeaders:s()});let h=t=>new FV(t,{provider:`gateway`,baseURL:a,headers:o,fetch:e.fetch,o11yHeaders:s()});return p.rerankingModel=h,p.reranking=h,p.chat=p.languageModel,p.embedding=p.embeddingModel,p.image=p.imageModel,p.video=p.videoModel,p.tools=BV,p}var GV=WV();async function KV(e){let t=DR({settingValue:e.apiKey,environmentVariableName:`AI_GATEWAY_API_KEY`});return t?{token:t,authMethod:`api-key`}:{token:await(0,uB.getVercelOidcToken)(),authMethod:`oidc`}}var qV=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{},JV=`1.9.0`,YV=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function XV(e){var t=new Set([e]),n=new Set,r=e.match(YV);if(!r)return function(){return!1};var i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;var r=e.match(YV);if(!r)return a(e);var s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}var ZV=XV(JV),QV=JV.split(`.`)[0],$V=Symbol.for(`opentelemetry.js.api.`+QV),eH=qV;function tH(e,t,n,r){r===void 0&&(r=!1);var i=eH[$V]=eH[$V]??{version:JV};if(!r&&i[e]){var a=Error(`@opentelemetry/api: Attempted duplicate registration of API: `+e);return n.error(a.stack||a.message),!1}if(i.version!==`1.9.0`){var a=Error(`@opentelemetry/api: Registration of version v`+i.version+` for `+e+` does not match previously registered API v`+JV);return n.error(a.stack||a.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for `+e+` v`+JV+`.`),!0}function nH(e){var t=eH[$V]?.version;if(!(!t||!ZV(t)))return eH[$V]?.[e]}function rH(e,t){t.debug(`@opentelemetry/api: Unregistering a global for `+e+` v`+JV+`.`);var n=eH[$V];n&&delete n[e]}var iH=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},aH=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},oH=function(){function e(e){this._namespace=e.namespace||`DiagComponentLogger`}return e.prototype.debug=function(){var e=[...arguments];return sH(`debug`,this._namespace,e)},e.prototype.error=function(){var e=[...arguments];return sH(`error`,this._namespace,e)},e.prototype.info=function(){var e=[...arguments];return sH(`info`,this._namespace,e)},e.prototype.warn=function(){var e=[...arguments];return sH(`warn`,this._namespace,e)},e.prototype.verbose=function(){var e=[...arguments];return sH(`verbose`,this._namespace,e)},e}();function sH(e,t,n){var r=nH(`diag`);if(r)return n.unshift(t),r[e].apply(r,aH([],iH(n),!1))}var cH;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(cH||={});function lH(e,t){e<cH.NONE?e=cH.NONE:e>cH.ALL&&(e=cH.ALL),t||={};function n(n,r){var i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,cH.ERROR),warn:n(`warn`,cH.WARN),info:n(`info`,cH.INFO),debug:n(`debug`,cH.DEBUG),verbose:n(`verbose`,cH.VERBOSE)}}var uH=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},dH=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},fH=`diag`,pH=function(){function e(){function e(e){return function(){var t=[...arguments],n=nH(`diag`);if(n)return n[e].apply(n,dH([],uH(t),!1))}}var t=this;t.setLogger=function(e,n){if(n===void 0&&(n={logLevel:cH.INFO}),e===t){var r=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(r.stack??r.message),!1}typeof n==`number`&&(n={logLevel:n});var i=nH(`diag`),a=lH(n.logLevel??cH.INFO,e);if(i&&!n.suppressOverrideMessage){var o=Error().stack??`<failed to generate stacktrace>`;i.warn(`Current logger will be overwritten from `+o),a.warn(`Current logger will overwrite one already registered from `+o)}return tH(`diag`,a,t,!0)},t.disable=function(){rH(fH,t)},t.createComponentLogger=function(e){return new oH(e)},t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}return e.instance=function(){return this._instance||=new e,this._instance},e}();function mH(e){return Symbol.for(e)}var hH=new(function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(e){return n._currentContext.get(e)},n.setValue=function(t,r){var i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=function(t){var r=new e(n._currentContext);return r._currentContext.delete(t),r}}return e}()),gH=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},_H=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},vH=function(){function e(){}return e.prototype.active=function(){return hH},e.prototype.with=function(e,t,n){var r=[...arguments].slice(3);return t.call.apply(t,_H([n],gH(r),!1))},e.prototype.bind=function(e,t){return t},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),yH=function(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},bH=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))},xH=`context`,SH=new vH,CH=function(){function e(){}return e.getInstance=function(){return this._instance||=new e,this._instance},e.prototype.setGlobalContextManager=function(e){return tH(xH,e,pH.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(e,t,n){for(var r,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(r=this._getContextManager()).with.apply(r,bH([e,t,n],yH(i),!1))},e.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},e.prototype._getContextManager=function(){return nH(xH)||SH},e.prototype.disable=function(){this._getContextManager().disable(),rH(xH,pH.instance())},e}(),wH;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(wH||={});var TH={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:wH.NONE},EH=function(){function e(e){e===void 0&&(e=TH),this._spanContext=e}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(e,t){return this},e.prototype.setAttributes=function(e){return this},e.prototype.addEvent=function(e,t){return this},e.prototype.addLink=function(e){return this},e.prototype.addLinks=function(e){return this},e.prototype.setStatus=function(e){return this},e.prototype.updateName=function(e){return this},e.prototype.end=function(e){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(e,t){},e}(),DH=mH(`OpenTelemetry Context Key SPAN`);function OH(e){return e.getValue(DH)||void 0}function kH(){return OH(CH.getInstance().active())}function AH(e,t){return e.setValue(DH,t)}function jH(e){return e.deleteValue(DH)}function MH(e,t){return AH(e,new EH(t))}function NH(e){return OH(e)?.spanContext()}var PH=/^([0-9a-f]{32})$/i,FH=/^[0-9a-f]{16}$/i;function IH(e){return PH.test(e)&&e!==`00000000000000000000000000000000`}function LH(e){return FH.test(e)&&e!==`0000000000000000`}function RH(e){return IH(e.traceId)&&LH(e.spanId)}function zH(e){return new EH(e)}var BH=CH.getInstance(),VH=function(){function e(){}return e.prototype.startSpan=function(e,t,n){if(n===void 0&&(n=BH.active()),t?.root)return new EH;var r=n&&NH(n);return HH(r)&&RH(r)?new EH(r):new EH},e.prototype.startActiveSpan=function(e,t,n,r){var i,a,o;if(!(arguments.length<2)){arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);var s=a??BH.active(),c=this.startSpan(e,i,s),l=AH(s,c);return BH.with(l,o,void 0,c)}},e}();function HH(e){return typeof e==`object`&&typeof e.spanId==`string`&&typeof e.traceId==`string`&&typeof e.traceFlags==`number`}var UH=new VH,WH=function(){function e(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}return e.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},e.prototype.startActiveSpan=function(e,t,n,r){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):UH},e}(),GH=new(function(){function e(){}return e.prototype.getTracer=function(e,t,n){return new VH},e}()),KH=function(){function e(){}return e.prototype.getTracer=function(e,t,n){return this.getDelegateTracer(e,t,n)??new WH(this,e,t,n)},e.prototype.getDelegate=function(){return this._delegate??GH},e.prototype.setDelegate=function(e){this._delegate=e},e.prototype.getDelegateTracer=function(e,t,n){return this._delegate?.getTracer(e,t,n)},e}(),qH;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(qH||={});var JH=CH.getInstance(),YH=`trace`,XH=function(){function e(){this._proxyTracerProvider=new KH,this.wrapSpanContext=zH,this.isSpanContextValid=RH,this.deleteSpan=jH,this.getSpan=OH,this.getActiveSpan=kH,this.getSpanContext=NH,this.setSpan=AH,this.setSpanContext=MH}return e.getInstance=function(){return this._instance||=new e,this._instance},e.prototype.setGlobalTracerProvider=function(e){var t=tH(YH,this._proxyTracerProvider,pH.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},e.prototype.getTracerProvider=function(){return nH(YH)||this._proxyTracerProvider},e.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},e.prototype.disable=function(){rH(YH,pH.instance()),this._proxyTracerProvider=new KH},e}().getInstance(),ZH=Object.defineProperty,QH=(e,t)=>{for(var n in t)ZH(e,n,{get:t[n],enumerable:!0})},$H=`AI_InvalidArgumentError`,eU=`vercel.ai.error.${$H}`,tU=Symbol.for(eU),nU,rU=class extends hF{constructor({parameter:e,value:t,message:n}){super({name:$H,message:`Invalid argument for parameter ${e}: ${n}`}),this[nU]=!0,this.parameter=e,this.value=t}static isInstance(e){return hF.hasMarker(e,eU)}};nU=tU;var iU=`AI_InvalidToolApprovalError`,aU=`vercel.ai.error.${iU}`,oU=Symbol.for(aU),sU,cU=class extends hF{constructor({approvalId:e}){super({name:iU,message:`Tool approval response references unknown approvalId: "${e}". No matching tool-approval-request found in message history.`}),this[sU]=!0,this.approvalId=e}static isInstance(e){return hF.hasMarker(e,aU)}};sU=oU;var lU=`AI_InvalidToolInputError`,uU=`vercel.ai.error.${lU}`,dU=Symbol.for(uU),fU,pU=class extends hF{constructor({toolInput:e,toolName:t,cause:n,message:r=`Invalid input for tool ${t}: ${OF(n)}`}){super({name:lU,message:r,cause:n}),this[fU]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return hF.hasMarker(e,uU)}};fU=dU;var mU=`AI_ToolCallNotFoundForApprovalError`,hU=`vercel.ai.error.${mU}`,gU=Symbol.for(hU),_U,vU=class extends hF{constructor({toolCallId:e,approvalId:t}){super({name:mU,message:`Tool call "${e}" not found for approval request "${t}".`}),this[_U]=!0,this.toolCallId=e,this.approvalId=t}static isInstance(e){return hF.hasMarker(e,hU)}};_U=gU;var yU=`AI_MissingToolResultsError`,bU=`vercel.ai.error.${yU}`,xU=Symbol.for(bU),SU,CU=class extends hF{constructor({toolCallIds:e}){super({name:yU,message:`Tool result${e.length>1?`s are`:` is`} missing for tool call${e.length>1?`s`:``} ${e.join(`, `)}.`}),this[SU]=!0,this.toolCallIds=e}static isInstance(e){return hF.hasMarker(e,bU)}};SU=xU;var wU=`AI_NoObjectGeneratedError`,TU=`vercel.ai.error.${wU}`,EU=Symbol.for(TU),DU,OU=class extends hF{constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:wU,message:e,cause:t}),this[DU]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return hF.hasMarker(e,TU)}};DU=EU;var kU=`AI_NoOutputGeneratedError`,AU=`vercel.ai.error.${kU}`,jU=Symbol.for(AU),MU,NU=class extends hF{constructor({message:e=`No output generated.`,cause:t}={}){super({name:kU,message:e,cause:t}),this[MU]=!0}static isInstance(e){return hF.hasMarker(e,AU)}};MU=jU;var PU=`AI_NoSuchToolError`,FU=`vercel.ai.error.${PU}`,IU=Symbol.for(FU),LU,RU=class extends hF{constructor({toolName:e,availableTools:t=void 0,message:n=`Model tried to call unavailable tool '${e}'. ${t===void 0?`No tools are available.`:`Available tools: ${t.join(`, `)}.`}`}){super({name:PU,message:n}),this[LU]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return hF.hasMarker(e,FU)}};LU=IU;var zU=`AI_ToolCallRepairError`,BU=`vercel.ai.error.${zU}`,VU=Symbol.for(BU),HU,UU=class extends hF{constructor({cause:e,originalError:t,message:n=`Error repairing tool call: ${OF(e)}`}){super({name:zU,message:n,cause:e}),this[HU]=!0,this.originalError=t}static isInstance(e){return hF.hasMarker(e,BU)}};HU=VU;var WU=class extends hF{constructor(e){super({name:`AI_UnsupportedModelVersionError`,message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},GU=`AI_UIMessageStreamError`,KU=`vercel.ai.error.${GU}`,qU=Symbol.for(KU),JU,YU=class extends hF{constructor({chunkType:e,chunkId:t,message:n}){super({name:GU,message:n}),this[JU]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return hF.hasMarker(e,KU)}};JU=qU;var XU=`AI_InvalidMessageRoleError`,ZU=`vercel.ai.error.${XU}`,QU=Symbol.for(ZU),$U,eW=class extends hF{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:XU,message:t}),this[$U]=!0,this.role=e}static isInstance(e){return hF.hasMarker(e,ZU)}};$U=QU;var tW=`AI_MessageConversionError`,nW=`vercel.ai.error.${tW}`,rW=Symbol.for(nW),iW,aW=class extends hF{constructor({originalMessage:e,message:t}){super({name:tW,message:t}),this[iW]=!0,this.originalMessage=e}static isInstance(e){return hF.hasMarker(e,nW)}};iW=rW;var oW=`AI_RetryError`,sW=`vercel.ai.error.${oW}`,cW=Symbol.for(sW),lW,uW=class extends hF{constructor({message:e,reason:t,errors:n}){super({name:oW,message:e}),this[lW]=!0,this.reason=t,this.errors=n,this.lastError=n[n.length-1]}static isInstance(e){return hF.hasMarker(e,sW)}};lW=cW;function dW(e){return e===void 0?[]:Array.isArray(e)?e:[e]}async function fW(e){for(let t of dW(e.callbacks))if(t!=null)try{await t(e.event)}catch{}}function pW({warning:e,provider:t,model:n}){let r=`AI SDK Warning (${t} / ${n}):`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var mW=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,hW=!1,gW=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}hW||(hW=!0,console.info(mW));for(let t of e.warnings)console.warn(pW({warning:t,provider:e.provider,model:e.model}))}};function _W({provider:e,modelId:t}){gW({warnings:[{type:`compatibility`,feature:`specificationVersion`,details:`Using v2 specification compatibility mode. Some features may not be available.`}],provider:e,model:t})}function vW(e){return e.specificationVersion===`v3`?e:(_W({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){switch(t){case`specificationVersion`:return`v3`;case`doGenerate`:return async(...t)=>{let n=await e.doGenerate(...t);return{...n,finishReason:bW(n.finishReason),usage:xW(n.usage)}};case`doStream`:return async(...t)=>{let n=await e.doStream(...t);return{...n,stream:yW(n.stream)}};default:return e[t]}}}))}function yW(e){return e.pipeThrough(new TransformStream({transform(e,t){switch(e.type){case`finish`:t.enqueue({...e,finishReason:bW(e.finishReason),usage:xW(e.usage)});break;default:t.enqueue(e);break}}}))}function bW(e){return{unified:e===`unknown`?`other`:e,raw:void 0}}function xW(e){return{inputTokens:{total:e.inputTokens,noCache:void 0,cacheRead:e.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:e.outputTokens,text:void 0,reasoning:e.reasoningTokens}}}function SW(e){if(typeof e!=`string`){if(e.specificationVersion!==`v3`&&e.specificationVersion!==`v2`){let t=e;throw new WU({version:t.specificationVersion,provider:t.provider,modelId:t.modelId})}return vW(e)}return CW().languageModel(e)}function CW(){return globalThis.AI_SDK_DEFAULT_PROVIDER??GV}function wW(e){if(e!=null)return typeof e==`number`?e:e.totalMs}function TW(e){if(!(e==null||typeof e==`number`))return e.stepMs}function EW(e){if(!(e==null||typeof e==`number`))return e.chunkMs}var DW=[{mediaType:`image/gif`,bytesPrefix:[71,73,70]},{mediaType:`image/png`,bytesPrefix:[137,80,78,71]},{mediaType:`image/jpeg`,bytesPrefix:[255,216]},{mediaType:`image/webp`,bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:`image/bmp`,bytesPrefix:[66,77]},{mediaType:`image/tiff`,bytesPrefix:[73,73,42,0]},{mediaType:`image/tiff`,bytesPrefix:[77,77,0,42]},{mediaType:`image/avif`,bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:`image/heic`,bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],OW=e=>{let t=typeof e==`string`?ZL(e):e,n=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(n+10)};function kW(e){return typeof e==`string`&&e.startsWith(`SUQz`)||typeof e!=`string`&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?OW(e):e}function AW({data:e,signatures:t}){let n=kW(e),r=typeof n==`string`?ZL(n.substring(0,Math.min(n.length,24))):n;for(let e of t)if(r.length>=e.bytesPrefix.length&&e.bytesPrefix.every((e,t)=>e===null||r[t]===e))return e.mediaType}var jW=`6.0.177`,MW=async({url:e,maxBytes:t,abortSignal:n})=>{let r=e.toString();sR(r);try{let e=await fetch(r,{headers:xR({},`ai-sdk/${jW}`,yR()),signal:n});if(e.redirected&&sR(e.url),!e.ok)throw new iR({url:r,statusCode:e.status,statusText:e.statusText});return{data:await oR({response:e,url:r,maxBytes:t??aR}),mediaType:e.headers.get(`content-type`)??void 0}}catch(e){throw iR.isInstance(e)?e:new iR({url:r,cause:e})}},NW=(e=MW)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:e(t)));function PW(e){try{let[t,n]=e.split(`,`);return{mediaType:t.split(`;`)[0].split(`:`)[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}var FW=c([y(),o(Uint8Array),o(ArrayBuffer),T(e=>globalThis.Buffer?.isBuffer(e)??!1,{message:`Must be a Buffer`})]);function IW(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e==`string`)try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol===`data:`){let{mediaType:t,base64Content:n}=PW(e.toString());if(t==null||n==null)throw new hF({name:`InvalidDataContentError`,message:`Invalid data URL format in content ${e.toString()}`});return{data:n,mediaType:t}}return{data:e,mediaType:void 0}}function LW(e){return typeof e==`string`?e:e instanceof ArrayBuffer?QL(new Uint8Array(e)):QL(e)}async function RW({prompt:e,supportedUrls:t,download:n=NW()}){let r=await BW(e.messages,n,t),i=new Map;for(let t of e.messages)if(t.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e.type===`tool-approval-request`&&`approvalId`in e&&`toolCallId`in e&&i.set(e.approvalId,e.toolCallId);let a=new Set;for(let t of e.messages)if(t.role===`tool`){for(let e of t.content)if(e.type===`tool-approval-response`){let t=i.get(e.approvalId);t&&a.add(t)}}let o=[...e.system==null?[]:typeof e.system==`string`?[{role:`system`,content:e.system}]:dW(e.system).map(e=>({role:`system`,content:e.content,providerOptions:e.providerOptions})),...e.messages.map(e=>zW({message:e,downloadedAssets:r}))],s=[];for(let e of o){if(e.role!==`tool`){s.push(e);continue}let t=s.at(-1);t?.role===`tool`?t.content.push(...e.content):s.push(e)}let c=new Set;for(let e of s)switch(e.role){case`assistant`:for(let t of e.content)t.type===`tool-call`&&!t.providerExecuted&&c.add(t.toolCallId);break;case`tool`:for(let t of e.content)t.type===`tool-result`&&c.delete(t.toolCallId);break;case`user`:case`system`:for(let e of a)c.delete(e);if(c.size>0)throw new CU({toolCallIds:Array.from(c)});break}for(let e of a)c.delete(e);if(c.size>0)throw new CU({toolCallIds:Array.from(c)});return s.filter(e=>e.role!==`tool`||e.content.length>0)}function zW({message:e,downloadedAssets:t}){let n=e.role;switch(n){case`system`:return{role:`system`,content:e.content,providerOptions:e.providerOptions};case`user`:return typeof e.content==`string`?{role:`user`,content:[{type:`text`,text:e.content}],providerOptions:e.providerOptions}:{role:`user`,content:e.content.map(e=>VW(e,t)).filter(e=>e.type!==`text`||e.text!==``),providerOptions:e.providerOptions};case`assistant`:return typeof e.content==`string`?{role:`assistant`,content:[{type:`text`,text:e.content}],providerOptions:e.providerOptions}:{role:`assistant`,content:e.content.filter(e=>e.type!==`text`||e.text!==``||e.providerOptions!=null).filter(e=>e.type!==`tool-approval-request`).map(e=>{let t=e.providerOptions;switch(e.type){case`file`:{let{data:n,mediaType:r}=IW(e.data);return{type:`file`,data:n,filename:e.filename,mediaType:r??e.mediaType,providerOptions:t}}case`reasoning`:return{type:`reasoning`,text:e.text,providerOptions:t};case`text`:return{type:`text`,text:e.text,providerOptions:t};case`tool-call`:return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:t};case`tool-result`:return{type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:HW(e.output),providerOptions:t}}}),providerOptions:e.providerOptions};case`tool`:return{role:`tool`,content:e.content.filter(e=>e.type!==`tool-approval-response`||e.providerExecuted).map(e=>{switch(e.type){case`tool-result`:return{type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:HW(e.output),providerOptions:e.providerOptions};case`tool-approval-response`:return{type:`tool-approval-response`,approvalId:e.approvalId,approved:e.approved,reason:e.reason}}}),providerOptions:e.providerOptions};default:throw new eW({role:n})}}async function BW(e,t,n){let r=e.filter(e=>e.role===`user`).map(e=>e.content).filter(e=>Array.isArray(e)).flat().filter(e=>e.type===`image`||e.type===`file`).map(e=>{let t=e.mediaType??(e.type===`image`?`image/*`:void 0),n=e.type===`image`?e.image:e.data;if(typeof n==`string`)try{n=new URL(n)}catch{}return{mediaType:t,data:n}}).filter(e=>e.data instanceof URL).map(e=>({url:e.data,isUrlSupportedByModel:e.mediaType!=null&&ER({url:e.data.toString(),mediaType:e.mediaType,supportedUrls:n})})),i=await t(r);return Object.fromEntries(i.map((e,t)=>e==null?null:[r[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>e!=null))}function VW(e,t){if(e.type===`text`)return{type:`text`,text:e.text,providerOptions:e.providerOptions};let n,r=e.type;switch(r){case`image`:n=e.image;break;case`file`:n=e.data;break;default:throw Error(`Unsupported part type: ${r}`)}let{data:i,mediaType:a}=IW(n),o=a??e.mediaType,s=i;if(s instanceof URL){let e=t[s.toString()];e&&(s=e.data,o??=e.mediaType)}switch(r){case`image`:return(s instanceof Uint8Array||typeof s==`string`)&&(o=AW({data:s,signatures:DW})??o),{type:`file`,mediaType:o??`image/*`,filename:void 0,data:s,providerOptions:e.providerOptions};case`file`:if(o==null)throw Error(`Media type is missing for file part`);return{type:`file`,mediaType:o,filename:e.filename,data:s,providerOptions:e.providerOptions}}}function HW(e){return e.type===`content`?{type:`content`,value:e.value.map(e=>e.type===`media`?e.mediaType.startsWith(`image/`)?{type:`image-data`,data:e.data,mediaType:e.mediaType}:{type:`file-data`,data:e.data,mediaType:e.mediaType}:e)}:e}async function UW({toolCallId:e,input:t,output:n,tool:r,errorMode:i}){return i===`text`?{type:`error-text`,value:OF(n)}:i===`json`?{type:`error-json`,value:WW(n)}:r?.toModelOutput?await r.toModelOutput({toolCallId:e,input:t,output:n}):typeof n==`string`?{type:`text`,value:n}:{type:`json`,value:WW(n)}}function WW(e){return e===void 0?null:e}function GW({maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:i,frequencyPenalty:a,seed:o,stopSequences:s}){if(e!=null){if(!Number.isInteger(e))throw new rU({parameter:`maxOutputTokens`,value:e,message:`maxOutputTokens must be an integer`});if(e<1)throw new rU({parameter:`maxOutputTokens`,value:e,message:`maxOutputTokens must be >= 1`})}if(t!=null&&typeof t!=`number`)throw new rU({parameter:`temperature`,value:t,message:`temperature must be a number`});if(n!=null&&typeof n!=`number`)throw new rU({parameter:`topP`,value:n,message:`topP must be a number`});if(r!=null&&typeof r!=`number`)throw new rU({parameter:`topK`,value:r,message:`topK must be a number`});if(i!=null&&typeof i!=`number`)throw new rU({parameter:`presencePenalty`,value:i,message:`presencePenalty must be a number`});if(a!=null&&typeof a!=`number`)throw new rU({parameter:`frequencyPenalty`,value:a,message:`frequencyPenalty must be a number`});if(o!=null&&!Number.isInteger(o))throw new rU({parameter:`seed`,value:o,message:`seed must be an integer`});return{maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:i,frequencyPenalty:a,stopSequences:s,seed:o}}function KW(e){return e!=null&&Object.keys(e).length>0}async function qW({tools:e,toolChoice:t,activeTools:n}){if(!KW(e))return{tools:void 0,toolChoice:void 0};let r=n==null?Object.entries(e):Object.entries(e).filter(([e])=>n.includes(e)),i=[];for(let[e,t]of r){let n=t.type;switch(n){case void 0:case`dynamic`:case`function`:i.push({type:`function`,name:e,description:t.description,inputSchema:await zz(t.inputSchema).jsonSchema,...t.inputExamples==null?{}:{inputExamples:t.inputExamples},providerOptions:t.providerOptions,...t.strict==null?{}:{strict:t.strict}});break;case`provider`:i.push({type:`provider`,name:e,id:t.id,args:t.args});break;default:throw Error(`Unsupported tool type: ${n}`)}}return{tools:i,toolChoice:t==null?{type:`auto`}:typeof t==`string`?{type:t}:{type:`tool`,toolName:t.toolName}}}var JW=h(()=>c([a(),y(),_(),r(),b(y(),JW.optional()),E(JW)])),$=b(y(),b(y(),JW.optional())),YW=k({type:s(`text`),text:y(),providerOptions:$.optional()}),XW=k({type:s(`image`),image:c([FW,o(URL)]),mediaType:y().optional(),providerOptions:$.optional()}),ZW=k({type:s(`file`),data:c([FW,o(URL)]),filename:y().optional(),mediaType:y(),providerOptions:$.optional()}),QW=k({type:s(`reasoning`),text:y(),providerOptions:$.optional()}),$W=k({type:s(`tool-call`),toolCallId:y(),toolName:y(),input:d(),providerOptions:$.optional(),providerExecuted:r().optional()}),eG=p(`type`,[k({type:s(`text`),value:y(),providerOptions:$.optional()}),k({type:s(`json`),value:JW,providerOptions:$.optional()}),k({type:s(`execution-denied`),reason:y().optional(),providerOptions:$.optional()}),k({type:s(`error-text`),value:y(),providerOptions:$.optional()}),k({type:s(`error-json`),value:JW,providerOptions:$.optional()}),k({type:s(`content`),value:E(c([k({type:s(`text`),text:y(),providerOptions:$.optional()}),k({type:s(`media`),data:y(),mediaType:y()}),k({type:s(`file-data`),data:y(),mediaType:y(),filename:y().optional(),providerOptions:$.optional()}),k({type:s(`file-url`),url:y(),providerOptions:$.optional()}),k({type:s(`file-id`),fileId:c([y(),b(y(),y())]),providerOptions:$.optional()}),k({type:s(`image-data`),data:y(),mediaType:y(),providerOptions:$.optional()}),k({type:s(`image-url`),url:y(),providerOptions:$.optional()}),k({type:s(`image-file-id`),fileId:c([y(),b(y(),y())]),providerOptions:$.optional()}),k({type:s(`custom`),providerOptions:$.optional()})]))})]),tG=k({type:s(`tool-result`),toolCallId:y(),toolName:y(),output:eG,providerOptions:$.optional()}),nG=k({type:s(`tool-approval-request`),approvalId:y(),toolCallId:y()}),rG=k({type:s(`tool-approval-response`),approvalId:y(),approved:r(),reason:y().optional()}),iG=c([k({role:s(`system`),content:y(),providerOptions:$.optional()}),k({role:s(`user`),content:c([y(),E(c([YW,XW,ZW]))]),providerOptions:$.optional()}),k({role:s(`assistant`),content:c([y(),E(c([YW,ZW,QW,$W,tG,nG]))]),providerOptions:$.optional()}),k({role:s(`tool`),content:E(c([tG,rG])),providerOptions:$.optional()})]);async function aG({allowSystemInMessages:e,system:t,prompt:n,messages:r}){if(n==null&&r==null)throw new BF({prompt:n,message:`prompt or messages must be defined`});if(n!=null&&r!=null)throw new BF({prompt:n,message:`prompt and messages cannot be defined at the same time`});if(typeof t!=`string`&&!dW(t).every(e=>e.role===`system`))throw new BF({prompt:n,message:`system must be a string, SystemModelMessage, or array of SystemModelMessage`});if(n!=null&&typeof n==`string`)r=[{role:`user`,content:n}];else if(n!=null&&Array.isArray(n))r=n;else if(r==null)throw new BF({prompt:n,message:`prompt or messages must be defined`});if(r.length===0)throw new BF({prompt:n,message:`messages must not be empty`});if(r.some(e=>e.role===`system`)){if(e===!1)throw new BF({prompt:n,message:`System messages are not allowed in the prompt or messages fields. Use the system option instead.`});e===void 0&&console.warn(`AI SDK Warning: System messages in the prompt or messages fields can be a security risk because they may enable prompt injection attacks. Use the system option instead when possible. Set allowSystemInMessages to true to suppress this warning, or false to throw an error.`)}let i=await Kz({value:r,schema:E(iG)});if(!i.success)throw new BF({prompt:n,message:`The messages do not match the ModelMessage[] schema.`,cause:i.error});return{messages:r,system:t}}function oG(e){if(!bB.isInstance(e))return e;let t=(process==null?void 0:`production`)===`production`,n=`https://ai-sdk.dev/unauthenticated-ai-gateway`;return t?new hF({name:`GatewayError`,message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${n}`}):Object.assign(Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
|
|
112
|
+
|
|
113
|
+
To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
|
|
114
|
+
|
|
115
|
+
Alternatively, you can use a provider module instead of the AI Gateway.
|
|
116
|
+
|
|
117
|
+
Learn more: \x1B[34m${n}\x1B[0m
|
|
118
|
+
|
|
119
|
+
`),{name:`GatewayAuthenticationError`})}function sG({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId==null?``:` ${t.functionId}`}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}function cG({model:e,settings:t,telemetry:n,headers:r}){return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((e,[t,n])=>{if(t===`timeout`){let r=wW(n);r!=null&&(e[`ai.settings.${t}`]=r)}else e[`ai.settings.${t}`]=n;return e},{}),...Object.entries(n?.metadata??{}).reduce((e,[t,n])=>(e[`ai.telemetry.metadata.${t}`]=n,e),{}),...Object.entries(r??{}).reduce((e,[t,n])=>(n!==void 0&&(e[`ai.request.headers.${t}`]=n),e),{})}}var lG={startSpan(){return uG},startActiveSpan(e,t,n,r){if(typeof t==`function`)return t(uG);if(typeof n==`function`)return n(uG);if(typeof r==`function`)return r(uG)}},uG={spanContext(){return dG},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},dG={traceId:``,spanId:``,traceFlags:0};function fG({isEnabled:e=!1,tracer:t}={}){return e?t||XH.getTracer(`ai`):lG}async function pG({name:e,tracer:t,attributes:n,fn:r,endWhenDone:i=!0}){return t.startActiveSpan(e,{attributes:await n},async e=>{let t=JH.active();try{let n=await JH.with(t,()=>r(e));return i&&e.end(),n}catch(t){try{mG(e,t)}finally{e.end()}throw t}})}function mG(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:qH.ERROR,message:t.message})):e.setStatus({code:qH.ERROR})}async function hG({telemetry:e,attributes:t}){if(e?.isEnabled!==!0)return{};let n={};for(let[r,i]of Object.entries(t))if(i!=null){if(typeof i==`object`&&`input`in i&&typeof i.input==`function`){if(e?.recordInputs===!1)continue;let t=await i.input();t!=null&&(n[r]=t);continue}if(typeof i==`object`&&`output`in i&&typeof i.output==`function`){if(e?.recordOutputs===!1)continue;let t=await i.output();t!=null&&(n[r]=t);continue}n[r]=i}return n}function gG(e){return JSON.stringify(e.map(e=>({...e,content:typeof e.content==`string`?e.content:e.content.map(e=>e.type===`file`?{...e,data:e.data instanceof Uint8Array?LW(e.data):e.data}:e)})))}function _G(){return globalThis.AI_SDK_TELEMETRY_INTEGRATIONS??[]}function vG(){let e=_G();return t=>{let n=dW(t),r=[...e,...n];function i(e){let t=r.map(e).filter(Boolean);return async e=>{for(let n of t)try{await n(e)}catch{}}}return{onStart:i(e=>e.onStart),onStepStart:i(e=>e.onStepStart),onToolCallStart:i(e=>e.onToolCallStart),onToolCallFinish:i(e=>e.onToolCallFinish),onStepFinish:i(e=>e.onStepFinish),onFinish:i(e=>e.onFinish)}}}function yG(e){return{inputTokens:e.inputTokens.total,inputTokenDetails:{noCacheTokens:e.inputTokens.noCache,cacheReadTokens:e.inputTokens.cacheRead,cacheWriteTokens:e.inputTokens.cacheWrite},outputTokens:e.outputTokens.total,outputTokenDetails:{textTokens:e.outputTokens.text,reasoningTokens:e.outputTokens.reasoning},totalTokens:SG(e.inputTokens.total,e.outputTokens.total),raw:e.raw,reasoningTokens:e.outputTokens.reasoning,cachedInputTokens:e.inputTokens.cacheRead}}function bG(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function xG(e,t){return{inputTokens:SG(e.inputTokens,t.inputTokens),inputTokenDetails:{noCacheTokens:SG(e.inputTokenDetails?.noCacheTokens,t.inputTokenDetails?.noCacheTokens),cacheReadTokens:SG(e.inputTokenDetails?.cacheReadTokens,t.inputTokenDetails?.cacheReadTokens),cacheWriteTokens:SG(e.inputTokenDetails?.cacheWriteTokens,t.inputTokenDetails?.cacheWriteTokens)},outputTokens:SG(e.outputTokens,t.outputTokens),outputTokenDetails:{textTokens:SG(e.outputTokenDetails?.textTokens,t.outputTokenDetails?.textTokens),reasoningTokens:SG(e.outputTokenDetails?.reasoningTokens,t.outputTokenDetails?.reasoningTokens)},totalTokens:SG(e.totalTokens,t.totalTokens),reasoningTokens:SG(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:SG(e.cachedInputTokens,t.cachedInputTokens)}}function SG(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function CG(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(!(r===`__proto__`||r===`constructor`||r===`prototype`)&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);o&&s?n[r]=CG(a,i):n[r]=i}return n}function wG({error:e,exponentialBackoffDelay:t}){let n=e.responseHeaders;if(!n)return t;let r,i=n[`retry-after-ms`];if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n[`retry-after`];if(a&&r===void 0){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():e*1e3}return r!=null&&!Number.isNaN(r)&&0<=r&&(r<60*1e3||r<t)?r:t}var TG=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r}={})=>async i=>EG(i,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:r});async function EG(e,{maxRetries:t,delayInMs:n,backoffFactor:r,abortSignal:i},a=[]){try{return await e()}catch(o){if(mR(o)||t===0)throw o;let s=pR(o),c=[...a,o],l=c.length;if(l>t)throw new uW({message:`Failed after ${l} attempts. Last error: ${s}`,reason:`maxRetriesExceeded`,errors:c});if(o instanceof Error&&xF.isInstance(o)&&o.isRetryable===!0&&l<=t)return await GL(wG({error:o,exponentialBackoffDelay:n}),{abortSignal:i}),EG(e,{maxRetries:t,delayInMs:r*n,backoffFactor:r,abortSignal:i},c);throw l===1?o:new uW({message:`Failed after ${l} attempts with non-retryable error: '${s}'`,reason:`errorNotRetryable`,errors:c})}}function DG({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new rU({parameter:`maxRetries`,value:e,message:`maxRetries must be an integer`});if(e<0)throw new rU({parameter:`maxRetries`,value:e,message:`maxRetries must be >= 0`})}let n=e??2;return{maxRetries:n,retry:TG({maxRetries:n,abortSignal:t})}}function OG({messages:e}){let t=e.at(-1);if(t?.role!=`tool`)return{approvedToolApprovals:[],deniedToolApprovals:[]};let n={};for(let t of e)if(t.role===`assistant`&&typeof t.content!=`string`){let e=t.content;for(let t of e)t.type===`tool-call`&&(n[t.toolCallId]=t)}let r={};for(let t of e)if(t.role===`assistant`&&typeof t.content!=`string`){let e=t.content;for(let t of e)t.type===`tool-approval-request`&&(r[t.approvalId]=t)}let i={};for(let e of t.content)e.type===`tool-result`&&(i[e.toolCallId]=e);let a=[],o=[],s=t.content.filter(e=>e.type===`tool-approval-response`);for(let e of s){let t=r[e.approvalId];if(t==null)throw new cU({approvalId:e.approvalId});if(i[t.toolCallId]!=null)continue;let s=n[t.toolCallId];if(s==null)throw new vU({toolCallId:t.toolCallId,approvalId:t.approvalId});let c={approvalRequest:t,approvalResponse:e,toolCall:s};e.approved?a.push(c):o.push(c)}return{approvedToolApprovals:a,deniedToolApprovals:o}}function kG(){return(globalThis==null?void 0:globalThis.performance)?.now()??Date.now()}async function AG({toolCall:e,tools:t,tracer:n,telemetry:r,messages:i,abortSignal:a,experimental_context:o,stepNumber:s,model:c,onPreliminaryToolResult:l,onToolCallStart:u,onToolCallFinish:d}){let{toolName:f,toolCallId:p,input:m}=e,h=t?.[f];if(h?.execute==null)return;let g={stepNumber:s,model:c,toolCall:e,messages:i,abortSignal:a,functionId:r?.functionId,metadata:r?.metadata,experimental_context:o};return pG({name:`ai.toolCall`,attributes:hG({telemetry:r,attributes:{...sG({operationId:`ai.toolCall`,telemetry:r}),"ai.toolCall.name":f,"ai.toolCall.id":p,"ai.toolCall.args":{output:()=>JSON.stringify(m)}}}),tracer:n,fn:async t=>{let n;await fW({event:g,callbacks:u});let s=kG();try{let t=sB({execute:h.execute.bind(h),input:m,options:{toolCallId:p,messages:i,abortSignal:a,experimental_context:o}});for await(let r of t)r.type===`preliminary`?l?.({...e,type:`tool-result`,output:r.output,preliminary:!0}):n=r.output}catch(n){let r=kG()-s;return await fW({event:{...g,success:!1,error:n,durationMs:r},callbacks:d}),mG(t,n),{type:`tool-error`,toolCallId:p,toolName:f,input:m,error:n,dynamic:h.type===`dynamic`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}}}let c=kG()-s;await fW({event:{...g,success:!0,output:n,durationMs:c},callbacks:d});try{t.setAttributes(await hG({telemetry:r,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(n)}}}))}catch{}return{type:`tool-result`,toolCallId:p,toolName:f,input:m,output:n,dynamic:h.type===`dynamic`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}}}})}function jG(e){let t=e.filter(e=>e.type===`reasoning`);return t.length===0?void 0:t.map(e=>e.text).join(`
|
|
120
|
+
`)}function MG(e){let t=e.filter(e=>e.type===`text`);if(t.length!==0)return t.map(e=>e.text).join(``)}var NG=class{constructor({data:e,mediaType:t}){let n=e instanceof Uint8Array;this.base64Data=n?void 0:e,this.uint8ArrayData=n?e:void 0,this.mediaType=t}get base64(){return this.base64Data??=QL(this.uint8ArrayData),this.base64Data}get uint8Array(){return this.uint8ArrayData??=ZL(this.base64Data),this.uint8ArrayData}},PG=class extends NG{constructor(e){super(e),this.type=`file`}};async function FG({tool:e,toolCall:t,messages:n,experimental_context:r}){return e.needsApproval==null?!1:typeof e.needsApproval==`boolean`?e.needsApproval:await e.needsApproval(t.input,{toolCallId:t.toolCallId,messages:n,experimental_context:r})}QH({},{array:()=>BG,choice:()=>VG,json:()=>HG,object:()=>zG,text:()=>RG});function IG(e){let t=[`ROOT`],n=-1,r=null;function i(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`);break}}function a(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop();break}}function o(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop();break}}for(let s=0;s<e.length;s++){let c=e[s];switch(t[t.length-1]){case`ROOT`:i(c,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=s,t.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break}break;case`INSIDE_OBJECT_KEY`:switch(c){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(c){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:i(c,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:a(c,s);break;case`INSIDE_STRING`:switch(c){case`"`:t.pop(),n=s;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(c){case`]`:n=s,t.pop();break;default:n=s,i(c,s,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(c){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=s,t.pop();break;default:n=s;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:i(c,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),n=s;break;case`INSIDE_NUMBER`:switch(c){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&a(c,s);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&a(c,s);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s);break;default:t.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?a(c,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&o(c,s)):n=s;break}}}let s=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:s+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:s+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:s+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?s+=`true`.slice(t.length):`false`.startsWith(t)?s+=`false`.slice(t.length):`null`.startsWith(t)&&(s+=`null`.slice(t.length))}}return s}async function LG(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await Jz({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await Jz({text:IG(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}var RG=()=>({name:`text`,responseFormat:Promise.resolve({type:`text`}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),zG=({schema:e,name:t,description:n})=>{let r=zz(e);return{name:`object`,responseFormat:tB(r.jsonSchema).then(e=>({type:`json`,schema:e,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:e},t){let n=await Jz({text:e});if(!n.success)throw new OU({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=await Kz({value:n.value,schema:r});if(!i.success)throw new OU({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return i.value},async parsePartialOutput({text:e}){let t=await LG(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value}}},createElementStreamTransform(){}}},BG=({element:e,name:t,description:n})=>{let r=zz(e);return{name:`array`,responseFormat:tB(r.jsonSchema).then(e=>{let{$schema:r,...i}=e;return{type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{elements:{type:`array`,items:i}},required:[`elements`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:e},t){let n=await Jz({text:e});if(!n.success)throw new OU({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=n.value;if(typeof i!=`object`||!i||!(`elements`in i)||!Array.isArray(i.elements))throw new OU({message:`No object generated: response did not match schema.`,cause:new QF({value:i,cause:`response must be an object with an elements array`}),text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});for(let n of i.elements){let i=await Kz({value:n,schema:r});if(!i.success)throw new OU({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason})}return i.elements},async parsePartialOutput({text:e}){let t=await LG(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let e=t.value;if(typeof e!=`object`||!e||!(`elements`in e)||!Array.isArray(e.elements))return;let n=t.state===`repaired-parse`&&e.elements.length>0?e.elements.slice(0,-1):e.elements,i=[];for(let e of n){let t=await Kz({value:e,schema:r});t.success&&i.push(t.value)}return{partial:i}}}},createElementStreamTransform(){let e=0;return new TransformStream({transform({partialOutput:t},n){if(t!=null)for(;e<t.length;e++)n.enqueue(t[e])}})}}},VG=({options:e,name:t,description:n})=>({name:`choice`,responseFormat:Promise.resolve({type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{result:{type:`string`,enum:e}},required:[`result`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:t},n){let r=await Jz({text:t});if(!r.success)throw new OU({message:`No object generated: could not parse the response.`,cause:r.error,text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=r.value;if(typeof i!=`object`||!i||!(`result`in i)||typeof i.result!=`string`||!e.includes(i.result))throw new OU({message:`No object generated: response did not match schema.`,cause:new QF({value:i,cause:`response must be an object that contains a choice value.`}),text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.result},async parsePartialOutput({text:t}){let n=await LG(t);switch(n.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let t=n.value;if(typeof t!=`object`||!t||!(`result`in t)||typeof t.result!=`string`)return;let r=e.filter(e=>e.startsWith(t.result));return n.state===`successful-parse`?r.includes(t.result)?{partial:t.result}:void 0:r.length===1?{partial:r[0]}:void 0}}},createElementStreamTransform(){}}),HG=({name:e,description:t}={})=>({name:`json`,responseFormat:Promise.resolve({type:`json`,...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:e},t){let n=await Jz({text:e});if(!n.success)throw new OU({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return n.value},async parsePartialOutput({text:e}){let t=await LG(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return t.value===void 0?void 0:{partial:t.value}}},createElementStreamTransform(){}});async function UG({toolCall:e,tools:t,repairToolCall:n,system:r,messages:i}){try{if(t==null){if(e.providerExecuted&&e.dynamic)return await WG(e);throw new RU({toolName:e.toolName})}try{return await GG({toolCall:e,tools:t})}catch(a){if(n==null||!(RU.isInstance(a)||pU.isInstance(a)))throw a;let o=null;try{o=await n({toolCall:e,tools:t,inputSchema:async({toolName:e})=>{let{inputSchema:n}=t[e];return await zz(n).jsonSchema},system:r,messages:i,error:a})}catch(e){throw new UU({cause:e,originalError:a})}if(o==null)throw a;return await GG({toolCall:o,tools:t})}}catch(n){let r=await Jz({text:e.input}),i=r.success?r.value:e.input,a=t?.[e.toolName];return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:i,dynamic:!0,invalid:!0,error:n,title:a?.title,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...a?.metadata==null?{}:{toolMetadata:a.metadata}}}}async function WG(e){let t=e.input.trim()===``?{success:!0,value:{}}:await Jz({text:e.input});if(t.success===!1)throw new pU({toolName:e.toolName,toolInput:e.input,cause:t.error});return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:t.value,providerExecuted:!0,dynamic:!0,providerMetadata:e.providerMetadata}}async function GG({toolCall:e,tools:t}){let n=e.toolName,r=t[n];if(r==null){if(e.providerExecuted&&e.dynamic)return await WG(e);throw new RU({toolName:e.toolName,availableTools:Object.keys(t)})}let i=zz(r.inputSchema),a=e.input.trim()===``?await Kz({value:{},schema:i}):await Jz({text:e.input,schema:i});if(a.success===!1)throw new pU({toolName:n,toolInput:e.input,cause:a.error});return r.type===`dynamic`?{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...r.metadata==null?{}:{toolMetadata:r.metadata},dynamic:!0,title:r.title}:{type:`tool-call`,toolCallId:e.toolCallId,toolName:n,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...r.metadata==null?{}:{toolMetadata:r.metadata},title:r.title}}var KG=class{constructor({stepNumber:e,model:t,functionId:n,metadata:r,experimental_context:i,content:a,finishReason:o,rawFinishReason:s,usage:c,warnings:l,request:u,response:d,providerMetadata:f}){this.stepNumber=e,this.model=t,this.functionId=n,this.metadata=r,this.experimental_context=i,this.content=a,this.finishReason=o,this.rawFinishReason=s,this.usage=c,this.warnings=l,this.request=u,this.response=d,this.providerMetadata=f}get text(){return this.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}get reasoning(){return this.content.filter(e=>e.type===`reasoning`)}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(e=>e.text).join(``)}get files(){return this.content.filter(e=>e.type===`file`).map(e=>e.file)}get sources(){return this.content.filter(e=>e.type===`source`)}get toolCalls(){return this.content.filter(e=>e.type===`tool-call`)}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type===`tool-result`)}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function qG(e){return({steps:t})=>t.length===e}async function JG({stopConditions:e,steps:t}){return(await Promise.all(e.map(e=>e({steps:t})))).some(e=>e)}async function YG({content:e,tools:t}){let n=[],r=[];for(let n of e)if(n.type!==`source`&&!((n.type===`tool-result`||n.type===`tool-error`)&&!n.providerExecuted)&&!(n.type===`text`&&n.text.length===0))switch(n.type){case`text`:r.push({type:`text`,text:n.text,providerOptions:n.providerMetadata});break;case`reasoning`:r.push({type:`reasoning`,text:n.text,providerOptions:n.providerMetadata});break;case`file`:r.push({type:`file`,data:n.file.base64,mediaType:n.file.mediaType,providerOptions:n.providerMetadata});break;case`tool-call`:r.push({type:`tool-call`,toolCallId:n.toolCallId,toolName:n.toolName,input:n.invalid&&typeof n.input!=`object`?{}:n.input,providerExecuted:n.providerExecuted,providerOptions:n.providerMetadata});break;case`tool-result`:{let e=await UW({toolCallId:n.toolCallId,input:n.input,tool:t?.[n.toolName],output:n.output,errorMode:`none`});r.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,providerOptions:n.providerMetadata});break}case`tool-error`:{let e=await UW({toolCallId:n.toolCallId,input:n.input,tool:t?.[n.toolName],output:n.error,errorMode:`json`});r.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,providerOptions:n.providerMetadata});break}case`tool-approval-request`:r.push({type:`tool-approval-request`,approvalId:n.approvalId,toolCallId:n.toolCall.toolCallId});break}r.length>0&&n.push({role:`assistant`,content:r});let i=[];for(let n of e){if(!(n.type===`tool-result`||n.type===`tool-error`)||n.providerExecuted)continue;let e=await UW({toolCallId:n.toolCallId,input:n.input,tool:t?.[n.toolName],output:n.type===`tool-result`?n.output:n.error,errorMode:n.type===`tool-error`?`text`:`none`});i.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}})}return i.length>0&&n.push({role:`tool`,content:i}),n}function XG(...e){let t=e.filter(e=>e!=null);if(t.length===0)return;if(t.length===1)return t[0];let n=new AbortController;for(let e of t){if(e.aborted)return n.abort(e.reason),n.signal;e.addEventListener(`abort`,()=>{n.abort(e.reason)},{once:!0})}return n.signal}var ZG=dR({prefix:`aitxt`,size:24});async function QG({model:e,tools:t,toolChoice:n,system:r,prompt:i,messages:a,allowSystemInMessages:o,maxRetries:s,abortSignal:c,timeout:l,headers:u,stopWhen:d=qG(1),experimental_output:f,output:p=f,experimental_telemetry:m,providerOptions:h,experimental_activeTools:g,activeTools:_=g,experimental_prepareStep:v,prepareStep:y=v,experimental_repairToolCall:b,experimental_download:x,experimental_context:S,experimental_include:C,_internal:{generateId:w=ZG}={},experimental_onStart:T,experimental_onStepStart:E,experimental_onToolCallStart:ee,experimental_onToolCallFinish:D,onStepFinish:O,onFinish:te,...k}){let ne=SW(e),re=vG(),ie=dW(d),A=wW(l),j=TW(l),ae=j==null?void 0:new AbortController,oe=XG(c,A==null?void 0:AbortSignal.timeout(A),ae?.signal),{maxRetries:se,retry:ce}=DG({maxRetries:s,abortSignal:oe}),M=GW(k),le=xR(u??{},`ai/${jW}`),ue=cG({model:ne,telemetry:m,headers:le,settings:{...M,maxRetries:se}}),de={provider:ne.provider,modelId:ne.modelId},fe=await aG({system:r,prompt:i,messages:a,allowSystemInMessages:o}),pe=re(m?.integrations);await fW({event:{model:de,system:r,prompt:i,messages:a,tools:t,toolChoice:n,activeTools:_,maxOutputTokens:M.maxOutputTokens,temperature:M.temperature,topP:M.topP,topK:M.topK,presencePenalty:M.presencePenalty,frequencyPenalty:M.frequencyPenalty,stopSequences:M.stopSequences,seed:M.seed,maxRetries:se,timeout:l,headers:u,providerOptions:h,stopWhen:d,output:p,abortSignal:c,include:C,functionId:m?.functionId,metadata:m?.metadata,experimental_context:S},callbacks:[T,pe.onStart]});let me=fG(m);try{return await pG({name:`ai.generateText`,attributes:hG({telemetry:m,attributes:{...sG({operationId:`ai.generateText`,telemetry:m}),...ue,"ai.model.provider":ne.provider,"ai.model.id":ne.modelId,"ai.prompt":{input:()=>JSON.stringify({system:r,prompt:i,messages:a})}}}),tracer:me,fn:async e=>{let i=fe.messages,a=[],{approvedToolApprovals:o,deniedToolApprovals:s}=OG({messages:i}),f=o.filter(e=>!e.toolCall.providerExecuted);if(s.length>0||f.length>0){let e=await $G({toolCalls:f.map(e=>e.toolCall),tools:t,tracer:me,telemetry:m,messages:i,abortSignal:oe,experimental_context:S,stepNumber:0,model:de,onToolCallStart:[ee,pe.onToolCallStart],onToolCallFinish:[D,pe.onToolCallFinish]}),n=[];for(let r of e){let e=await UW({toolCallId:r.toolCallId,input:r.input,tool:t?.[r.toolName],output:r.type===`tool-result`?r.output:r.error,errorMode:r.type===`tool-error`?`text`:`none`});n.push({type:`tool-result`,toolCallId:r.toolCallId,toolName:r.toolName,output:e})}for(let e of s)n.push({type:`tool-result`,toolCallId:e.toolCall.toolCallId,toolName:e.toolCall.toolName,output:{type:`execution-denied`,reason:e.approvalResponse.reason,...e.toolCall.providerExecuted&&{providerOptions:{openai:{approvalId:e.approvalResponse.approvalId}}}}});a.push({role:`tool`,content:n})}let g=GW(k),v,T=[],re=[],A=[],se=new Map;do{let e=j==null?void 0:setTimeout(()=>ae.abort(),j);try{let e=[...i,...a],o=await y?.({model:ne,steps:A,stepNumber:A.length,messages:e,experimental_context:S}),s=SW(o?.model??ne),f={provider:s.provider,modelId:s.modelId},te=await RW({prompt:{system:o?.system??fe.system,messages:o?.messages??e},supportedUrls:await s.supportedUrls,download:x});S=o?.experimental_context??S;let ie=o?.activeTools??_,{toolChoice:j,tools:ae}=await qW({tools:t,toolChoice:o?.toolChoice??n,activeTools:ie}),M=o?.messages??e,de=o?.system??fe.system,he=CG(h,o?.providerOptions);await fW({event:{stepNumber:A.length,model:f,system:de,messages:M,tools:t,toolChoice:j,activeTools:ie,steps:[...A],providerOptions:he,timeout:l,headers:u,stopWhen:d,output:p,abortSignal:c,include:C,functionId:m?.functionId,metadata:m?.metadata,experimental_context:S},callbacks:[E,pe.onStepStart]}),v=await ce(()=>pG({name:`ai.generateText.doGenerate`,attributes:hG({telemetry:m,attributes:{...sG({operationId:`ai.generateText.doGenerate`,telemetry:m}),...ue,"ai.model.provider":s.provider,"ai.model.id":s.modelId,"ai.prompt.messages":{input:()=>gG(te)},"ai.prompt.tools":{input:()=>ae?.map(e=>JSON.stringify(e))},"ai.prompt.toolChoice":{input:()=>j==null?void 0:JSON.stringify(j)},"gen_ai.system":s.provider,"gen_ai.request.model":s.modelId,"gen_ai.request.frequency_penalty":k.frequencyPenalty,"gen_ai.request.max_tokens":k.maxOutputTokens,"gen_ai.request.presence_penalty":k.presencePenalty,"gen_ai.request.stop_sequences":k.stopSequences,"gen_ai.request.temperature":k.temperature??void 0,"gen_ai.request.top_k":k.topK,"gen_ai.request.top_p":k.topP}}),tracer:me,fn:async e=>{let t=await s.doGenerate({...g,tools:ae,toolChoice:j,responseFormat:await p?.responseFormat,prompt:te,providerOptions:he,abortSignal:oe,headers:le}),n={id:t.response?.id??w(),timestamp:t.response?.timestamp??new Date,modelId:t.response?.modelId??s.modelId,headers:t.response?.headers,body:t.response?.body},r=yG(t.usage);return e.setAttributes(await hG({telemetry:m,attributes:{"ai.response.finishReason":t.finishReason.unified,"ai.response.text":{output:()=>MG(t.content)},"ai.response.reasoning":{output:()=>jG(t.content)},"ai.response.toolCalls":{output:()=>{let e=tK(t.content);return e==null?void 0:JSON.stringify(e)}},"ai.response.id":n.id,"ai.response.model":n.modelId,"ai.response.timestamp":n.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(t.providerMetadata),"ai.usage.inputTokens":t.usage.inputTokens.total,"ai.usage.inputTokenDetails.noCacheTokens":t.usage.inputTokens.noCache,"ai.usage.inputTokenDetails.cacheReadTokens":t.usage.inputTokens.cacheRead,"ai.usage.inputTokenDetails.cacheWriteTokens":t.usage.inputTokens.cacheWrite,"ai.usage.outputTokens":t.usage.outputTokens.total,"ai.usage.outputTokenDetails.textTokens":t.usage.outputTokens.text,"ai.usage.outputTokenDetails.reasoningTokens":t.usage.outputTokens.reasoning,"ai.usage.totalTokens":r.totalTokens,"ai.usage.reasoningTokens":t.usage.outputTokens.reasoning,"ai.usage.cachedInputTokens":t.usage.inputTokens.cacheRead,"gen_ai.response.finish_reasons":[t.finishReason.unified],"gen_ai.response.id":n.id,"gen_ai.response.model":n.modelId,"gen_ai.usage.input_tokens":t.usage.inputTokens.total,"gen_ai.usage.output_tokens":t.usage.outputTokens.total}})),{...t,response:n}}}));let ge=await Promise.all(v.content.filter(e=>e.type===`tool-call`).map(n=>UG({toolCall:n,tools:t,repairToolCall:b,system:r,messages:e}))),_e={};for(let n of ge){if(n.invalid)continue;let r=t?.[n.toolName];r!=null&&(r?.onInputAvailable!=null&&await r.onInputAvailable({input:n.input,toolCallId:n.toolCallId,messages:e,abortSignal:oe,experimental_context:S}),await FG({tool:r,toolCall:n,messages:e,experimental_context:S})&&(_e[n.toolCallId]={type:`tool-approval-request`,approvalId:w(),toolCall:n}))}let ve=ge.filter(e=>e.invalid&&e.dynamic);re=[];for(let e of ve)re.push({type:`tool-error`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,error:pR(e.error),dynamic:!0});T=ge.filter(e=>!e.providerExecuted),t!=null&&re.push(...await $G({toolCalls:T.filter(e=>!e.invalid&&_e[e.toolCallId]==null),tools:t,tracer:me,telemetry:m,messages:e,abortSignal:oe,experimental_context:S,stepNumber:A.length,model:f,onToolCallStart:[ee,pe.onToolCallStart],onToolCallFinish:[D,pe.onToolCallFinish]}));for(let e of ge){if(!e.providerExecuted)continue;let n=t?.[e.toolName];n?.type===`provider`&&n.supportsDeferredResults&&(v.content.some(t=>t.type===`tool-result`&&t.toolCallId===e.toolCallId)||se.set(e.toolCallId,{toolName:e.toolName}))}for(let e of v.content)e.type===`tool-result`&&se.delete(e.toolCallId);let N=nK({content:v.content,toolCalls:ge,toolOutputs:re,toolApprovalRequests:Object.values(_e),tools:t});a.push(...await YG({content:N,tools:t}));let ye=C?.requestBody??!0?v.request??{}:{...v.request,body:void 0},be={...v.response,messages:structuredClone(a),body:C?.responseBody??!0?v.response?.body:void 0},xe=A.length,Se=new KG({stepNumber:xe,model:f,functionId:m?.functionId,metadata:m?.metadata,experimental_context:S,content:N,finishReason:v.finishReason.unified,rawFinishReason:v.finishReason.raw,usage:yG(v.usage),warnings:v.warnings,providerMetadata:v.providerMetadata,request:ye,response:be});gW({warnings:v.warnings??[],provider:f.provider,model:f.modelId}),A.push(Se),await fW({event:Se,callbacks:[O,pe.onStepFinish]})}finally{e!=null&&clearTimeout(e)}}while((T.length>0&&re.length===T.length||se.size>0)&&!await JG({stopConditions:ie,steps:A}));e.setAttributes(await hG({telemetry:m,attributes:{"ai.response.finishReason":v.finishReason.unified,"ai.response.text":{output:()=>MG(v.content)},"ai.response.reasoning":{output:()=>jG(v.content)},"ai.response.toolCalls":{output:()=>{let e=tK(v.content);return e==null?void 0:JSON.stringify(e)}},"ai.response.providerMetadata":JSON.stringify(v.providerMetadata)}}));let M=A[A.length-1],he=A.reduce((e,t)=>xG(e,t.usage),{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0});e.setAttributes(await hG({telemetry:m,attributes:{"ai.usage.inputTokens":he.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":he.inputTokenDetails?.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":he.inputTokenDetails?.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":he.inputTokenDetails?.cacheWriteTokens,"ai.usage.outputTokens":he.outputTokens,"ai.usage.outputTokenDetails.textTokens":he.outputTokenDetails?.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":he.outputTokenDetails?.reasoningTokens,"ai.usage.totalTokens":he.totalTokens,"ai.usage.reasoningTokens":he.outputTokenDetails?.reasoningTokens,"ai.usage.cachedInputTokens":he.inputTokenDetails?.cacheReadTokens}})),await fW({event:{stepNumber:M.stepNumber,model:M.model,functionId:M.functionId,metadata:M.metadata,experimental_context:M.experimental_context,finishReason:M.finishReason,rawFinishReason:M.rawFinishReason,usage:M.usage,content:M.content,text:M.text,reasoningText:M.reasoningText,reasoning:M.reasoning,files:M.files,sources:M.sources,toolCalls:M.toolCalls,staticToolCalls:M.staticToolCalls,dynamicToolCalls:M.dynamicToolCalls,toolResults:M.toolResults,staticToolResults:M.staticToolResults,dynamicToolResults:M.dynamicToolResults,request:M.request,response:M.response,warnings:M.warnings,providerMetadata:M.providerMetadata,steps:A,totalUsage:he},callbacks:[te,pe.onFinish]});let ge;return M.finishReason===`stop`&&(ge=await(p??RG()).parseCompleteOutput({text:M.text},{response:M.response,usage:M.usage,finishReason:M.finishReason})),new eK({steps:A,totalUsage:he,output:ge})}})}catch(e){throw oG(e)}}async function $G({toolCalls:e,tools:t,tracer:n,telemetry:r,messages:i,abortSignal:a,experimental_context:o,stepNumber:s,model:c,onToolCallStart:l,onToolCallFinish:u}){return(await Promise.all(e.map(async e=>AG({toolCall:e,tools:t,tracer:n,telemetry:r,messages:i,abortSignal:a,experimental_context:o,stepNumber:s,model:c,onToolCallStart:l,onToolCallFinish:u})))).filter(e=>e!=null)}var eK=class{constructor(e){this.steps=e.steps,this._output=e.output,this.totalUsage=e.totalUsage}get finalStep(){return this.steps[this.steps.length-1]}get content(){return this.finalStep.content}get text(){return this.finalStep.text}get files(){return this.finalStep.files}get reasoningText(){return this.finalStep.reasoningText}get reasoning(){return this.finalStep.reasoning}get toolCalls(){return this.finalStep.toolCalls}get staticToolCalls(){return this.finalStep.staticToolCalls}get dynamicToolCalls(){return this.finalStep.dynamicToolCalls}get toolResults(){return this.finalStep.toolResults}get staticToolResults(){return this.finalStep.staticToolResults}get dynamicToolResults(){return this.finalStep.dynamicToolResults}get sources(){return this.finalStep.sources}get finishReason(){return this.finalStep.finishReason}get rawFinishReason(){return this.finalStep.rawFinishReason}get warnings(){return this.finalStep.warnings}get providerMetadata(){return this.finalStep.providerMetadata}get response(){return this.finalStep.response}get request(){return this.finalStep.request}get usage(){return this.finalStep.usage}get experimental_output(){return this.output}get output(){if(this._output==null)throw new NU;return this._output}};function tK(e){let t=e.filter(e=>e.type===`tool-call`);if(t.length!==0)return t.map(e=>({toolCallId:e.toolCallId,toolName:e.toolName,input:e.input}))}function nK({content:e,toolCalls:t,toolOutputs:n,toolApprovalRequests:r,tools:i}){let a=[];for(let n of e)switch(n.type){case`text`:case`reasoning`:case`source`:a.push(n);break;case`file`:a.push({type:`file`,file:new NG(n),...n.providerMetadata==null?{}:{providerMetadata:n.providerMetadata}});break;case`tool-call`:a.push(t.find(e=>e.toolCallId===n.toolCallId));break;case`tool-result`:{let e=t.find(e=>e.toolCallId===n.toolCallId);if(e==null){let e=i?.[n.toolName];if(!(e?.type===`provider`&&e.supportsDeferredResults))throw Error(`Tool call ${n.toolCallId} not found.`);n.isError?a.push({type:`tool-error`,toolCallId:n.toolCallId,toolName:n.toolName,input:void 0,error:n.result,providerExecuted:!0,dynamic:n.dynamic,...n.providerMetadata==null?{}:{providerMetadata:n.providerMetadata},...e?.metadata==null?{}:{toolMetadata:e.metadata}}):a.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,input:void 0,output:n.result,providerExecuted:!0,dynamic:n.dynamic,...n.providerMetadata==null?{}:{providerMetadata:n.providerMetadata},...e?.metadata==null?{}:{toolMetadata:e.metadata}});break}n.isError?a.push({type:`tool-error`,toolCallId:n.toolCallId,toolName:n.toolName,input:e.input,error:n.result,providerExecuted:!0,dynamic:e.dynamic,...n.providerMetadata==null?{}:{providerMetadata:n.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}}):a.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,input:e.input,output:n.result,providerExecuted:!0,dynamic:e.dynamic,...n.providerMetadata==null?{}:{providerMetadata:n.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}});break}case`tool-approval-request`:{let e=t.find(e=>e.toolCallId===n.toolCallId);if(e==null)throw new vU({toolCallId:n.toolCallId,approvalId:n.approvalId});a.push({type:`tool-approval-request`,approvalId:n.approvalId,toolCall:e});break}}return[...a,...n,...r]}function rK(e,t){let n=new Headers(e??{});for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r);return n}function iK({status:e,statusText:t,headers:n,textStream:r}){return new Response(r.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:rK(n,{"content-type":`text/plain; charset=utf-8`})})}function aK({response:e,status:t,statusText:n,headers:r,stream:i}){let a=t??200;n===void 0?e.writeHead(a,r):e.writeHead(a,n,r);let o=i.getReader();(async()=>{try{for(;;){let{done:t,value:n}=await o.read();if(t)break;e.write(n)||await new Promise(t=>{e.once(`drain`,t)})}}catch(e){throw e}finally{e.end()}})()}function oK({response:e,status:t,statusText:n,headers:r,textStream:i}){aK({response:e,status:t,statusText:n,headers:Object.fromEntries(rK(r,{"content-type":`text/plain; charset=utf-8`}).entries()),stream:i.pipeThrough(new TextEncoderStream)})}var sK=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
121
|
+
|
|
122
|
+
`)},flush(e){e.enqueue(`data: [DONE]
|
|
123
|
+
|
|
124
|
+
`)}})}},cK={"content-type":`text/event-stream`,"cache-control":`no-cache`,connection:`keep-alive`,"x-vercel-ai-ui-message-stream":`v1`,"x-accel-buffering":`no`};function lK({status:e,statusText:t,headers:n,stream:r,consumeSseStream:i}){let a=r.pipeThrough(new sK);if(i){let[e,t]=a.tee();a=e,i({stream:t})}return new Response(a.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:rK(n,cK)})}function uK({originalMessages:e,responseMessageId:t}){if(e==null)return;let n=e[e.length-1];return n?.role===`assistant`?n.id:typeof t==`function`?t():t}var dK=b(y(),JW.optional()),fK=Iz(()=>Wz(c([l({type:s(`text-start`),id:y(),providerMetadata:$.optional()}),l({type:s(`text-delta`),id:y(),delta:y(),providerMetadata:$.optional()}),l({type:s(`text-end`),id:y(),providerMetadata:$.optional()}),l({type:s(`error`),errorText:y()}),l({type:s(`tool-input-start`),toolCallId:y(),toolName:y(),providerExecuted:r().optional(),providerMetadata:$.optional(),toolMetadata:dK.optional(),dynamic:r().optional(),title:y().optional()}),l({type:s(`tool-input-delta`),toolCallId:y(),inputTextDelta:y()}),l({type:s(`tool-input-available`),toolCallId:y(),toolName:y(),input:d(),providerExecuted:r().optional(),providerMetadata:$.optional(),toolMetadata:dK.optional(),dynamic:r().optional(),title:y().optional()}),l({type:s(`tool-input-error`),toolCallId:y(),toolName:y(),input:d(),providerExecuted:r().optional(),providerMetadata:$.optional(),toolMetadata:dK.optional(),dynamic:r().optional(),errorText:y(),title:y().optional()}),l({type:s(`tool-approval-request`),approvalId:y(),toolCallId:y()}),l({type:s(`tool-output-available`),toolCallId:y(),output:d(),providerExecuted:r().optional(),providerMetadata:$.optional(),toolMetadata:dK.optional(),dynamic:r().optional(),preliminary:r().optional()}),l({type:s(`tool-output-error`),toolCallId:y(),errorText:y(),providerExecuted:r().optional(),providerMetadata:$.optional(),toolMetadata:dK.optional(),dynamic:r().optional()}),l({type:s(`tool-output-denied`),toolCallId:y()}),l({type:s(`reasoning-start`),id:y(),providerMetadata:$.optional()}),l({type:s(`reasoning-delta`),id:y(),delta:y(),providerMetadata:$.optional()}),l({type:s(`reasoning-end`),id:y(),providerMetadata:$.optional()}),l({type:s(`source-url`),sourceId:y(),url:y(),title:y().optional(),providerMetadata:$.optional()}),l({type:s(`source-document`),sourceId:y(),mediaType:y(),title:y(),filename:y().optional(),providerMetadata:$.optional()}),l({type:s(`file`),url:y(),mediaType:y(),providerMetadata:$.optional()}),l({type:T(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:y().optional(),data:d(),transient:r().optional()}),l({type:s(`start-step`)}),l({type:s(`finish-step`)}),l({type:s(`start`),messageId:y().optional(),messageMetadata:d().optional()}),l({type:s(`finish`),finishReason:v([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`]).optional(),messageMetadata:d().optional()}),l({type:s(`abort`),reason:y().optional()}),l({type:s(`message-metadata`),messageMetadata:d()})])));function pK(e){return e.type.startsWith(`data-`)}function mK(e){return e.type.startsWith(`data-`)}function hK(e){return e.type===`text`}function gK(e){return e.type===`file`}function _K(e){return e.type===`reasoning`}function vK(e){return e.type.startsWith(`tool-`)}function yK(e){return e.type===`dynamic-tool`}function bK(e){return vK(e)||yK(e)}function xK(e){return e.type.split(`-`).slice(1).join(`-`)}function SK(e){return yK(e)?e.toolName:xK(e)}function CK({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function wK({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{function l(e){let t=r.message.parts.filter(bK).find(t=>t.toolCallId===e);if(t==null)throw new YU({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function u(e){let t=r.message.parts.find(t=>vK(t)&&t.toolCallId===e.toolCallId),n=e,i=t;if(t!=null){t.state=e.state,i.input=n.input,i.output=n.output,i.errorText=n.errorText,i.rawInput=n.rawInput,i.preliminary=n.preliminary,e.title!==void 0&&(i.title=e.title),e.toolMetadata!==void 0&&(i.toolMetadata=e.toolMetadata),i.providerExecuted=n.providerExecuted??t.providerExecuted;let r=n.providerMetadata;if(r!=null)if(e.state===`output-available`||e.state===`output-error`){let e=t;e.resultProviderMetadata=r}else t.callProviderMetadata=r}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:n.input,output:n.output,rawInput:n.rawInput,errorText:n.errorText,providerExecuted:n.providerExecuted,preliminary:n.preliminary,...n.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:n.providerMetadata}:{},...n.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:n.providerMetadata}:{}})}function d(e){let t=r.message.parts.find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),n=e,i=t;if(t!=null){t.state=e.state,i.toolName=e.toolName,i.input=n.input,i.output=n.output,i.errorText=n.errorText,i.rawInput=n.rawInput??i.rawInput,i.preliminary=n.preliminary,e.title!==void 0&&(i.title=e.title),e.toolMetadata!==void 0&&(i.toolMetadata=e.toolMetadata),i.providerExecuted=n.providerExecuted??t.providerExecuted;let r=n.providerMetadata;if(r!=null)if(e.state===`output-available`||e.state===`output-error`){let e=t;e.resultProviderMetadata=r}else t.callProviderMetadata=r}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:n.input,output:n.output,errorText:n.errorText,preliminary:n.preliminary,providerExecuted:n.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...n.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:n.providerMetadata}:{},...n.providerMetadata!=null&&!(e.state===`output-available`||e.state===`output-error`)?{callProviderMetadata:n.providerMetadata}:{}})}async function f(e){if(e!=null){let n=r.message.metadata==null?e:CG(r.message.metadata,e);t!=null&&await Gz({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new YU({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new YU({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`reasoning-start`:{let t={type:`reasoning`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new YU({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new YU({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:r.message.parts.push({type:`file`,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=r.message.parts.filter(vK);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new YU({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let{value:n}=await LG(t.text);t.dynamic?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-input-available`:e.dynamic?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=r.message.parts.filter(bK).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?d({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):u({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),c();break}case`tool-approval-request`:{let t=l(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId},c();break}case`tool-output-denied`:{let t=l(e.toolCallId);t.state=`output-denied`,c();break}case`tool-output-available`:{let t=l(e.toolCallId);t.type===`dynamic-tool`?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:xK(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-output-error`:{let t=l(e.toolCallId);t.type===`dynamic-tool`?d({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}):u({toolCallId:e.toolCallId,toolName:xK(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:r.activeTextParts={},r.activeReasoningParts={};break;case`start`:e.messageId!=null&&(r.message.id=e.messageId),await f(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c();break;case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await f(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await f(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(pK(e)){if(n?.[e.type]!=null){let t=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=t>=0?t:r.message.parts.length;await Gz({value:e.data,schema:n[e.type],context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}function TK({messageId:e,originalMessages:t=[],onStepFinish:n,onFinish:r,onError:i,stream:a}){let o=t?.[t.length-1];o?.role===`assistant`?e=o.id:o=void 0;let s=!1,c=a.pipeThrough(new TransformStream({transform(t,n){if(t.type===`start`){let n=t;n.messageId==null&&e!=null&&(n.messageId=e)}t.type===`abort`&&(s=!0),n.enqueue(t)}}));if(r==null&&n==null)return c;let l=CK({lastMessage:o?structuredClone(o):void 0,messageId:e??``}),u=async e=>{await e({state:l,write:()=>{}})},d=!1,f=async()=>{if(d||!r)return;d=!0;let e=l.message.id===o?.id;await r({isAborted:s,isContinuation:e,responseMessage:l.message,messages:[...e?t.slice(0,-1):t,l.message],finishReason:l.finishReason})},p=async()=>{if(!n)return;let e=l.message.id===o?.id;try{await n({isContinuation:e,responseMessage:structuredClone(l.message),messages:[...e?t.slice(0,-1):t,structuredClone(l.message)]})}catch(e){i(e)}};return wK({stream:c,runUpdateMessageJob:u,onError:i}).pipeThrough(new TransformStream({async transform(e,t){e.type===`finish-step`&&await p(),t.enqueue(e)},async cancel(){await f()},async flush(){await f()}}))}function EK({response:e,status:t,statusText:n,headers:r,stream:i,consumeSseStream:a}){let o=i.pipeThrough(new sK);if(a){let[e,t]=o.tee();o=e,a({stream:t})}aK({response:e,status:t,statusText:n,headers:Object.fromEntries(rK(r,cK).entries()),stream:o.pipeThrough(new TextEncoderStream)})}function DK(e){let t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){let e=this.getReader(),t=!1;async function n(n){if(!t){t=!0;try{n&&await e.cancel?.call(e)}finally{try{e.releaseLock()}catch{}}}}return{async next(){if(t)return{done:!0,value:void 0};let{done:r,value:i}=await e.read();return r?(await n(!0),{done:!0,value:void 0}):{done:!1,value:i}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(e){throw await n(!0),e}}},t}async function OK({stream:e,onError:t}){let n=e.getReader();try{for(;;){let{done:e}=await n.read();if(e)break}}catch(e){t?.(e)}finally{n.releaseLock()}}function kK(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function AK(){let e=[],t=null,n=!1,r=kK(),i=()=>{n=!0,r.resolve(),e.forEach(e=>e.cancel()),e=[],t?.close()},a=async()=>{if(n&&e.length===0){t?.close();return}if(e.length===0)return r=kK(),await r.promise,a();try{let{value:r,done:i}=await e[0].read();i?(e.shift(),e.length===0&&n?t?.close():await a()):t?.enqueue(r)}catch(n){t?.error(n),e.shift(),i()}};return{stream:new ReadableStream({start(e){t=e},pull:a,async cancel(){for(let t of e)await t.cancel();e=[],n=!0}}),addStream:t=>{if(n)throw Error(`Cannot add inner stream: outer stream is closed`);e.push(t.getReader()),r.resolve()},close:()=>{n=!0,r.resolve(),e.length===0&&t?.close()},terminate:i}}function jK({tools:e,generatorStream:t,tracer:n,telemetry:r,system:i,messages:a,abortSignal:o,repairToolCall:s,experimental_context:c,generateId:l,stepNumber:u,model:d,onToolCallStart:f,onToolCallFinish:p}){let m=null,h=new ReadableStream({start(e){m=e}}),g=new Set,_=new Map,v=new Map,y=!1,b;function x(){y&&g.size===0&&(b!=null&&m.enqueue(b),m.close())}let S=new TransformStream({async transform(t,h){let y=t.type;switch(y){case`stream-start`:case`text-start`:case`text-delta`:case`text-end`:case`reasoning-start`:case`reasoning-delta`:case`reasoning-end`:case`tool-input-start`:case`tool-input-delta`:case`tool-input-end`:case`source`:case`response-metadata`:case`error`:case`raw`:h.enqueue(t);break;case`file`:h.enqueue({type:`file`,file:new PG({data:t.data,mediaType:t.mediaType}),...t.providerMetadata==null?{}:{providerMetadata:t.providerMetadata}});break;case`finish`:b={type:`finish`,finishReason:t.finishReason.unified,rawFinishReason:t.finishReason.raw,usage:yG(t.usage),providerMetadata:t.providerMetadata};break;case`tool-approval-request`:{let e=v.get(t.toolCallId);if(e==null){m.enqueue({type:`error`,error:new vU({toolCallId:t.toolCallId,approvalId:t.approvalId})});break}h.enqueue({type:`tool-approval-request`,approvalId:t.approvalId,toolCall:e});break}case`tool-call`:try{let y=await UG({toolCall:t,tools:e,repairToolCall:s,system:i,messages:a});if(v.set(y.toolCallId,y),h.enqueue(y),y.invalid){m.enqueue({type:`tool-error`,toolCallId:y.toolCallId,toolName:y.toolName,input:y.input,error:pR(y.error),dynamic:!0,title:y.title,...y.toolMetadata==null?{}:{toolMetadata:y.toolMetadata}});break}let b=e?.[y.toolName];if(b==null)break;if(b.onInputAvailable!=null&&await b.onInputAvailable({input:y.input,toolCallId:y.toolCallId,messages:a,abortSignal:o,experimental_context:c}),await FG({tool:b,toolCall:y,messages:a,experimental_context:c})){m.enqueue({type:`tool-approval-request`,approvalId:l(),toolCall:y});break}if(_.set(y.toolCallId,y.input),b.execute!=null&&y.providerExecuted!==!0){let t=l();g.add(t),AG({toolCall:y,tools:e,tracer:n,telemetry:r,messages:a,abortSignal:o,experimental_context:c,stepNumber:u,model:d,onToolCallStart:f,onToolCallFinish:p,onPreliminaryToolResult:e=>{m.enqueue(e)}}).then(e=>{m.enqueue(e)}).catch(e=>{m.enqueue({type:`error`,error:e})}).finally(()=>{g.delete(t),x()})}}catch(e){m.enqueue({type:`error`,error:e})}break;case`tool-result`:{let e=t.toolName,n=v.get(t.toolCallId);t.isError?m.enqueue({type:`tool-error`,toolCallId:t.toolCallId,toolName:e,input:_.get(t.toolCallId),providerExecuted:!0,error:t.result,dynamic:t.dynamic,...t.providerMetadata==null?{}:{providerMetadata:t.providerMetadata},...n?.toolMetadata==null?{}:{toolMetadata:n.toolMetadata}}):h.enqueue({type:`tool-result`,toolCallId:t.toolCallId,toolName:e,input:_.get(t.toolCallId),output:t.result,providerExecuted:!0,dynamic:t.dynamic,...t.providerMetadata==null?{}:{providerMetadata:t.providerMetadata},...n?.toolMetadata==null?{}:{toolMetadata:n.toolMetadata}});break}default:throw Error(`Unhandled chunk type: ${y}`)}},flush(){y=!0,x()}});return new ReadableStream({async start(e){return Promise.all([t.pipeThrough(S).pipeTo(new WritableStream({write(t){e.enqueue(t)},close(){}})),h.pipeTo(new WritableStream({write(t){e.enqueue(t)},close(){e.close()}}))])}})}var MK=dR({prefix:`aitxt`,size:24});function NK({model:e,tools:t,toolChoice:n,system:r,prompt:i,messages:a,allowSystemInMessages:o,maxRetries:s,abortSignal:c,timeout:l,headers:u,stopWhen:d=qG(1),experimental_output:f,output:p=f,experimental_telemetry:m,prepareStep:h,providerOptions:g,experimental_activeTools:_,activeTools:v=_,experimental_repairToolCall:y,experimental_transform:b,experimental_download:x,includeRawChunks:S=!1,onChunk:C,onError:w=({error:e})=>{console.error(e)},onFinish:T,onAbort:E,onStepFinish:ee,experimental_onStart:D,experimental_onStepStart:O,experimental_onToolCallStart:te,experimental_onToolCallFinish:k,experimental_context:ne,experimental_include:re,_internal:{now:ie=kG,generateId:A=MK}={},...j}){let ae=wW(l),oe=TW(l),se=EW(l),ce=oe==null?void 0:new AbortController,M=se==null?void 0:new AbortController;return new FK({model:SW(e),telemetry:m,headers:u,settings:j,maxRetries:s,abortSignal:XG(c,ae==null?void 0:AbortSignal.timeout(ae),ce?.signal,M?.signal),stepTimeoutMs:oe,stepAbortController:ce,chunkTimeoutMs:se,chunkAbortController:M,system:r,prompt:i,messages:a,allowSystemInMessages:o,tools:t,toolChoice:n,transforms:dW(b),activeTools:v,repairToolCall:y,stopConditions:dW(d),output:p,providerOptions:g,prepareStep:h,includeRawChunks:S,timeout:l,stopWhen:d,originalAbortSignal:c,onChunk:C,onError:w,onFinish:T,onAbort:E,onStepFinish:ee,onStart:D,onStepStart:O,onToolCallStart:te,onToolCallFinish:k,now:ie,generateId:A,experimental_context:ne,download:x,include:re})}function PK(e){let t,n=``,r=``,i,a=``;function o({controller:e,partialOutput:n=void 0}){e.enqueue({part:{type:`text-delta`,id:t,text:r,providerMetadata:i},partialOutput:n}),r=``}return new TransformStream({async transform(s,c){if(s.type===`finish-step`&&r.length>0&&o({controller:c}),s.type!==`text-delta`&&s.type!==`text-start`&&s.type!==`text-end`){c.enqueue({part:s,partialOutput:void 0});return}if(t==null)t=s.id;else if(s.id!==t){c.enqueue({part:s,partialOutput:void 0});return}if(s.type===`text-start`){c.enqueue({part:s,partialOutput:void 0});return}if(s.type===`text-end`){r.length>0&&o({controller:c}),c.enqueue({part:s,partialOutput:void 0});return}n+=s.text,r+=s.text,i=s.providerMetadata??i;let l=await e.parsePartialOutput({text:n});if(l!==void 0){let e=typeof l.partial==`string`?l.partial:JSON.stringify(l.partial);e!==a&&(o({controller:c,partialOutput:l.partial}),a=e)}}})}var FK=class{constructor({model:e,telemetry:t,headers:n,settings:r,maxRetries:i,abortSignal:a,stepTimeoutMs:o,stepAbortController:s,chunkTimeoutMs:c,chunkAbortController:l,system:u,prompt:d,messages:f,allowSystemInMessages:p,tools:m,toolChoice:h,transforms:g,activeTools:_,repairToolCall:v,stopConditions:y,output:b,providerOptions:x,prepareStep:S,includeRawChunks:C,now:w,generateId:T,timeout:E,stopWhen:ee,originalAbortSignal:D,onChunk:O,onError:te,onFinish:k,onAbort:ne,onStepFinish:re,onStart:ie,onStepStart:A,onToolCallStart:j,onToolCallFinish:ae,experimental_context:oe,download:se,include:ce}){this._totalUsage=new qL,this._finishReason=new qL,this._rawFinishReason=new qL,this._steps=new qL,this.outputSpecification=b,this.includeRawChunks=C,this.tools=m;let M=vG()(t?.integrations),le,ue=[],de=[],fe,pe,me,he={},ge=[],_e=[],ve=new Map,N,ye={},be={},xe=new TransformStream({async transform(e,t){t.enqueue(e);let{part:n}=e;if((n.type===`text-delta`||n.type===`reasoning-delta`||n.type===`source`||n.type===`tool-call`||n.type===`tool-result`||n.type===`tool-input-start`||n.type===`tool-input-delta`||n.type===`raw`)&&await O?.({chunk:n}),n.type===`error`&&await te({error:oG(n.error)}),n.type===`text-start`&&(ye[n.id]={type:`text`,text:``,providerMetadata:n.providerMetadata},ue.push(ye[n.id])),n.type===`text-delta`){let e=ye[n.id];if(e==null){t.enqueue({part:{type:`error`,error:`text part ${n.id} not found`},partialOutput:void 0});return}e.text+=n.text,e.providerMetadata=n.providerMetadata??e.providerMetadata}if(n.type===`text-end`){let e=ye[n.id];if(e==null){t.enqueue({part:{type:`error`,error:`text part ${n.id} not found`},partialOutput:void 0});return}e.providerMetadata=n.providerMetadata??e.providerMetadata,delete ye[n.id]}if(n.type===`reasoning-start`&&(be[n.id]={type:`reasoning`,text:``,providerMetadata:n.providerMetadata},ue.push(be[n.id])),n.type===`reasoning-delta`){let e=be[n.id];if(e==null){t.enqueue({part:{type:`error`,error:`reasoning part ${n.id} not found`},partialOutput:void 0});return}e.text+=n.text,e.providerMetadata=n.providerMetadata??e.providerMetadata}if(n.type===`reasoning-end`){let e=be[n.id];if(e==null){t.enqueue({part:{type:`error`,error:`reasoning part ${n.id} not found`},partialOutput:void 0});return}e.providerMetadata=n.providerMetadata??e.providerMetadata,delete be[n.id]}if(n.type===`file`&&ue.push({type:`file`,file:n.file,...n.providerMetadata==null?{}:{providerMetadata:n.providerMetadata}}),n.type===`source`&&ue.push(n),n.type===`tool-call`&&ue.push(n),n.type===`tool-result`&&!n.preliminary&&ue.push(n),n.type===`tool-approval-request`&&ue.push(n),n.type===`tool-error`&&ue.push(n),n.type===`start-step`&&(ue=[],be={},ye={},he=n.request,ge=n.warnings),n.type===`finish-step`){let e=await YG({content:ue,tools:m}),t=new KG({stepNumber:_e.length,model:je,...Me,experimental_context:oe,content:ue,finishReason:n.finishReason,rawFinishReason:n.rawFinishReason,usage:n.usage,warnings:ge,request:he,response:{...n.response,messages:[...de,...e]},providerMetadata:n.providerMetadata});await fW({event:t,callbacks:[re,M.onStepFinish]}),gW({warnings:ge,provider:je.provider,model:je.modelId}),_e.push(t),de.push(...e),le.resolve()}n.type===`finish`&&(me=n.totalUsage,fe=n.finishReason,pe=n.rawFinishReason)},async flush(e){try{if(_e.length===0){let e=a?.aborted?a.reason:new NU({message:`No output generated. Check the stream for errors.`});Ae._finishReason.reject(e),Ae._rawFinishReason.reject(e),Ae._totalUsage.reject(e),Ae._steps.reject(e);return}let e=fe??`other`,n=me??bG();Ae._finishReason.resolve(e),Ae._rawFinishReason.resolve(pe),Ae._totalUsage.resolve(n),Ae._steps.resolve(_e);let r=_e[_e.length-1];await fW({event:{stepNumber:r.stepNumber,model:r.model,functionId:r.functionId,metadata:r.metadata,experimental_context:r.experimental_context,finishReason:r.finishReason,rawFinishReason:r.rawFinishReason,totalUsage:n,usage:r.usage,content:r.content,text:r.text,reasoningText:r.reasoningText,reasoning:r.reasoning,files:r.files,sources:r.sources,toolCalls:r.toolCalls,staticToolCalls:r.staticToolCalls,dynamicToolCalls:r.dynamicToolCalls,toolResults:r.toolResults,staticToolResults:r.staticToolResults,dynamicToolResults:r.dynamicToolResults,request:r.request,response:r.response,warnings:r.warnings,providerMetadata:r.providerMetadata,steps:_e},callbacks:[k,M.onFinish]}),N.setAttributes(await hG({telemetry:t,attributes:{"ai.response.finishReason":e,"ai.response.text":{output:()=>r.text},"ai.response.reasoning":{output:()=>r.reasoningText},"ai.response.toolCalls":{output:()=>r.toolCalls?.length?JSON.stringify(r.toolCalls):void 0},"ai.response.providerMetadata":JSON.stringify(r.providerMetadata),"ai.usage.inputTokens":n.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":n.inputTokenDetails?.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":n.inputTokenDetails?.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":n.inputTokenDetails?.cacheWriteTokens,"ai.usage.outputTokens":n.outputTokens,"ai.usage.outputTokenDetails.textTokens":n.outputTokenDetails?.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":n.outputTokenDetails?.reasoningTokens,"ai.usage.totalTokens":n.totalTokens,"ai.usage.reasoningTokens":n.outputTokenDetails?.reasoningTokens,"ai.usage.cachedInputTokens":n.inputTokenDetails?.cacheReadTokens}}))}catch(t){e.error(t)}finally{N.end()}}}),Se=AK();this.addStream=Se.addStream,this.closeStream=Se.close;let Ce=Se.stream.getReader(),we=new ReadableStream({async start(e){e.enqueue({type:`start`})},async pull(e){function t(){ne?.({steps:_e}),e.enqueue({type:`abort`,...a?.reason===void 0?{}:{reason:OF(a.reason)}}),e.close()}try{let{done:n,value:r}=await Ce.read();if(n){e.close();return}if(a?.aborted){t();return}e.enqueue(r)}catch(n){mR(n)&&a?.aborted?t():e.error(n)}},cancel(e){return Se.stream.cancel(e)}});for(let e of g)we=we.pipeThrough(e({tools:m,stopStream(){Se.terminate()}}));this.baseStream=we.pipeThrough(PK(b??RG())).pipeThrough(xe);let{maxRetries:Te,retry:Ee}=DG({maxRetries:i,abortSignal:a}),De=fG(t),Oe=GW(r),ke=cG({model:e,telemetry:t,headers:n,settings:{...Oe,maxRetries:Te}}),Ae=this,je={provider:e.provider,modelId:e.modelId},Me={functionId:t?.functionId,metadata:t?.metadata};pG({name:`ai.streamText`,attributes:hG({telemetry:t,attributes:{...sG({operationId:`ai.streamText`,telemetry:t}),...ke,"ai.prompt":{input:()=>JSON.stringify({system:u,prompt:d,messages:f})}}}),tracer:De,endWhenDone:!1,fn:async r=>{N=r;let i=await aG({system:u,prompt:d,messages:f,allowSystemInMessages:p});await fW({event:{model:je,system:u,prompt:d,messages:f,tools:m,toolChoice:h,activeTools:_,maxOutputTokens:Oe.maxOutputTokens,temperature:Oe.temperature,topP:Oe.topP,topK:Oe.topK,presencePenalty:Oe.presencePenalty,frequencyPenalty:Oe.frequencyPenalty,stopSequences:Oe.stopSequences,seed:Oe.seed,maxRetries:Te,timeout:E,headers:n,providerOptions:x,stopWhen:ee,output:b,abortSignal:D,include:ce,...Me,experimental_context:oe},callbacks:[ie,M.onStart]});let g=i.messages,C=[],{approvedToolApprovals:O,deniedToolApprovals:te}=OG({messages:g});if(te.length>0||O.length>0){let e=O.filter(e=>!e.toolCall.providerExecuted),n=te.filter(e=>!e.toolCall.providerExecuted),r=te.filter(e=>e.toolCall.providerExecuted),i,o=new ReadableStream({start(e){i=e}});Ae.addStream(o);try{for(let e of[...n,...r])i?.enqueue({type:`tool-output-denied`,toolCallId:e.toolCall.toolCallId,toolName:e.toolCall.toolName});let o=[];if(await Promise.all(e.map(async e=>{let n=await AG({toolCall:e.toolCall,tools:m,tracer:De,telemetry:t,messages:g,abortSignal:a,experimental_context:oe,stepNumber:_e.length,model:je,onToolCallStart:[j,M.onToolCallStart],onToolCallFinish:[ae,M.onToolCallFinish],onPreliminaryToolResult:e=>{i?.enqueue(e)}});n!=null&&(i?.enqueue(n),o.push(n))})),o.length>0||n.length>0){let e=[];for(let t of o)e.push({type:`tool-result`,toolCallId:t.toolCallId,toolName:t.toolName,output:await UW({toolCallId:t.toolCallId,input:t.input,tool:m?.[t.toolName],output:t.type===`tool-result`?t.output:t.error,errorMode:t.type===`tool-error`?`text`:`none`})});for(let t of n)e.push({type:`tool-result`,toolCallId:t.toolCall.toolCallId,toolName:t.toolCall.toolName,output:{type:`execution-denied`,reason:t.approvalResponse.reason}});C.push({role:`tool`,content:e})}}finally{i?.close()}}de.push(...C);async function k({currentStep:r,responseMessages:d,usage:f}){let p=Ae.includeRawChunks,C=o==null?void 0:setTimeout(()=>s.abort(),o),O;function te(){c!=null&&(O!=null&&clearTimeout(O),O=setTimeout(()=>l.abort(),c))}function ne(){O!=null&&(clearTimeout(O),O=void 0)}function re(){C!=null&&clearTimeout(C)}try{le=new qL;let o=[...g,...d],s=await S?.({model:e,steps:_e,stepNumber:_e.length,messages:o,experimental_context:oe}),c=SW(s?.model??e),l={provider:c.provider,modelId:c.modelId},C=await RW({prompt:{system:s?.system??i.system,messages:s?.messages??o},supportedUrls:await c.supportedUrls,download:se}),O=s?.activeTools??_,{toolChoice:ie,tools:ue}=await qW({tools:m,toolChoice:s?.toolChoice??h,activeTools:O});oe=s?.experimental_context??oe;let de=s?.messages??o,fe=s?.system??i.system,pe=CG(x,s?.providerOptions);await fW({event:{stepNumber:_e.length,model:l,system:fe,messages:de,tools:m,toolChoice:ie,activeTools:O,steps:[..._e],providerOptions:pe,timeout:E,headers:n,stopWhen:ee,output:b,abortSignal:D,include:ce,...Me,experimental_context:oe},callbacks:[A,M.onStepStart]});let{result:{stream:me,response:he,request:ge},doStreamSpan:N,startTimestampMs:ye}=await Ee(()=>pG({name:`ai.streamText.doStream`,attributes:hG({telemetry:t,attributes:{...sG({operationId:`ai.streamText.doStream`,telemetry:t}),...ke,"ai.model.provider":c.provider,"ai.model.id":c.modelId,"ai.prompt.messages":{input:()=>gG(C)},"ai.prompt.tools":{input:()=>ue?.map(e=>JSON.stringify(e))},"ai.prompt.toolChoice":{input:()=>ie==null?void 0:JSON.stringify(ie)},"gen_ai.system":c.provider,"gen_ai.request.model":c.modelId,"gen_ai.request.frequency_penalty":Oe.frequencyPenalty,"gen_ai.request.max_tokens":Oe.maxOutputTokens,"gen_ai.request.presence_penalty":Oe.presencePenalty,"gen_ai.request.stop_sequences":Oe.stopSequences,"gen_ai.request.temperature":Oe.temperature,"gen_ai.request.top_k":Oe.topK,"gen_ai.request.top_p":Oe.topP}}),tracer:De,endWhenDone:!1,fn:async e=>({startTimestampMs:w(),doStreamSpan:e,result:await c.doStream({...Oe,tools:ue,toolChoice:ie,responseFormat:await b?.responseFormat,prompt:C,providerOptions:pe,abortSignal:a,headers:n,includeRawChunks:p})})})),be=jK({tools:m,generatorStream:me,tracer:De,telemetry:t,system:u,messages:o,repairToolCall:v,abortSignal:a,experimental_context:oe,generateId:T,stepNumber:_e.length,model:l,onToolCallStart:[j,M.onToolCallStart],onToolCallFinish:[ae,M.onToolCallFinish]}),xe=ce?.requestBody??!0?ge??{}:{...ge,body:void 0},Se=[],Ce=[],we,Te={},Ne=`other`,Pe,Fe=bG(),Ie,Le=!0,Re={id:T(),timestamp:new Date,modelId:je.modelId},ze=``;Ae.addStream(be.pipeThrough(new TransformStream({async transform(e,t){if(te(),e.type===`stream-start`){we=e.warnings;return}if(Le){let e=w()-ye;Le=!1,N.addEvent(`ai.stream.firstChunk`,{"ai.response.msToFirstChunk":e}),N.setAttributes({"ai.response.msToFirstChunk":e}),t.enqueue({type:`start-step`,request:xe,warnings:we??[]})}let n=e.type;switch(n){case`tool-approval-request`:case`text-start`:case`text-end`:t.enqueue(e);break;case`text-delta`:e.delta.length>0&&(t.enqueue({type:`text-delta`,id:e.id,text:e.delta,providerMetadata:e.providerMetadata}),ze+=e.delta);break;case`reasoning-start`:case`reasoning-end`:t.enqueue(e);break;case`reasoning-delta`:t.enqueue({type:`reasoning-delta`,id:e.id,text:e.delta,providerMetadata:e.providerMetadata});break;case`tool-call`:t.enqueue(e),Se.push(e);break;case`tool-result`:t.enqueue(e),e.preliminary||Ce.push(e);break;case`tool-error`:t.enqueue(e),Ce.push(e);break;case`response-metadata`:Re={id:e.id??Re.id,timestamp:e.timestamp??Re.timestamp,modelId:e.modelId??Re.modelId};break;case`finish`:{Fe=e.usage,Ne=e.finishReason,Pe=e.rawFinishReason,Ie=e.providerMetadata;let t=w()-ye;N.addEvent(`ai.stream.finish`),N.setAttributes({"ai.response.msToFinish":t,"ai.response.avgOutputTokensPerSecond":1e3*(Fe.outputTokens??0)/t});break}case`file`:t.enqueue(e);break;case`source`:t.enqueue(e);break;case`tool-input-start`:{Te[e.id]=e.toolName;let n=m?.[e.toolName];n?.onInputStart!=null&&await n.onInputStart({toolCallId:e.id,messages:o,abortSignal:a,experimental_context:oe}),t.enqueue({...e,dynamic:e.dynamic??n?.type===`dynamic`,title:n?.title});break}case`tool-input-end`:delete Te[e.id],t.enqueue(e);break;case`tool-input-delta`:{let n=Te[e.id],r=m?.[n];r?.onInputDelta!=null&&await r.onInputDelta({inputTextDelta:e.delta,toolCallId:e.id,messages:o,abortSignal:a,experimental_context:oe}),t.enqueue(e);break}case`error`:t.enqueue(e),Ne=`error`;break;case`raw`:p&&t.enqueue(e);break;default:throw Error(`Unknown chunk type: ${n}`)}},async flush(e){let n=Se.length>0?JSON.stringify(Se):void 0;try{N.setAttributes(await hG({telemetry:t,attributes:{"ai.response.finishReason":Ne,"ai.response.toolCalls":{output:()=>n},"ai.response.id":Re.id,"ai.response.model":Re.modelId,"ai.response.timestamp":Re.timestamp.toISOString(),"ai.usage.inputTokens":Fe.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":Fe.inputTokenDetails?.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":Fe.inputTokenDetails?.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":Fe.inputTokenDetails?.cacheWriteTokens,"ai.usage.outputTokens":Fe.outputTokens,"ai.usage.outputTokenDetails.textTokens":Fe.outputTokenDetails?.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":Fe.outputTokenDetails?.reasoningTokens,"ai.usage.totalTokens":Fe.totalTokens,"ai.usage.reasoningTokens":Fe.outputTokenDetails?.reasoningTokens,"ai.usage.cachedInputTokens":Fe.inputTokenDetails?.cacheReadTokens,"gen_ai.response.finish_reasons":[Ne],"gen_ai.response.id":Re.id,"gen_ai.response.model":Re.modelId,"gen_ai.usage.input_tokens":Fe.inputTokens,"gen_ai.usage.output_tokens":Fe.outputTokens}}))}catch{}e.enqueue({type:`finish-step`,finishReason:Ne,rawFinishReason:Pe,usage:Fe,providerMetadata:Ie,response:{...Re,headers:he?.headers}});let i=xG(f,Fe);await le.promise;let a=_e[_e.length-1];try{N.setAttributes(await hG({telemetry:t,attributes:{"ai.response.text":{output:()=>a.text},"ai.response.reasoning":{output:()=>a.reasoningText},"ai.response.providerMetadata":JSON.stringify(a.providerMetadata)}}))}catch{}finally{N.end()}let o=Se.filter(e=>e.providerExecuted!==!0),s=Ce.filter(e=>e.providerExecuted!==!0);for(let e of Se){if(e.providerExecuted!==!0)continue;let t=m?.[e.toolName];t?.type===`provider`&&t.supportsDeferredResults&&(Ce.some(t=>(t.type===`tool-result`||t.type===`tool-error`)&&t.toolCallId===e.toolCallId)||ve.set(e.toolCallId,{toolName:e.toolName}))}for(let e of Ce)(e.type===`tool-result`||e.type===`tool-error`)&&ve.delete(e.toolCallId);if(re(),ne(),(o.length>0&&s.length===o.length||ve.size>0)&&!await JG({stopConditions:y,steps:_e})){d.push(...await YG({content:_e[_e.length-1].content,tools:m}));try{await k({currentStep:r+1,responseMessages:d,usage:i})}catch(t){e.enqueue({type:`error`,error:t}),Ae.closeStream()}}else e.enqueue({type:`finish`,finishReason:Ne,rawFinishReason:Pe,totalUsage:i}),Ae.closeStream()}})))}finally{re(),ne()}}await k({currentStep:0,responseMessages:C,usage:bG()})}}).catch(e=>{Ae.addStream(new ReadableStream({start(t){t.enqueue({type:`error`,error:e}),t.close()}})),Ae.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}get rawFinishReason(){return this.consumeStream(),this._rawFinishReason.promise}teeStream(){let[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return DK(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type===`text-delta`&&t.enqueue(e.text)}})))}get fullStream(){return DK(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await OK({stream:this.fullStream,onError:e?.onError})}catch(n){(t=e?.onError)==null||t.call(e,n)}}get experimental_partialOutputStream(){return this.partialOutputStream}get partialOutputStream(){return DK(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}get elementStream(){let e=this.outputSpecification?.createElementStreamTransform();if(e==null)throw new iI({functionality:`element streams in ${this.outputSpecification?.name??`text`} mode`});return DK(this.teeStream().pipeThrough(e))}get output(){return this.finalStep.then(e=>(this.outputSpecification??RG()).parseCompleteOutput({text:e.text},{response:e.response,usage:e.usage,finishReason:e.finishReason}))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:r,sendReasoning:i=!0,sendSources:a=!1,sendStart:o=!0,sendFinish:s=!0,onError:c=OF}={}){let l=t==null?void 0:uK({originalMessages:e,responseMessageId:t}),u=e=>{let t=this.tools?.[e.toolName];return t==null?e.dynamic:t?.type===`dynamic`?!0:void 0};return DK(TK({stream:this.fullStream.pipeThrough(new TransformStream({transform:async(e,t)=>{let n=r?.({part:e}),d=e.type;switch(d){case`text-start`:t.enqueue({type:`text-start`,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`text-delta`:t.enqueue({type:`text-delta`,id:e.id,delta:e.text,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`text-end`:t.enqueue({type:`text-end`,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`reasoning-start`:case`reasoning-end`:i&&t.enqueue({type:d,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`reasoning-delta`:i&&t.enqueue({type:`reasoning-delta`,id:e.id,delta:e.text,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`file`:t.enqueue({type:`file`,mediaType:e.file.mediaType,url:`data:${e.file.mediaType};base64,${e.file.base64}`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`source`:a&&e.sourceType===`url`&&t.enqueue({type:`source-url`,sourceId:e.id,url:e.url,title:e.title,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),a&&e.sourceType===`document`&&t.enqueue({type:`source-document`,sourceId:e.id,mediaType:e.mediaType,title:e.title,filename:e.filename,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}});break;case`tool-input-start`:{let n=u(e);t.enqueue({type:`tool-input-start`,toolCallId:e.id,toolName:e.toolName,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...n==null?{}:{dynamic:n},...e.title==null?{}:{title:e.title}});break}case`tool-input-delta`:t.enqueue({type:`tool-input-delta`,toolCallId:e.id,inputTextDelta:e.delta});break;case`tool-call`:{let n=u(e);e.invalid?t.enqueue({type:`tool-input-error`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...n==null?{}:{dynamic:n},errorText:c(e.error),...e.title==null?{}:{title:e.title}}):t.enqueue({type:`tool-input-available`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...n==null?{}:{dynamic:n},...e.title==null?{}:{title:e.title}});break}case`tool-approval-request`:t.enqueue({type:`tool-approval-request`,approvalId:e.approvalId,toolCallId:e.toolCall.toolCallId});break;case`tool-result`:{let n=u(e);t.enqueue({type:`tool-output-available`,toolCallId:e.toolCallId,output:e.output,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...e.preliminary==null?{}:{preliminary:e.preliminary},...n==null?{}:{dynamic:n}});break}case`tool-error`:{let n=u(e);t.enqueue({type:`tool-output-error`,toolCallId:e.toolCallId,errorText:e.providerExecuted?typeof e.error==`string`?e.error:JSON.stringify(e.error):c(e.error),...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...n==null?{}:{dynamic:n}});break}case`tool-output-denied`:t.enqueue({type:`tool-output-denied`,toolCallId:e.toolCallId});break;case`error`:t.enqueue({type:`error`,errorText:c(e.error)});break;case`start-step`:t.enqueue({type:`start-step`});break;case`finish-step`:t.enqueue({type:`finish-step`});break;case`start`:o&&t.enqueue({type:`start`,...n==null?{}:{messageMetadata:n},...l==null?{}:{messageId:l}});break;case`finish`:s&&t.enqueue({type:`finish`,finishReason:e.finishReason,...n==null?{}:{messageMetadata:n}});break;case`abort`:t.enqueue(e);break;case`tool-input-end`:break;case`raw`:break;default:throw Error(`Unknown chunk type: ${d}`)}n!=null&&d!==`start`&&d!==`finish`&&t.enqueue({type:`message-metadata`,messageMetadata:n})}})),messageId:l??t?.(),originalMessages:e,onFinish:n,onError:c}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:n,onFinish:r,messageMetadata:i,sendReasoning:a,sendSources:o,sendFinish:s,sendStart:c,onError:l,...u}={}){EK({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:n,onFinish:r,messageMetadata:i,sendReasoning:a,sendSources:o,sendFinish:s,sendStart:c,onError:l}),...u})}pipeTextStreamToResponse(e,t){oK({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:r,sendReasoning:i,sendSources:a,sendFinish:o,sendStart:s,onError:c,...l}={}){return lK({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:n,messageMetadata:r,sendReasoning:i,sendSources:a,sendFinish:o,sendStart:s,onError:c}),...l})}toTextStreamResponse(e){return iK({textStream:this.textStream,...e})}},IK=class{constructor(e){this.version=`agent-v1`,this.settings=e}get id(){return this.settings.id}get tools(){return this.settings.tools}async prepareCall(e){var t;if(this.settings.callOptionsSchema!=null&&e.options!==void 0){let t=await Gz({value:e.options,schema:this.settings.callOptionsSchema,context:{field:`options`}});e={...e,options:t}}let{onStepFinish:n,...r}=this.settings,i={...r,stopWhen:this.settings.stopWhen??qG(20),...e},{instructions:a,messages:o,prompt:s,...c}=await(t=this.settings).prepareCall?.call(t,i)??i;return{...c,system:a,messages:o,prompt:s}}mergeOnStepFinishCallbacks(e){let t=this.settings.onStepFinish;return e&&t?async n=>{await t(n),await e(n)}:e??t}async generate({abortSignal:e,timeout:t,onStepFinish:n,...r}){return QG({...await this.prepareCall(r),abortSignal:e,timeout:t,onStepFinish:this.mergeOnStepFinishCallbacks(n)})}async stream({abortSignal:e,timeout:t,experimental_transform:n,onStepFinish:r,...i}){return NK({...await this.prepareCall(i),abortSignal:e,timeout:t,experimental_transform:n,onStepFinish:this.mergeOnStepFinishCallbacks(r)})}};async function LK(e,t){let n=[];t?.ignoreIncompleteToolCalls&&(e=e.map(e=>({...e,parts:e.parts.filter(e=>!bK(e)||e.state!==`input-streaming`&&e.state!==`input-available`)})));for(let r of e)switch(r.role){case`system`:{let e=r.parts.filter(e=>e.type===`text`),t=e.reduce((e,t)=>t.providerMetadata==null?e:{...e,...t.providerMetadata},{});n.push({role:`system`,content:e.map(e=>e.text).join(``),...Object.keys(t).length>0?{providerOptions:t}:{}});break}case`user`:n.push({role:`user`,content:r.parts.map(e=>{if(hK(e))return{type:`text`,text:e.text,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}};if(gK(e))return{type:`file`,mediaType:e.mediaType,filename:e.filename,data:e.url,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}};if(mK(e))return(t?.convertDataPart)?.call(t,e)}).filter(TR)});break;case`assistant`:if(r.parts!=null){let e=[];async function i(){if(e.length===0)return;let r=[];for(let n of e)if(hK(n))r.push({type:`text`,text:n.text,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(gK(n))r.push({type:`file`,mediaType:n.mediaType,filename:n.filename,data:n.url,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(_K(n))r.push({type:`reasoning`,text:n.text,providerOptions:n.providerMetadata});else if(bK(n)){let e=SK(n);if(n.state!==`input-streaming`&&(r.push({type:`tool-call`,toolCallId:n.toolCallId,toolName:e,input:n.state===`output-error`?n.input??(`rawInput`in n?n.rawInput:void 0):n.input,providerExecuted:n.providerExecuted,...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}}),n.approval!=null&&r.push({type:`tool-approval-request`,approvalId:n.approval.id,toolCallId:n.toolCallId}),n.providerExecuted===!0&&n.state!==`approval-responded`&&(n.state===`output-available`||n.state===`output-error`))){let i=n.resultProviderMetadata??n.callProviderMetadata;r.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:e,output:await UW({toolCallId:n.toolCallId,input:n.input,output:n.state===`output-error`?n.errorText:n.output,tool:t?.tools?.[e],errorMode:n.state===`output-error`?`json`:`none`}),...i==null?{}:{providerOptions:i}})}}else if(mK(n)){let e=(t?.convertDataPart)?.call(t,n);e!=null&&r.push(e)}else throw Error(`Unsupported part: ${n}`);n.push({role:`assistant`,content:r});let i=e.filter(e=>bK(e)&&(e.providerExecuted!==!0||e.approval?.approved!=null));if(i.length>0){let e=[];for(let n of i)if(n.approval?.approved!=null&&e.push({type:`tool-approval-response`,approvalId:n.approval.id,approved:n.approval.approved,reason:n.approval.reason,providerExecuted:n.providerExecuted}),n.providerExecuted!==!0)switch(n.state){case`output-denied`:e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:SK(n),output:{type:`error-text`,value:n.approval.reason??`Tool execution denied.`},...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}});break;case`output-error`:case`output-available`:{let r=SK(n);e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:r,output:await UW({toolCallId:n.toolCallId,input:n.input,output:n.state===`output-error`?n.errorText:n.output,tool:t?.tools?.[r],errorMode:n.state===`output-error`?`text`:`none`}),...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}});break}}e.length>0&&n.push({role:`tool`,content:e})}e=[]}for(let t of r.parts)hK(t)||_K(t)||gK(t)||bK(t)||mK(t)?e.push(t):t.type===`step-start`&&await i();await i();break}break;default:{let e=r.role;throw new aW({originalMessage:r,message:`Unsupported role: ${e}`})}}return n}var RK=b(y(),JW.optional()),zK=Iz(()=>Wz(E(k({id:y(),role:v([`system`,`user`,`assistant`]),metadata:d().optional(),parts:E(c([k({type:s(`text`),text:y(),state:v([`streaming`,`done`]).optional(),providerMetadata:$.optional()}),k({type:s(`reasoning`),text:y(),state:v([`streaming`,`done`]).optional(),providerMetadata:$.optional()}),k({type:s(`source-url`),sourceId:y(),url:y(),title:y().optional(),providerMetadata:$.optional()}),k({type:s(`source-document`),sourceId:y(),mediaType:y(),title:y(),filename:y().optional(),providerMetadata:$.optional()}),k({type:s(`file`),mediaType:y(),filename:y().optional(),url:y(),providerMetadata:$.optional()}),k({type:s(`step-start`)}),k({type:y().startsWith(`data-`),id:y().optional(),data:d()}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`input-streaming`),input:d().optional(),providerExecuted:r().optional(),callProviderMetadata:$.optional(),output:f().optional(),errorText:f().optional(),approval:f().optional()}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`input-available`),input:d(),providerExecuted:r().optional(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:f().optional()}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`approval-requested`),input:d(),providerExecuted:r().optional(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:k({id:y(),approved:f().optional(),reason:f().optional()})}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`approval-responded`),input:d(),providerExecuted:r().optional(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:k({id:y(),approved:r(),reason:y().optional()})}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`output-available`),input:d(),providerExecuted:r().optional(),output:d(),errorText:f().optional(),callProviderMetadata:$.optional(),resultProviderMetadata:$.optional(),preliminary:r().optional(),approval:k({id:y(),approved:s(!0),reason:y().optional()}).optional()}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`output-error`),input:d(),rawInput:d().optional(),providerExecuted:r().optional(),output:f().optional(),errorText:y(),callProviderMetadata:$.optional(),resultProviderMetadata:$.optional(),approval:k({id:y(),approved:s(!0),reason:y().optional()}).optional()}),k({type:s(`dynamic-tool`),toolName:y(),toolCallId:y(),toolMetadata:RK.optional(),state:s(`output-denied`),input:d(),providerExecuted:r().optional(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:k({id:y(),approved:s(!1),reason:y().optional()})}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`input-streaming`),providerExecuted:r().optional(),callProviderMetadata:$.optional(),input:d().optional(),output:f().optional(),errorText:f().optional(),approval:f().optional()}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`input-available`),providerExecuted:r().optional(),input:d(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:f().optional()}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`approval-requested`),input:d(),providerExecuted:r().optional(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:k({id:y(),approved:f().optional(),reason:f().optional()})}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`approval-responded`),input:d(),providerExecuted:r().optional(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:k({id:y(),approved:r(),reason:y().optional()})}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`output-available`),providerExecuted:r().optional(),input:d(),output:d(),errorText:f().optional(),callProviderMetadata:$.optional(),resultProviderMetadata:$.optional(),preliminary:r().optional(),approval:k({id:y(),approved:s(!0),reason:y().optional()}).optional()}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`output-error`),providerExecuted:r().optional(),input:d(),rawInput:d().optional(),output:f().optional(),errorText:y(),callProviderMetadata:$.optional(),resultProviderMetadata:$.optional(),approval:k({id:y(),approved:s(!0),reason:y().optional()}).optional()}),k({type:y().startsWith(`tool-`),toolCallId:y(),toolMetadata:RK.optional(),state:s(`output-denied`),providerExecuted:r().optional(),input:d(),output:f().optional(),errorText:f().optional(),callProviderMetadata:$.optional(),approval:k({id:y(),approved:s(!1),reason:y().optional()})})])).nonempty(`Message must contain at least one part`)})).nonempty(`Messages array must not be empty`)));async function BK({messages:e,metadataSchema:t,dataSchemas:n,tools:r}){try{if(e==null)return{success:!1,error:new rU({parameter:`messages`,value:e,message:`messages parameter must be provided`})};let i=await Gz({value:e,schema:zK});if(t)for(let[e,n]of i.entries())await Gz({value:n.metadata,schema:t,context:{field:`messages[${e}].metadata`,entityId:n.id}});if(n||r)for(let[e,t]of i.entries())for(let[i,a]of t.parts.entries()){if(n&&a.type.startsWith(`data-`)){let t=a,r=t.type.slice(5),o=n[r];if(!o)return{success:!1,error:new QF({value:t.data,cause:`No data schema found for data part ${r}`,context:{field:`messages[${e}].parts[${i}].data`,entityName:r,entityId:t.id}})};await Gz({value:t.data,schema:o,context:{field:`messages[${e}].parts[${i}].data`,entityName:r,entityId:t.id}})}if(r&&a.type.startsWith(`tool-`)){let t=a,n=t.type.slice(5),o=r[n];if(!o&&(t.state===`output-available`||t.state===`output-error`||t.state===`output-denied`))continue;if(!o)return{success:!1,error:new QF({value:t.input,cause:`No tool schema found for tool part ${n}`,context:{field:`messages[${e}].parts[${i}].input`,entityName:n,entityId:t.toolCallId}})};(t.state===`input-available`||t.state===`output-available`||t.state===`output-error`&&t.input!==void 0)&&await Gz({value:t.input,schema:o.inputSchema,context:{field:`messages[${e}].parts[${i}].input`,entityName:n,entityId:t.toolCallId}}),t.state===`output-available`&&o.outputSchema&&await Gz({value:t.output,schema:o.outputSchema,context:{field:`messages[${e}].parts[${i}].output`,entityName:n,entityId:t.toolCallId}})}}return{success:!0,data:i}}catch(e){return{success:!1,error:e}}}async function VK({messages:e,metadataSchema:t,dataSchemas:n,tools:r}){let i=await BK({messages:e,metadataSchema:t,dataSchemas:n,tools:r});if(!i.success)throw i.error;return i.data}async function HK({agent:e,uiMessages:t,options:n,abortSignal:r,timeout:i,experimental_transform:a,onStepFinish:o,...s}){let c=await VK({messages:t,tools:e.tools}),l=await LK(c,{tools:e.tools});return(await e.stream({prompt:l,options:n,abortSignal:r,timeout:i,experimental_transform:a,onStepFinish:o})).toUIMessageStream({...s,originalMessages:s.originalMessages??c})}async function UK({headers:e,status:t,statusText:n,consumeSseStream:r,...i}){return lK({headers:e,status:t,statusText:n,consumeSseStream:r,stream:await HK(i)})}dR({prefix:`aiobj`,size:24});var WK=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}};dR({prefix:`aiobj`,size:24});async function GK(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw Error(`FileList is not supported in the current environment`);return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}var KK=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await tB(this.body),r=await tB(this.headers),i=await tB(this.credentials),a={...bR(r),...bR(t.headers)},o=await this.prepareSendMessagesRequest?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:bR(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"Content-Type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw Error(await d.text()??`Failed to fetch the chat response.`);if(!d.body)throw Error(`The response body is empty.`);return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await tB(this.body),n=await tB(this.headers),r=await tB(this.credentials),i={...bR(n),...bR(e.headers)},a=await this.prepareReconnectToStreamRequest?.call(this,{api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api??`${this.api}/${e.chatId}/stream`,s=a?.headers===void 0?i:bR(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c});if(l.status===204)return null;if(!l.ok)throw Error(await l.text()??`Failed to fetch the chat response.`);if(!l.body)throw Error(`The response body is empty.`);return this.processResponseStream(l.body)}},qK=class extends KK{constructor(e={}){super(e)}processResponseStream(e){return Yz({stream:e,schema:fK}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},JK=class{constructor({generateId:e=fR,id:t=e(),transport:n=new qK,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.activeResponse=void 0,this.jobExecutor=new WK,this.sendMessage=async(e,t)=>{if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...t});return}let n;if(n=`text`in e||`files`in e?{parts:[...Array.isArray(e.files)?e.files:await GK(e.files),...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}:e,e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw Error(`message with id ${e.messageId} not found`);if(this.state.messages[t].role!==`user`)throw Error(`message with id ${e.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{...n,id:e.messageId,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw Error(`message ${e} not found`);this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.state.messages,a=i[i.length-1],o=r=>bK(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{id:e,approved:t,reason:n}}:r;this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(o)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...r})})}),this.addToolOutput=async({state:e=`output-available`,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.state.messages,o=a[a.length-1],s=i=>bK(i)&&i.toolCallId===t?{...i,state:e,output:n,errorText:r}:i;this.state.replaceMessage(a.length-1,{...o,parts:o.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...i})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{this.status!==`streaming`&&this.status!==`submitted`||this.activeResponse?.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e==`object`&&`then`in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a;let o;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:n,body:r});if(e==null)return;o=e}catch(e){this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e});return}this.setStatus({status:`submitted`,error:void 0});let s=this.lastMessage,c=!1,l=!1,u=!1;try{let a={state:CK({lastMessage:this.state.snapshot(s),messageId:this.generateId()}),abortController:new AbortController};a.abortController.signal.addEventListener(`abort`,()=>{c=!0}),this.activeResponse=a;let l;l=e===`resume-stream`?o:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await OK({stream:wK({stream:l,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>e({state:a.state,write:()=>{this.setStatus({status:`streaming`}),a.state.message.id===this.lastMessage?.id?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message)}})),onError:e=>{throw e}}),onError:e=>{throw e}}),this.setStatus({status:`ready`})}catch(e){if(c||e.name===`AbortError`)return c=!0,this.setStatus({status:`ready`}),null;u=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(l=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:l,isError:u,finishReason:this.activeResponse?.state.finishReason})}catch(e){console.error(e)}this.activeResponse=void 0}!u&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r})}};function YK({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(bK);return r.filter(e=>e.state===`approval-responded`).length>0&&r.every(e=>e.state===`output-available`||e.state===`output-error`||e.state===`approval-responded`)}function XK({messages:e}){let t=e[e.length-1];if(!t||t.role!==`assistant`)return!1;let n=t.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=t.parts.slice(n+1).filter(bK).filter(e=>!e.providerExecuted);return r.length>0&&r.every(e=>e.state===`output-available`||e.state===`output-error`)}var ZK=`vercel.ai.error`,QK=Symbol.for(ZK),$K,eq,tq=class e extends (eq=Error,$K=QK,eq){constructor({name:e,message:t,cause:n}){super(t),this[$K]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,ZK)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},nq=`AI_APICallError`,rq=`vercel.ai.error.${nq}`,iq=Symbol.for(rq),aq,oq,sq=class extends (oq=tq,aq=iq,oq){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:nq,message:e,cause:o}),this[aq]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return tq.hasMarker(e,rq)}},cq=`AI_EmptyResponseBodyError`,lq=`vercel.ai.error.${cq}`,uq=Symbol.for(lq),dq,fq,pq=class extends (fq=tq,dq=uq,fq){constructor({message:e=`Empty response body`}={}){super({name:cq,message:e}),this[dq]=!0}static isInstance(e){return tq.hasMarker(e,lq)}};function mq(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var hq=`AI_InvalidArgumentError`,gq=`vercel.ai.error.${hq}`,_q=Symbol.for(gq),vq,yq,bq=class extends (yq=tq,vq=_q,yq){constructor({message:e,cause:t,argument:n}){super({name:hq,message:e,cause:t}),this[vq]=!0,this.argument=n}static isInstance(e){return tq.hasMarker(e,gq)}},xq=`AI_InvalidPromptError`,Sq=`vercel.ai.error.${xq}`,Cq=Symbol.for(Sq),wq,Tq,Eq=class extends (Tq=tq,wq=Cq,Tq){constructor({prompt:e,message:t,cause:n}){super({name:xq,message:`Invalid prompt: ${t}`,cause:n}),this[wq]=!0,this.prompt=e}static isInstance(e){return tq.hasMarker(e,Sq)}},Dq=`AI_InvalidResponseDataError`,Oq=`vercel.ai.error.${Dq}`,kq=Symbol.for(Oq),Aq,jq,Mq=class extends (jq=tq,Aq=kq,jq){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:Dq,message:t}),this[Aq]=!0,this.data=e}static isInstance(e){return tq.hasMarker(e,Oq)}},Nq=`AI_JSONParseError`,Pq=`vercel.ai.error.${Nq}`,Fq=Symbol.for(Pq),Iq,Lq,Rq=class extends (Lq=tq,Iq=Fq,Lq){constructor({text:e,cause:t}){super({name:Nq,message:`JSON parsing failed: Text: ${e}.
|
|
125
|
+
Error message: ${mq(t)}`,cause:t}),this[Iq]=!0,this.text=e}static isInstance(e){return tq.hasMarker(e,Pq)}},zq=`AI_TooManyEmbeddingValuesForCallError`,Bq=`vercel.ai.error.${zq}`,Vq=Symbol.for(Bq),Hq,Uq,Wq=class extends (Uq=tq,Hq=Vq,Uq){constructor(e){super({name:zq,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[Hq]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return tq.hasMarker(e,Bq)}},Gq=`AI_TypeValidationError`,Kq=`vercel.ai.error.${Gq}`,qq=Symbol.for(Kq),Jq,Yq,Xq=class e extends (Yq=tq,Jq=qq,Yq){constructor({value:e,cause:t}){super({name:Gq,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
126
|
+
Error message: ${mq(t)}`,cause:t}),this[Jq]=!0,this.value=e}static isInstance(e){return tq.hasMarker(e,Kq)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}},Zq=`AI_UnsupportedFunctionalityError`,Qq=`vercel.ai.error.${Zq}`,$q=Symbol.for(Qq),eJ,tJ,nJ=class extends (tJ=tq,eJ=$q,tJ){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:Zq,message:t}),this[eJ]=!0,this.functionality=e}static isInstance(e){return tq.hasMarker(e,Qq)}};function rJ(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function iJ(e){return Object.fromEntries([...e.headers])}var aJ=(({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new bq({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`})();function oJ(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var sJ=[`fetch failed`,`failed to fetch`];function cJ({error:e,url:t,requestBodyValues:n}){if(oJ(e))return e;if(e instanceof TypeError&&sJ.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new sq({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return e}function lJ(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function uJ(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function dJ(e,...t){let n=new Headers(uJ(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var fJ=`3.0.25`,pJ=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,mJ=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function hJ(e){let t=JSON.parse(e);return typeof t!=`object`||!t||pJ.test(e)===!1&&mJ.test(e)===!1?t:gJ(t)}function gJ(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function _J(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return hJ(e)}try{return hJ(e)}finally{Error.stackTraceLimit=t}}var vJ=Symbol.for(`vercel.ai.validator`);function yJ(e){return{[vJ]:!0,validate:e}}function bJ(e){return typeof e==`object`&&!!e&&vJ in e&&e[vJ]===!0&&`validate`in e}function xJ(e){return bJ(e)?e:typeof e==`function`?e():SJ(e)}function SJ(e){return yJ(async t=>{let n=await e[`~standard`].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Xq({value:t,cause:n.issues})}})}async function CJ({value:e,schema:t}){let n=await wJ({value:e,schema:t});if(!n.success)throw Xq.wrap({value:e,cause:n.error});return n.value}async function wJ({value:e,schema:t}){let n=xJ(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};let t=await n.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:Xq.wrap({value:e,cause:t.error}),rawValue:e}}catch(t){return{success:!1,error:Xq.wrap({value:e,cause:t}),rawValue:e}}}async function TJ({text:e,schema:t}){try{let n=_J(e);return t==null?n:CJ({value:n,schema:t})}catch(t){throw Rq.isInstance(t)||Xq.isInstance(t)?t:new Rq({text:e,cause:t})}}async function EJ({text:e,schema:t}){try{let n=_J(e);return t==null?{success:!0,value:n,rawValue:n}:await wJ({value:n,schema:t})}catch(t){return{success:!1,error:Rq.isInstance(t)?t:new Rq({text:e,cause:t}),rawValue:void 0}}}function DJ(e){try{return _J(e),!0}catch{return!1}}function OJ({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new UL).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await EJ({text:e,schema:t}))}}))}async function kJ({provider:e,providerOptions:t,schema:n}){if(t?.[e]==null)return;let r=await wJ({value:t[e],schema:n});if(!r.success)throw new bq({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:r.error});return r.value}var AJ=()=>globalThis.fetch,jJ=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>MJ({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),MJ=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=AJ()})=>{try{let s=await o(e,{method:`POST`,headers:dJ(t,`ai-sdk/provider-utils/${fJ}`,lJ()),body:n.content,signal:a}),c=iJ(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw oJ(t)||sq.isInstance(t)?t:new sq({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(oJ(t)||sq.isInstance(t))?t:new sq({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw cJ({error:t,url:e,requestBodyValues:n.values})}},NJ=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await r.text(),s=iJ(r);if(o.trim()===``)return{responseHeaders:s,value:new sq({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await TJ({text:o,schema:e});return{responseHeaders:s,value:new sq({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new sq({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},PJ=e=>async({response:t})=>{let n=iJ(t);if(t.body==null)throw new pq({});return{responseHeaders:n,value:OJ({stream:t.body,schema:e})}},FJ=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await t.text(),a=await EJ({text:i,schema:e}),o=iJ(t);if(!a.success)throw new sq({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}},{btoa:IJ,atob:LJ}=globalThis;function RJ(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return IJ(t)}function zJ(e){return e instanceof Uint8Array?RJ(e):e}function BJ(e){return e?.replace(/\/$/,``)}function VJ(e){return e?.providerOptions?.openaiCompatible??{}}function HJ(e){let t=[];for(let{role:n,content:r,...i}of e){let e=VJ({...i});switch(n){case`system`:t.push({role:`system`,content:r,...e});break;case`user`:if(r.length===1&&r[0].type===`text`){t.push({role:`user`,content:r[0].text,...VJ(r[0])});break}t.push({role:`user`,content:r.map(e=>{let t=VJ(e);switch(e.type){case`text`:return{type:`text`,text:e.text,...t};case`file`:if(e.mediaType.startsWith(`image/`)){let n=e.mediaType===`image/*`?`image/jpeg`:e.mediaType;return{type:`image_url`,image_url:{url:e.data instanceof URL?e.data.toString():`data:${n};base64,${zJ(e.data)}`},...t}}else throw new nJ({functionality:`file part media type ${e.mediaType}`})}}),...e});break;case`assistant`:{let n=``,i=``,a=[];for(let e of r){let t=VJ(e);switch(e.type){case`text`:n+=e.text;break;case`reasoning`:i+=e.text;break;case`tool-call`:a.push({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input)},...t});break}}t.push({role:`assistant`,content:n,...i.length>0?{reasoning_content:i}:{},tool_calls:a.length>0?a:void 0,...e});break}case`tool`:for(let e of r){let n=e.output,r;switch(n.type){case`text`:case`error-text`:r=n.value;break;case`content`:case`json`:case`error-json`:r=JSON.stringify(n.value);break}let i=VJ(e);t.push({role:`tool`,tool_call_id:e.toolCallId,content:r,...i})}break;default:throw Error(`Unsupported role: ${n}`)}}return t}function UJ({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function WJ(e){switch(e){case`stop`:return`stop`;case`length`:return`length`;case`content_filter`:return`content-filter`;case`function_call`:case`tool_calls`:return`tool-calls`;default:return`unknown`}}var GJ=k({user:y().optional(),reasoningEffort:y().optional(),textVerbosity:y().optional()}),KJ={errorSchema:k({error:k({message:y(),type:y().nullish(),param:m().nullish(),code:c([y(),_()]).nullish()})}),errorToMessage:e=>e.error.message};function qJ({tools:e,toolChoice:t}){e=e?.length?e:void 0;let n=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:n};let r=[];for(let t of e)t.type===`provider-defined`?n.push({type:`unsupported-tool`,tool:t}):r.push({type:`function`,function:{name:t.name,description:t.description,parameters:t.inputSchema}});if(t==null)return{tools:r,toolChoice:void 0,toolWarnings:n};let i=t.type;switch(i){case`auto`:case`none`:case`required`:return{tools:r,toolChoice:i,toolWarnings:n};case`tool`:return{tools:r,toolChoice:{type:`function`,function:{name:t.toolName}},toolWarnings:n};default:throw new nJ({functionality:`tool choice type: ${i}`})}}var JJ=class{constructor(e,t){this.specificationVersion=`v2`,this.modelId=e,this.config=t;let n=t.errorStructure??KJ;this.chunkSchema=QJ(n.errorSchema),this.failedResponseHandler=NJ(n),this.supportsStructuredOutputs=t.supportsStructuredOutputs??!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}transformRequestBody(e){var t;return(t=this.config).transformRequestBody?.call(t,e)??e}convertUsage(e){var t;return(t=this.config).convertUsage?.call(t,e)??XJ(e)}async getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:r,topK:i,frequencyPenalty:a,presencePenalty:o,providerOptions:s,stopSequences:c,responseFormat:l,seed:u,toolChoice:d,tools:f}){let p=[],m=Object.assign(await kJ({provider:`openai-compatible`,providerOptions:s,schema:GJ})??{},await kJ({provider:this.providerOptionsName,providerOptions:s,schema:GJ})??{});i!=null&&p.push({type:`unsupported-setting`,setting:`topK`}),l?.type===`json`&&l.schema!=null&&!this.supportsStructuredOutputs&&p.push({type:`unsupported-setting`,setting:`responseFormat`,details:`JSON response format schema is only supported with structuredOutputs`});let{tools:h,toolChoice:g,toolWarnings:_}=qJ({tools:f,toolChoice:d});return{args:{model:this.modelId,user:m.user,max_tokens:t,temperature:n,top_p:r,frequency_penalty:a,presence_penalty:o,response_format:l?.type===`json`?this.supportsStructuredOutputs===!0&&l.schema!=null?{type:`json_schema`,json_schema:{schema:l.schema,name:l.name??`response`,description:l.description}}:{type:`json_object`}:void 0,stop:c,seed:u,...Object.fromEntries(Object.entries(s?.[this.providerOptionsName]??{}).filter(([e])=>!Object.keys(GJ.shape).includes(e))),reasoning_effort:m.reasoningEffort,verbosity:m.textVerbosity,messages:HJ(e),tools:h,tool_choice:g},warnings:[...p,..._]}}async doGenerate(e){var t;let{args:n,warnings:r}=await this.getArgs({...e}),i=this.transformRequestBody(n),a=JSON.stringify(i),{responseHeaders:o,value:s,rawValue:c}=await jJ({url:this.config.url({path:`/chat/completions`,modelId:this.modelId}),headers:rJ(this.config.headers(),e.headers),body:i,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:FJ(ZJ),abortSignal:e.abortSignal,fetch:this.config.fetch}),l=s.choices[0],u=[],d=l.message.content;d!=null&&d.length>0&&u.push({type:`text`,text:d});let f=l.message.reasoning_content??l.message.reasoning;if(f!=null&&f.length>0&&u.push({type:`reasoning`,text:f}),l.message.tool_calls!=null)for(let e of l.message.tool_calls)u.push({type:`tool-call`,toolCallId:e.id??aJ(),toolName:e.function.name,input:e.function.arguments});let p={[this.providerOptionsName]:{},...await((t=this.config.metadataExtractor)?.extractMetadata)?.call(t,{parsedBody:c})},m=s.usage?.completion_tokens_details;return m?.accepted_prediction_tokens!=null&&(p[this.providerOptionsName].acceptedPredictionTokens=m?.accepted_prediction_tokens),m?.rejected_prediction_tokens!=null&&(p[this.providerOptionsName].rejectedPredictionTokens=m?.rejected_prediction_tokens),{content:u,finishReason:WJ(l.finish_reason),usage:this.convertUsage(s.usage),providerMetadata:p,request:{body:a},response:{...UJ(s),headers:o,body:c},warnings:r}}async doStream(e){let{args:t,warnings:n}=await this.getArgs({...e}),r=this.transformRequestBody({...t,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0}),i=this.config.metadataExtractor?.createStreamExtractor(),{responseHeaders:a,value:o}=await jJ({url:this.config.url({path:`/chat/completions`,modelId:this.modelId}),headers:rJ(this.config.headers(),e.headers),body:r,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:PJ(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),s=[],c=`unknown`,l={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0},u,d=!0,f=this.providerOptionsName,p=!1,m=!1,h=e=>this.convertUsage(e);return{stream:o.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(e.includeRawChunks&&n.enqueue({type:`raw`,rawValue:t.rawValue}),!t.success){c=`error`,n.enqueue({type:`error`,error:t.error});return}let r=t.value;if(i?.processChunk(t.rawValue),`error`in r){c=`error`,n.enqueue({type:`error`,error:r.error.message});return}if(d&&(d=!1,n.enqueue({type:`response-metadata`,...UJ(r)})),r.usage!=null){u=r.usage;let{prompt_tokens:e,completion_tokens:t,total_tokens:n,prompt_tokens_details:i,completion_tokens_details:a}=r.usage;l.promptTokens=e??void 0,l.completionTokens=t??void 0,l.totalTokens=n??void 0,a?.reasoning_tokens!=null&&(l.completionTokensDetails.reasoningTokens=a?.reasoning_tokens),a?.accepted_prediction_tokens!=null&&(l.completionTokensDetails.acceptedPredictionTokens=a?.accepted_prediction_tokens),a?.rejected_prediction_tokens!=null&&(l.completionTokensDetails.rejectedPredictionTokens=a?.rejected_prediction_tokens),i?.cached_tokens!=null&&(l.promptTokensDetails.cachedTokens=i?.cached_tokens)}let a=r.choices[0];if(a?.finish_reason!=null&&(c=WJ(a.finish_reason)),a?.delta==null)return;let o=a.delta,f=o.reasoning_content??o.reasoning;if(f&&(p||=(n.enqueue({type:`reasoning-start`,id:`reasoning-0`}),!0),n.enqueue({type:`reasoning-delta`,id:`reasoning-0`,delta:f})),o.content&&(m||=(n.enqueue({type:`text-start`,id:`txt-0`}),!0),n.enqueue({type:`text-delta`,id:`txt-0`,delta:o.content})),o.tool_calls!=null)for(let e of o.tool_calls){let t=e.index;if(s[t]==null){if(e.id==null)throw new Mq({data:e,message:`Expected 'id' to be a string.`});if(e.function?.name==null)throw new Mq({data:e,message:`Expected 'function.name' to be a string.`});n.enqueue({type:`tool-input-start`,id:e.id,toolName:e.function.name}),s[t]={id:e.id,type:`function`,function:{name:e.function.name,arguments:e.function.arguments??``},hasFinished:!1};let r=s[t];r.function?.name!=null&&r.function?.arguments!=null&&(r.function.arguments.length>0&&n.enqueue({type:`tool-input-delta`,id:r.id,delta:r.function.arguments}),DJ(r.function.arguments)&&(n.enqueue({type:`tool-input-end`,id:r.id}),n.enqueue({type:`tool-call`,toolCallId:r.id??aJ(),toolName:r.function.name,input:r.function.arguments}),r.hasFinished=!0));continue}let r=s[t];r.hasFinished||(e.function?.arguments!=null&&(r.function.arguments+=e.function?.arguments??``),n.enqueue({type:`tool-input-delta`,id:r.id,delta:e.function.arguments??``}),r.function?.name!=null&&r.function?.arguments!=null&&DJ(r.function.arguments)&&(n.enqueue({type:`tool-input-end`,id:r.id}),n.enqueue({type:`tool-call`,toolCallId:r.id??aJ(),toolName:r.function.name,input:r.function.arguments}),r.hasFinished=!0))}},flush(e){p&&e.enqueue({type:`reasoning-end`,id:`reasoning-0`}),m&&e.enqueue({type:`text-end`,id:`txt-0`});for(let t of s.filter(e=>!e.hasFinished))e.enqueue({type:`tool-input-end`,id:t.id}),e.enqueue({type:`tool-call`,toolCallId:t.id??aJ(),toolName:t.function.name,input:t.function.arguments});let t={[f]:{},...i?.buildMetadata()};l.completionTokensDetails.acceptedPredictionTokens!=null&&(t[f].acceptedPredictionTokens=l.completionTokensDetails.acceptedPredictionTokens),l.completionTokensDetails.rejectedPredictionTokens!=null&&(t[f].rejectedPredictionTokens=l.completionTokensDetails.rejectedPredictionTokens),e.enqueue({type:`finish`,finishReason:c,usage:h(u),providerMetadata:t})}})),request:{body:r},response:{headers:a}}}},YJ=k({prompt_tokens:_().nullish(),completion_tokens:_().nullish(),total_tokens:_().nullish(),prompt_tokens_details:k({cached_tokens:_().nullish()}).nullish(),completion_tokens_details:k({reasoning_tokens:_().nullish(),accepted_prediction_tokens:_().nullish(),rejected_prediction_tokens:_().nullish()}).nullish()}).nullish();function XJ(e){return{inputTokens:e?.prompt_tokens??void 0,outputTokens:e?.completion_tokens??void 0,totalTokens:e?.total_tokens??void 0,reasoningTokens:e?.completion_tokens_details?.reasoning_tokens??void 0,cachedInputTokens:e?.prompt_tokens_details?.cached_tokens??void 0}}var ZJ=k({id:y().nullish(),created:_().nullish(),model:y().nullish(),choices:E(k({message:k({role:s(`assistant`).nullish(),content:y().nullish(),reasoning_content:y().nullish(),reasoning:y().nullish(),tool_calls:E(k({id:y().nullish(),function:k({name:y(),arguments:y()})})).nullish()}),finish_reason:y().nullish()})),usage:YJ}),QJ=e=>c([k({id:y().nullish(),created:_().nullish(),model:y().nullish(),choices:E(k({delta:k({role:v([`assistant`]).nullish(),content:y().nullish(),reasoning_content:y().nullish(),reasoning:y().nullish(),tool_calls:E(k({index:_(),id:y().nullish(),function:k({name:y().nullish(),arguments:y().nullish()})})).nullish()}).nullish(),finish_reason:y().nullish()})),usage:YJ}),e]);function $J({prompt:e,user:t=`user`,assistant:n=`assistant`}){let r=``;e[0].role===`system`&&(r+=`${e[0].content}
|
|
127
|
+
|
|
128
|
+
`,e=e.slice(1));for(let{role:i,content:a}of e)switch(i){case`system`:throw new Eq({message:"Unexpected system message in prompt: ${content}",prompt:e});case`user`:{let e=a.map(e=>{switch(e.type){case`text`:return e.text}}).filter(Boolean).join(``);r+=`${t}:
|
|
129
|
+
${e}
|
|
130
|
+
|
|
131
|
+
`;break}case`assistant`:{let e=a.map(e=>{switch(e.type){case`text`:return e.text;case`tool-call`:throw new nJ({functionality:`tool-call messages`})}}).join(``);r+=`${n}:
|
|
132
|
+
${e}
|
|
133
|
+
|
|
134
|
+
`;break}case`tool`:throw new nJ({functionality:`tool messages`});default:throw Error(`Unsupported role: ${i}`)}return r+=`${n}:
|
|
135
|
+
`,{prompt:r,stopSequences:[`
|
|
136
|
+
${t}:`]}}function eY({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function tY(e){switch(e){case`stop`:return`stop`;case`length`:return`length`;case`content_filter`:return`content-filter`;case`function_call`:case`tool_calls`:return`tool-calls`;default:return`unknown`}}var nY=k({echo:r().optional(),logitBias:b(y(),_()).optional(),suffix:y().optional(),user:y().optional()}),rY=class{constructor(e,t){this.specificationVersion=`v2`,this.modelId=e,this.config=t;let n=t.errorStructure??KJ;this.chunkSchema=oY(n.errorSchema),this.failedResponseHandler=NJ(n)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}async getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:r,topK:i,frequencyPenalty:a,presencePenalty:o,stopSequences:s,responseFormat:c,seed:l,providerOptions:u,tools:d,toolChoice:f}){let p=[],m=await kJ({provider:this.providerOptionsName,providerOptions:u,schema:nY})??{};i!=null&&p.push({type:`unsupported-setting`,setting:`topK`}),d?.length&&p.push({type:`unsupported-setting`,setting:`tools`}),f!=null&&p.push({type:`unsupported-setting`,setting:`toolChoice`}),c!=null&&c.type!==`text`&&p.push({type:`unsupported-setting`,setting:`responseFormat`,details:`JSON response format is not supported.`});let{prompt:h,stopSequences:g}=$J({prompt:e}),_=[...g??[],...s??[]];return{args:{model:this.modelId,echo:m.echo,logit_bias:m.logitBias,suffix:m.suffix,user:m.user,max_tokens:t,temperature:n,top_p:r,frequency_penalty:a,presence_penalty:o,seed:l,...u?.[this.providerOptionsName],prompt:h,stop:_.length>0?_:void 0},warnings:p}}async doGenerate(e){let{args:t,warnings:n}=await this.getArgs(e),{responseHeaders:r,value:i,rawValue:a}=await jJ({url:this.config.url({path:`/completions`,modelId:this.modelId}),headers:rJ(this.config.headers(),e.headers),body:t,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:FJ(aY),abortSignal:e.abortSignal,fetch:this.config.fetch}),o=i.choices[0],s=[];return o.text!=null&&o.text.length>0&&s.push({type:`text`,text:o.text}),{content:s,usage:{inputTokens:i.usage?.prompt_tokens??void 0,outputTokens:i.usage?.completion_tokens??void 0,totalTokens:i.usage?.total_tokens??void 0},finishReason:tY(o.finish_reason),request:{body:t},response:{...eY(i),headers:r,body:a},warnings:n}}async doStream(e){let{args:t,warnings:n}=await this.getArgs(e),r={...t,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:i,value:a}=await jJ({url:this.config.url({path:`/completions`,modelId:this.modelId}),headers:rJ(this.config.headers(),e.headers),body:r,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:PJ(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),o=`unknown`,s={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},c=!0;return{stream:a.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(e.includeRawChunks&&n.enqueue({type:`raw`,rawValue:t.rawValue}),!t.success){o=`error`,n.enqueue({type:`error`,error:t.error});return}let r=t.value;if(`error`in r){o=`error`,n.enqueue({type:`error`,error:r.error});return}c&&(c=!1,n.enqueue({type:`response-metadata`,...eY(r)}),n.enqueue({type:`text-start`,id:`0`})),r.usage!=null&&(s.inputTokens=r.usage.prompt_tokens??void 0,s.outputTokens=r.usage.completion_tokens??void 0,s.totalTokens=r.usage.total_tokens??void 0);let i=r.choices[0];i?.finish_reason!=null&&(o=tY(i.finish_reason)),i?.text!=null&&n.enqueue({type:`text-delta`,id:`0`,delta:i.text})},flush(e){c||e.enqueue({type:`text-end`,id:`0`}),e.enqueue({type:`finish`,finishReason:o,usage:s})}})),request:{body:r},response:{headers:i}}}},iY=k({prompt_tokens:_(),completion_tokens:_(),total_tokens:_()}),aY=k({id:y().nullish(),created:_().nullish(),model:y().nullish(),choices:E(k({text:y(),finish_reason:y()})),usage:iY.nullish()}),oY=e=>c([k({id:y().nullish(),created:_().nullish(),model:y().nullish(),choices:E(k({text:y(),finish_reason:y().nullish(),index:_()})),usage:iY.nullish()}),e]),sY=k({dimensions:_().optional(),user:y().optional()}),cY=class{constructor(e,t){this.specificationVersion=`v2`,this.modelId=e,this.config=t}get provider(){return this.config.provider}get maxEmbeddingsPerCall(){return this.config.maxEmbeddingsPerCall??2048}get supportsParallelCalls(){return this.config.supportsParallelCalls??!0}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:r}){let i=Object.assign(await kJ({provider:`openai-compatible`,providerOptions:r,schema:sY})??{},await kJ({provider:this.providerOptionsName,providerOptions:r,schema:sY})??{});if(e.length>this.maxEmbeddingsPerCall)throw new Wq({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:e});let{responseHeaders:a,value:o,rawValue:s}=await jJ({url:this.config.url({path:`/embeddings`,modelId:this.modelId}),headers:rJ(this.config.headers(),t),body:{model:this.modelId,input:e,encoding_format:`float`,dimensions:i.dimensions,user:i.user},failedResponseHandler:NJ(this.config.errorStructure??KJ),successfulResponseHandler:FJ(lY),abortSignal:n,fetch:this.config.fetch});return{embeddings:o.data.map(e=>e.embedding),usage:o.usage?{tokens:o.usage.prompt_tokens}:void 0,providerMetadata:o.providerMetadata,response:{headers:a,body:s}}}},lY=k({data:E(k({embedding:E(_())})),usage:k({prompt_tokens:_()}).nullish(),providerMetadata:b(y(),b(y(),m())).optional()}),uY=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v2`,this.maxImagesPerCall=10}get provider(){return this.config.provider}get providerOptionsKey(){return this.config.provider.split(`.`)[0].trim()}async doGenerate({prompt:e,n:t,size:n,aspectRatio:r,seed:i,providerOptions:a,headers:o,abortSignal:s}){var c;let l=[];r!=null&&l.push({type:`unsupported-setting`,setting:`aspectRatio`,details:"This model does not support aspect ratio. Use `size` instead."}),i!=null&&l.push({type:`unsupported-setting`,setting:`seed`});let u=((c=this.config._internal)?.currentDate)?.call(c)??new Date,{value:d,responseHeaders:f}=await jJ({url:this.config.url({path:`/images/generations`,modelId:this.modelId}),headers:rJ(this.config.headers(),o),body:{model:this.modelId,prompt:e,n:t,size:n,...a[this.providerOptionsKey],response_format:`b64_json`},failedResponseHandler:NJ(this.config.errorStructure??KJ),successfulResponseHandler:FJ(dY),abortSignal:s,fetch:this.config.fetch});return{images:d.data.map(e=>e.b64_json),warnings:l,response:{timestamp:u,modelId:this.modelId,headers:f}}}},dY=k({data:E(k({b64_json:y()}))}),fY=`1.0.39`;function pY(e){let t=BJ(e.baseURL),n=e.name,r={...e.apiKey&&{Authorization:`Bearer ${e.apiKey}`},...e.headers},i=()=>dJ(r,`ai-sdk/openai-compatible/${fY}`),a=r=>({provider:`${n}.${r}`,url:({path:n})=>{let r=new URL(`${t}${n}`);return e.queryParams&&(r.search=new URLSearchParams(e.queryParams).toString()),r.toString()},headers:i,fetch:e.fetch}),o=e=>s(e),s=t=>new JJ(t,{...a(`chat`),includeUsage:e.includeUsage,supportsStructuredOutputs:e.supportsStructuredOutputs,supportedUrls:e.supportedUrls,transformRequestBody:e.transformRequestBody,metadataExtractor:e.metadataExtractor,convertUsage:e.convertUsage}),c=t=>new rY(t,{...a(`completion`),includeUsage:e.includeUsage}),l=e=>new cY(e,{...a(`embedding`)}),u=e=>new uY(e,a(`image`)),d=e=>o(e);return d.languageModel=o,d.chatModel=s,d.completionModel=c,d.textEmbeddingModel=l,d.imageModel=u,d}var mY=`Tool call cancelled by user`,hY=`abort`,gY=`Analysis cancelled - session was deleted`,_Y=`Analysis cancelled`,vY=`data-sqlrooms-chat-error`;function yY(e){return e?e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(``):``}function bY(e){let t=(e?.metadata)?.sqlrooms?.errorMessage?.error;return typeof t==`string`?{error:t}:void 0}function xY(e){let t=e?.metadata;return typeof t?.sqlrooms?.isCompleted==`boolean`?t.sqlrooms.isCompleted:void 0}function SY(e,t){let n=e.metadata??{};e.metadata={...n,sqlrooms:{...n.sqlrooms??{},errorMessage:t}}}function CY(e){return{type:vY,data:e}}function wY(e){if(!e||typeof e!=`object`)return;let t=e;if(t.type!==`data-sqlrooms-chat-error`)return;let n=t.data;if(!n||typeof n!=`object`)return;let r=n.error;return typeof r==`string`?{error:r}:void 0}function TY(e){return e.some(e=>!!bY(e)||e.parts.some(e=>!!wY(e)))}function EY(e){if((e.type===`text`||e.type===`reasoning`)&&e.state===`streaming`)return!1;if(e.type===`dynamic-tool`||e.type.startsWith(`tool-`)){let t=e.state;return t===`output-available`||t===`output-error`||t===`output-denied`}return!0}function DY(e){return e.every(e=>e.parts.every(EY))}function OY(e,t={}){if(!e?.length)return[];let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!i||i.role!==`user`)continue;let a=[],o=r+1;for(;o<e.length;){let t=e[o];if(!t||t.role===`user`)break;t.role===`assistant`&&a.push(t),o++}let s=!e.slice(o).some(e=>e.role===`user`),c=bY(i),l=xY(i),u=a.length>0&&DY(a)&&!(t.isRunning&&s);n.push({id:i.id,prompt:yY(i),userMessage:i,assistantMessages:a,isCompleted:!!c||(l??u),errorMessage:c})}return n}function kY(e,t={}){return OY(e,t).map(e=>({id:e.id,prompt:e.prompt,isCompleted:e.isCompleted,...e.errorMessage?{errorMessage:e.errorMessage}:{}}))}function AY(e){let t=e.filter(Boolean);if(t.length===0)return;if(t.length===1)return t[0];let n=new AbortController,r=()=>{n.signal.aborted||n.abort()};for(let e of t){if(e.aborted){r();break}e.addEventListener(hY,r,{once:!0})}return n.signal}var jY=class e extends Error{progressSnapshot;constructor(t=`Operation was aborted`,n){super(t),this.name=`ToolAbortError`,this.progressSnapshot=n,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function MY(e){let t=[];return Object.entries(e.providers).forEach(([e,n])=>{n.models.forEach(n=>{t.push({provider:e,label:n.modelName,value:n.modelName})})}),e.customModels.forEach(e=>{t.push({provider:`custom`,label:e.modelName,value:e.modelName})}),t}function NY(e){return e.type===`text`}function PY(e){return e.type===`reasoning`}function FY(e){return typeof e.type==`string`&&e.type.startsWith(`tool-`)}function IY(e){return e.type===`dynamic-tool`}function LY(e,t){if(!e)return!1;for(let n of t)if(!(typeof n.type==`string`&&n.type.startsWith(`step-`))){if(FY(n)||IY(n))return n.input?.reasoning?.toString().trim()===e;break}return!1}function RY(e){return Array.isArray(e.uiMessages)?{...e,uiMessages:WY(e.uiMessages)}:e}function zY(e){return{...RY(e),isRunning:!1}}function BY(e){return e?.sessions?{...e,sessions:e.sessions.map(zY)}:e}function VY(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(VY);let t=e;if(!(`agentToolCalls`in t))return e;let n={};for(let[e,r]of Object.entries(t))e!==`agentToolCalls`&&(n[e]=VY(r));return n}function HY(e,t){let n=t===void 0?void 0:new Set(t),r=e=>{if(n===void 0||typeof e.type!=`string`)return!1;if(e.type===`dynamic-tool`){let t=e.toolName;return typeof t==`string`&&!n.has(t)}if(e.type.startsWith(`tool-`)){let t=e.type.slice(5);return!n.has(t)}return!1};return e.filter(e=>e.role!==`assistant`||!e.parts||e.parts.length===0?!0:!e.parts.every(e=>e.type===vY)).map(e=>{if(!e.parts||e.parts.length===0)return e;let t=e.parts.filter(e=>{if(e.type===`text`){let t=e;return t.text&&t.text.trim().length>0}if(e.type===`reasoning`){let t=e;return t.text&&t.text.trim().length>0}return!r(e)}).map(e=>{let t=e;return t.state===`output-available`&&t.output&&typeof t.output==`object`&&`agentToolCalls`in t.output?{...e,output:VY(t.output)}:e});return t.length===0&&e.role===`assistant`?{...e,parts:[{type:`text`,text:`[Response interrupted]`}]}:{...e,parts:t}}).filter(e=>e.parts&&e.parts.length>0)}function UY(e){let t=XK({messages:e}),n=e[e.length-1],r=n?.role===`assistant`,i=!1;if(r){let e=n?.parts??[],t=-1;for(let n=e.length-1;n>=0;n--)if(e[n]?.type===`step-start`){t=n;break}i=e.slice(t+1).some(e=>typeof e?.type==`string`&&(e.type.startsWith(`tool-`)||e.type===`dynamic-tool`))}return r&&!t&&!i||!t&&!r}function WY(e){return e.map(e=>{if(e.role!==`assistant`||!e.parts)return e;let t=e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.type==`string`?t.type:void 0;return!!n&&`toolCallId`in t&&(n===`dynamic-tool`||n.startsWith(`tool-`))},n=[...e.parts];for(let e=0;e<n.length;e++){let t=n[e];t?.type===`reasoning`&&t.state!==`done`&&(n[e]={...n[e],state:`done`})}for(let e=n.length-1;e>=0;e--){let r=n[e];if(!t(r))continue;let i=r;if(i.state?.startsWith(`output`)||i.state===`approval-requested`||i.state===`approval-responded`){i.state===`output-error`&&i.input!==void 0&&(n[e]={...n[e],input:void 0,rawInput:i.rawInput??i.input});continue}let a={toolCallId:i.toolCallId,state:`output-error`,input:void 0,rawInput:i.rawInput??i.input,errorText:mY,providerExecuted:!1};n[e]=i.type===`dynamic-tool`?{type:`dynamic-tool`,toolName:i.toolName||`unknown`,...a}:{type:i.type,...a}}return{...e,parts:n}})}function GY(e){let t=e.tools;return!t||typeof t!=`object`?[]:Object.entries(t).map(([e,t])=>{let n=t&&typeof t==`object`?t:{};return{name:e,description:typeof n.description==`string`?n.description:void 0,hasExecute:typeof n.execute==`function`,hasRenderer:typeof n.renderer==`function`||typeof n.render==`function`,needsApproval:!!n.needsApproval}})}function KY(e){if(e&&typeof e==`object`&&`agentToolCalls`in e&&Array.isArray(e.agentToolCalls))return e.agentToolCalls}var qY=200;function JY(e){if(e==null)return e;try{let t=typeof e==`string`?e:JSON.stringify(e);return t.length<=qY?e:t.slice(0,qY)+`...`}catch{return`[output too large to summarize]`}}function YY(e){let t=Date.now();for(let[n,r]of e)(r.state===`pending`||r.state===`approval-requested`)&&e.set(n,{...r,state:`error`,errorText:mY,completedAt:t,approvalId:void 0})}function XY(e,t,n,r){let i=[],a=[],o=[];for(let e of t.values()){let t=r.getState().ai.readAbortSnapshot?.(e.toolCallId);e.state===`success`?i.push({toolName:e.toolName,input:e.input,output:JY(e.output),...t?{childSnapshot:t}:{}}):e.state===`error`?a.push({toolName:e.toolName,input:e.input,errorText:e.errorText||`unknown`,...t?{childSnapshot:t}:{}}):o.push({toolName:e.toolName,input:e.input,...t?{childSnapshot:t}:{}})}return{agentName:e,completedTools:i,failedTools:a,pendingTools:o,partialText:n}}function ZY(e,t=``){let n=[];for(let r of e.completedTools){let e=r.input==null?``:JSON.stringify(r.input),i=r.output==null?``:` -> ${typeof r.output==`string`?r.output:JSON.stringify(r.output)}`;n.push(`${t}- Completed: ${r.toolName}(${e})${i}`),r.childSnapshot&&n.push(ZY(r.childSnapshot,t+` `))}for(let r of e.failedTools)n.push(`${t}- Failed: ${r.toolName} (${r.errorText})`),r.childSnapshot&&n.push(ZY(r.childSnapshot,t+` `));for(let r of e.pendingTools){let e=r.input==null?``:JSON.stringify(r.input);n.push(`${t}- Pending: ${r.toolName}(${e})`),r.childSnapshot&&n.push(ZY(r.childSnapshot,t+` `))}if(e.partialText){let r=e.partialText.length>200?e.partialText.slice(0,200)+`...`:e.partialText;n.push(`${t}- Partial response: ${r}`)}return n.join(`
|
|
137
|
+
`)}async function QY(e,t,n,r,i){let a=()=>{if(i?.aborted)throw new jY(mY)},o=``,s=new Map,c=n.getState().ai.devtools;c?.shouldCaptureAgentSnapshots?.()&&c.writeAgentSnapshot?.(r,{agentName:r,parentToolCallId:r,availableTools:GY(e),startedAt:Date.now()});let l=()=>{n.getState().ai.updateAgentProgress(r,Array.from(s.values()).map(e=>({...e})))},u=[{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:t}]}];for(;;){a();let t=null,c=await HK({agent:e,uiMessages:u,abortSignal:i}),d=new Map;try{for await(let e of c){if(a(),e.type===`text-delta`&&(o+=e.delta),e.type===`tool-approval-request`&&`approvalId`in e&&`toolCallId`in e){let n=e;t={approvalId:n.approvalId,toolCallId:n.toolCallId};let r=s.get(n.toolCallId);r&&(s.set(n.toolCallId,{...r,state:`approval-requested`,approvalId:n.approvalId}),l());continue}if(e.type===`tool-input-available`&&d.set(e.toolCallId,{toolCallId:e.toolCallId,toolName:e.toolName,input:e.input}),!(`toolCallId`in e)||!e.toolCallId)continue;let n=e.toolCallId,r=!1;!s.has(n)&&`toolName`in e&&e.toolName&&(s.set(n,{toolCallId:n,toolName:e.toolName,state:`pending`,startedAt:Date.now()}),r=!0);let i=s.get(n);if(i){if(e.type===`tool-input-available`)s.set(n,{...i,input:e.input}),r=!0;else if(e.type===`tool-output-available`){let t=KY(e.output);s.set(n,{...i,output:e.output,state:`success`,completedAt:Date.now(),...t?{agentToolCalls:t}:{}}),r=!0;let a=d.get(n);a&&(a.output=e.output)}else e.type===`tool-output-error`||e.type===`tool-input-error`?(s.set(n,{...i,errorText:e.errorText,state:`error`,completedAt:Date.now()}),r=!0):e.type===`tool-output-denied`&&(s.set(n,{...i,state:`error`,errorText:`Denied by user`,completedAt:Date.now()}),r=!0);r&&l()}}}catch(e){if(YY(s),l(),i?.aborted){let e=XY(r,s,o,n);throw n.getState().ai.writeAbortSnapshot?.(r,e),new jY(mY,e)}throw e}if(!t)break;let f=s.get(t.toolCallId);if(!f||!n.getState().ai.requestSubAgentApproval)break;let p=await new Promise(e=>{a(),n.getState().ai.requestSubAgentApproval({toolCallId:t.toolCallId,approvalId:t.approvalId,toolName:f.toolName,input:f.input,resolve:e})});a(),n.getState().ai.clearSubAgentApproval?.(t.approvalId),p?s.set(t.toolCallId,{...f,state:`pending`,approvalId:void 0}):s.set(t.toolCallId,{...f,state:`error`,errorText:`Denied by user`,approvalId:void 0}),l();let m={id:crypto.randomUUID(),role:`assistant`,parts:Array.from(d.values()).map(e=>e.toolCallId===t.toolCallId?{type:`tool-${e.toolName}`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,state:p?`approval-responded`:`output-denied`,approval:{id:t.approvalId,approved:p}}:{type:`tool-${e.toolName}`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,output:e.output,state:`output-available`})};u=[...u,m]}if(i?.aborted&&YY(s),l(),i?.aborted){let e=XY(r,s,o,n);throw n.getState().ai.writeAbortSnapshot?.(r,e),new jY(mY,e)}return{finalOutput:o,agentToolCalls:Array.from(s.values())}}function $Y(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(!r||r.role!==`assistant`)continue;let i=r.parts.filter(e=>typeof e.type==`string`&&(e.type.startsWith(`tool-`)||e.type===`dynamic-tool`)).map(e=>e.toolCallId).filter(e=>!!e);if(i.length===0)continue;let a={};for(let e of i){let n=t[e];n&&(a[e]=n)}if(Object.keys(a).length>0){let e=r.metadata??{};r.metadata={...e,toolTimings:{...e.toolTimings??{},...a}}}}}function eX(e,t){for(let n of e)if(!(n.role!==`assistant`||!n.parts))for(let e=0;e<n.parts.length;e++){let r=n.parts[e];if(r.state!==`output-error`||!r.toolCallId||typeof r.toolCallId!=`string`)continue;let i=t.ai.readAbortSnapshot?.(r.toolCallId);if(!i)continue;let a=ZY(i);r.errorText=`${typeof r.errorText==`string`?r.errorText:mY}\nProgress before cancellation:\n${a}`}}function tX(e,t){let n=nX(e);rX(n,t.ai.agentProgress),e.agentProgress=structuredClone(aX(t.ai.agentProgress,n)),t.ai.devtools.shouldPersistAgentSnapshots()?e.agentSnapshots=structuredClone(aX(t.ai.devtools.agentSnapshots,n)):delete e.agentSnapshots}function nX(e){let t=new Set;for(let n of e.uiMessages??[])for(let e of n.parts??[]){let n=e.toolCallId;typeof n==`string`&&t.add(n)}return t}function rX(e,t){let n=!0;for(;n;){n=!1;for(let[r,i]of Object.entries(t))if(e.has(r))for(let t of i)n=iX(e,t)||n}}function iX(e,t){let n=!1;e.has(t.toolCallId)||(e.add(t.toolCallId),n=!0);for(let r of t.agentToolCalls??[])n=iX(e,r)||n;return n}function aX(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)))}function oX(e,t){if(t)return e.getState().ai.config.sessions.find(e=>e.id===t)}function sX(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>{if(!n||typeof n.execute!=`function`)return[e,n];let r=n.execute;return[e,{...n,execute:async(e,n)=>{let i=typeof n?.toolCallId==`string`?n.toolCallId:void 0;return i&&t.sessionId&&t.state.ai.setToolCallSession(i,t.sessionId),r(e,{...n,sessionId:t.sessionId,aiRunContext:t.getAiRunContext?t.getAiRunContext():t.aiRunContext,getAiRunContext:t.getAiRunContext,setAiRunContext:t.setAiRunContext,setPrimaryRunContextItem:t.setPrimaryRunContextItem})}}]}))}var cX=new Map;function lX(e,t){cX.set(e,structuredClone(t))}function uX(e){let t=cX.get(e);return cX.delete(e),t}function dX(e,t){if(!(!t||t.totalTokens<=0))for(let n=e.length-1;n>=0;n--){let r=e[n];if(!(!r||r.role!==`assistant`)){r.metadata={...r.metadata??{},tokenUsage:t};return}}}function fX(e){return{inputTokens:e?.inputTokens??0,outputTokens:e?.outputTokens??0,totalTokens:e?.totalTokens??0,inputTokenDetails:{cacheReadTokens:e?.inputTokenDetails?.cacheReadTokens,cacheWriteTokens:e?.inputTokenDetails?.cacheWriteTokens},outputTokenDetails:{reasoningTokens:e?.outputTokenDetails?.reasoningTokens}}}function pX({sessionId:e,store:t,defaultProvider:n,defaultModel:r,headers:i,getInstructions:a,getCustomModel:o}){return()=>new qK({fetch:async(s,c)=>{let l=c?.body,u={};try{u=l?JSON.parse(l):{}}catch(e){console.error(`Failed to parse chat transport body. Messages will be empty.`,{bodyType:typeof l,bodyLength:l?.length,parseError:e}),u={}}let d=u||{},f=t.getState(),p=oX(t,e),m=p?.modelProvider||n,h=p?.model||r,g=p?.runContext,_=t=>{g=t,f.ai.setSessionRunContext(e,t)},v=f.ai.getApiKeyFromSettings(),y=f.ai.getBaseUrlFromSettings(),b=o?.();b||=pY({apiKey:v,name:m,baseURL:y??`https://api.openai.com/v1`,headers:i}).chatModel(h);let x=Array.isArray(d.messages)?d.messages:[],S=sX(f.ai.tools||{},{state:f,sessionId:e,aiRunContext:g,getAiRunContext:()=>g,setAiRunContext:_,setPrimaryRunContextItem:e=>{_(aF(g,e))}}),C=a(),w=f.ai.getProviderOptions?.({provider:m,modelId:h}),T=f.ai.getAbortController(e)?.signal,E=AY([c?.signal??void 0,T]),ee=f.ai.getMaxStepsFromSettings(),D=new IK({model:b,instructions:C,tools:S,stopWhen:qG(ee),onFinish:({totalUsage:t,usage:n})=>{lX(e,fX(t??n))},...w?{providerOptions:w}:{}}),O={inputTokens:0,outputTokens:0,totalTokens:0};return UK({agent:D,uiMessages:HY(WY(x),Object.keys(S)),abortSignal:E,messageMetadata:({part:t})=>{if(t.type===`finish-step`){let e=t.usage;O.inputTokens+=e.inputTokens??0,O.outputTokens+=e.outputTokens??0,O.totalTokens+=e.totalTokens??0,(e.inputTokenDetails?.cacheReadTokens!=null||e.inputTokenDetails?.cacheWriteTokens!=null)&&(O.inputTokenDetails={cacheReadTokens:(O.inputTokenDetails?.cacheReadTokens??0)+(e.inputTokenDetails?.cacheReadTokens??0),cacheWriteTokens:(O.inputTokenDetails?.cacheWriteTokens??0)+(e.inputTokenDetails?.cacheWriteTokens??0)}),e.outputTokenDetails?.reasoningTokens!=null&&(O.outputTokenDetails={reasoningTokens:(O.outputTokenDetails?.reasoningTokens??0)+(e.outputTokenDetails.reasoningTokens??0)})}if(t.type===`finish`)return lX(e,O),{tokenUsage:O}}})}})}function mX(e){return(t,n)=>new qK({api:t,credentials:`include`,headers:n,fetch:async(t,n)=>{let{store:r,defaultProvider:i,defaultModel:a,sessionId:o,getInstructions:s}=e,c=r.getState(),l=n?.body,u={};try{u=l?JSON.parse(l):{}}catch(e){console.error(`Failed to parse remote chat transport body. Messages will be empty.`,{bodyType:typeof l,bodyLength:l?.length,parseError:e}),u={}}let d=oX(r,o),f=d?.modelProvider||i,p=d?.model||a,m=typeof u==`object`&&u?u:{},h=Array.isArray(m.messages)?HY(WY(m.messages)):[],g={...m,messages:h,modelProvider:f,model:p,instructions:s(),runContext:d?.runContext,maxSteps:c.ai.getMaxStepsFromSettings()},_=c.ai.getAbortController(o)?.signal,v=AY([n?.signal??void 0,_]);return fetch(t,{...n,signal:v,body:JSON.stringify(g)})}})}function hX({sessionMessages:e,fallbackMessages:t}){return t&&t.length>0?t:e}function gX(e){return!!(e?.role===`assistant`&&e.parts?.some(e=>e.type===`data-sqlrooms-chat-error`))}function _X(e){return{id:EP(),role:`assistant`,parts:[CY({error:e})]}}function vX({store:e,onChatFinish:t}){return{onChatFinish:({sessionId:n,messages:r})=>{if(n)try{let i=e.getState();if(i.ai.getAbortController(n)?.signal.aborted){let t=oX(e,n)?.uiMessages||[],a=WY(r&&r.length>0?r:t);eX(a,i),uX(n),$Y(a,i.ai.getToolTimings());let o=a.filter(e=>e.role===`user`).slice(-1)[0];o&&SY(o,{error:mY}),i.ai.setSessionUiMessages(n,a),i.ai.setIsRunning(n,!1),i.ai.setAbortController(n,void 0),i.ai.clearAbortSnapshots?.(),e.setState(e=>w(e,e=>{let t=e.ai.config.sessions.find(e=>e.id===n);t&&(t.messagesRevision=(t.messagesRevision||0)+1,tX(t,i))}));return}let a=WY(r);dX(a,uX(n)),$Y(a,i.ai.getToolTimings()),i.ai.setSessionUiMessages(n,a),e.setState(e=>w(e,e=>{let t=e.ai.config.sessions.find(e=>e.id===n);t&&tX(t,i)})),UY(a)&&(i.ai.setIsRunning(n,!1),i.ai.setAbortController(n,void 0),t?.({sessionId:n,messages:a}))}catch(e){throw console.error(`onChatFinish error:`,e),e}},onChatError:(t,n,r)=>{try{uX(t);let i=bv(n);if((!i||i.trim().length===0)&&(i=`Unknown error`),yX(n,i)){let n=oX(e,t)?.modelProvider||`openai`;e.getState().ai.setApiKeyError(n,!0)}let a=e.getState(),o=a.ai.getToolTimings();e.setState(e=>w(e,e=>{if(!t)return;let n=e.ai.config.sessions.find(e=>e.id===t);if(n){let e=WY(hX({sessionMessages:n.uiMessages||[],fallbackMessages:r}));$Y(e,o);let t=e.filter(e=>e.role===`user`).slice(-1)[0];t&&SY(t,{error:i}),gX(e.at(-1))||e.push(_X(i)),n.uiMessages=e,tX(n,a)}})),e.setState(e=>w(e,e=>{let n=e.ai.config.sessions.find(e=>e.id===t);n&&(n.messagesRevision=(n.messagesRevision||0)+1)})),e.getState().ai.setIsRunning(t,!1),e.getState().ai.setAbortController(t,void 0),e.getState().ai.clearAbortSnapshots?.()}catch(e){throw console.error(`Failed to store chat error:`,e),e}}}}function yX(e,t){if(e&&typeof e==`object`){let t=e,n=t.status??t.statusCode??t.response?.status;if(n===401||n===403)return!0}let n=t.toLowerCase();return[`invalid api key`,`incorrect api key`,`invalid_api_key`,`unauthorized`,`authentication failed`,`api key is invalid`,`api key not found`,`invalid authorization`,`invalid credentials`,`access denied`,`401`,`403`].some(e=>n.includes(e))}function bX(e){return xX(e)&&`aiSettings`in e&&xX(e.aiSettings)&&`config`in e.aiSettings&&xX(e.aiSettings.config)}function xX(e){return typeof e==`object`&&!!e}function SX(e,t){try{let n=JSON.stringify(e);return new TextEncoder().encode(n).byteLength>t?void 0:JSON.parse(n)}catch{return}}function CX(e){let t=new Set(e.sessions.map(e=>e.id)),n=e.sessionForks??{},r=Object.fromEntries(Object.entries(n).filter(([e])=>t.has(e)));return e.sessionForks&&Object.keys(r).length===Object.keys(n).length?e:{...e,sessionForks:r}}function wX(e){let t=new Set;for(let n of e)for(let e of n.parts??[]){let n=e.toolCallId;typeof n==`string`&&t.add(n)}return t}function TX(e,t){if(!t)return;let n=!0;for(;n;){n=!1;for(let[r,i]of Object.entries(t))if(!(!e.has(r)||!Array.isArray(i)))for(let t of i)n=EX(e,t)||n}}function EX(e,t){if(!t||typeof t!=`object`)return!1;let n=!1,r=t;if(typeof r.toolCallId==`string`&&!e.has(r.toolCallId)&&(e.add(r.toolCallId),n=!0),Array.isArray(r.agentToolCalls))for(let t of r.agentToolCalls)n=EX(e,t)||n;return n}function DX({sourceSession:e,targetMessages:t}){if(!e.agentProgress)return;let n=wX(t);TX(n,e.agentProgress);let r=Object.fromEntries(Object.entries(e.agentProgress).filter(([e])=>n.has(e)));return Object.keys(r).length>0?structuredClone(r):void 0}function OX({sourceSession:e,targetMessages:t}){if(!e.agentSnapshots)return;let n=wX(t);TX(n,e.agentProgress);let r=Object.fromEntries(Object.entries(e.agentSnapshots).filter(([e])=>n.has(e)));return Object.keys(r).length>0?structuredClone(r):void 0}function kX({sourceSession:e,args:t,targetSessionId:n,now:r}){let i=e.uiMessages,a=OY(i,{isRunning:e.isRunning}),o=t.sourceTurnId?a.find(e=>e.id===t.sourceTurnId):t.legacySourceAnalysisResultId?a.find(e=>e.id===t.legacySourceAnalysisResultId):void 0,s=typeof t.sourceMessageIndex==`number`?t.sourceMessageIndex:-1;if(s<0&&t.sourceMessageId&&(s=i.findIndex(e=>e.id===t.sourceMessageId)),s<0&&o){let e=new Set([o.userMessage.id,...o.assistantMessages.map(e=>e.id)]);for(let t=i.length-1;t>=0;t--){let n=i[t];if(n&&e.has(n.id)){s=t;break}}}if(s<0||s>=i.length)return;let c=i[s];if(!c||c.role!==`assistant`)return;if(!o){if(t.sourceTurnId||t.legacySourceAnalysisResultId)return;o=a.find(e=>e.assistantMessages.some(e=>e.id===c.id))}if(!o||!o.isCompleted||!o.assistantMessages.some(e=>e.id===c.id))return;let l=structuredClone(i.slice(0,s+1)),u=e.draftContextItemIds?Array.from(new Set(e.draftContextItemIds)):void 0,d=DX({sourceSession:e,targetMessages:l}),f=OX({sourceSession:e,targetMessages:l});return{forkedSession:{id:n,name:t.name??`Fork of ${e.name||`Untitled`}`,modelProvider:e.modelProvider,model:e.model,...e.customModelName?{customModelName:e.customModelName}:{},...e.baseUrl?{baseUrl:e.baseUrl}:{},createdAt:new Date(r),uiMessages:l,messagesRevision:0,prompt:``,...u?{draftContextItemIds:u}:{},...!u&&e.runContext?{runContext:structuredClone(e.runContext)}:{},...d?{agentProgress:d}:{},...f?{agentSnapshots:f}:{},isRunning:!1,lastOpenedAt:r},forkOrigin:{sourceSessionId:e.id,sourceMessageId:c.id,sourceTurnId:o.id,sourceMessageIndex:s,...t.legacySourceAnalysisResultId?{legacySourceAnalysisResultId:t.legacySourceAnalysisResultId}:{},sourceSessionNameAtFork:e.name,createdAt:r}}}var AX=`@sqlrooms/ai-core`;function jX(e){let{initialPrompt:t=``,tools:n,getApiKey:r,getBaseUrl:i,maxSteps:a,getInstructions:o,defaultProvider:s=`openai`,defaultModel:c=`gpt-4.1`,getAvailableModels:l,getCustomModel:u,getProviderOptions:d,chatEndPoint:f=``,chatHeaders:p={},getRunContext:m,formatRunContextInstructions:h}=e,g={captureAgentSnapshots:e.devtools?.captureAgentSnapshots??!1,persistAgentSnapshots:e.devtools?.persistAgentSnapshots??!1,maxAgentSnapshotBytes:e.devtools?.maxAgentSnapshotBytes??64e3};return C((_,v,y)=>{let b=new WeakMap,x=BY(e.config);function C(e){let t={},n={},r={};for(let i of e.sessions){if(i.agentProgress&&Object.assign(n,i.agentProgress),i.agentSnapshots)for(let[e,t]of Object.entries(i.agentSnapshots)){let n=SX(t,g.maxAgentSnapshotBytes);n&&(r[e]=n)}let e=i.uiMessages??[];for(let n of e){if(n.role!==`assistant`)continue;let e=n.metadata;e?.toolTimings&&Object.assign(t,e.toolTimings)}}return{timings:t,progress:n,snapshots:r}}let T=new Map,E=new Map,D=new Map,O=new Map,te=new Map,k=new Map,ne=new Map,re=new Map,ie=(e,t)=>{let n=l?.()??[],r=(e,t)=>!!(e&&t&&(n.length===0||n.some(n=>n.provider===e&&n.value===t)));if(r(e,t))return{modelProvider:e,model:t};if(r(s,c))return{modelProvider:s,model:c};let i=n[0];return i?{modelProvider:i.provider,model:i.value}:{modelProvider:s,model:c}},A=CX(uF(x));if(!x?.sessions||x.sessions.length===0){let e=A.sessions[0];e&&(e.modelProvider=s,e.model=c,e.prompt=t,e.isRunning=!1)}let j=new Set(A.sessions.map(e=>e.id));(!A.currentSessionId||!j.has(A.currentSessionId))&&(A.currentSessionId=A.sessions[0]?.id),A.openSessionTabs&&A.openSessionTabs.length>0&&(A.openSessionTabs=A.openSessionTabs.filter(e=>j.has(e))),A.currentSessionId&&!A.openSessionTabs?.includes(A.currentSessionId)&&(A.openSessionTabs=[A.currentSessionId,...A.openSessionTabs??[]]),(!A.openSessionTabs||A.openSessionTabs.length===0)&&(A.openSessionTabs=A.currentSessionId?[A.currentSessionId]:[]);let ae=C(A);return{ai:{initialize:async()=>{S(y,AX,IX());let e=C(v().ai.config);_(t=>w(t,t=>{t.ai.toolTimings=e.timings,t.ai.agentProgress=e.progress,t.ai.devtools.agentSnapshots=e.snapshots}))},destroy:async()=>{ee(y,AX)},config:A,promptSuggestionsVisible:!0,apiKeyErrors:{},tools:n,toolRenderers:e.toolRenderers??{},getProviderOptions:d,setToolCallSession:(e,t)=>{e&&(t?T.set(e,t):T.delete(e))},getToolCallSession:e=>{if(e)return T.get(e)},agentProgress:ae.progress,updateAgentProgress:(e,t)=>{_(n=>w(n,n=>{n.ai.agentProgress[e]=t}))},clearAgentProgress:e=>{_(t=>w(t,t=>{delete t.ai.agentProgress[e]}))},devtools:{agentSnapshots:ae.snapshots,shouldCaptureAgentSnapshots:()=>g.captureAgentSnapshots,shouldPersistAgentSnapshots:()=>g.persistAgentSnapshots,writeAgentSnapshot:(e,t)=>{if(!g.captureAgentSnapshots)return;let n=SX(t,g.maxAgentSnapshotBytes);n&&_(t=>w(t,t=>{t.ai.devtools.agentSnapshots[e]=n}))},clearAgentSnapshots:()=>{_(e=>w(e,e=>{e.ai.devtools.agentSnapshots={}}))}},pendingSubAgentApprovals:{},requestSubAgentApproval:e=>{_(t=>w(t,t=>{t.ai.pendingSubAgentApprovals[e.approvalId]={toolCallId:e.toolCallId,approvalId:e.approvalId,toolName:e.toolName,input:e.input,resolve:e.resolve}})),ne.set(e.approvalId,e.resolve)},resolveSubAgentApproval:(e,t)=>{let n=ne.get(e);n&&(n(t),ne.delete(e)),_(t=>w(t,t=>{delete t.ai.pendingSubAgentApprovals[e]}))},clearSubAgentApproval:e=>{ne.delete(e),_(t=>w(t,t=>{delete t.ai.pendingSubAgentApprovals[e]}))},writeAbortSnapshot:(e,t)=>{re.set(e,t)},readAbortSnapshot:e=>re.get(e),clearAbortSnapshots:()=>{re.clear()},isSummarizing:!1,setIsSummarizing:e=>{_(t=>w(t,t=>{t.ai.isSummarizing=e}))},toolTimings:ae.timings,setToolTiming:(e,t)=>{_(n=>w(n,n=>{n.ai.toolTimings[e]=t}))},getToolTimings:()=>v().ai.toolTimings,getAbortController:e=>E.get(e),setAbortController:(e,t)=>{t?E.set(e,t):E.delete(e)},setChatStop:(e,t)=>{t?D.set(e,t):D.delete(e)},getChatStop:e=>D.get(e),setChatSendMessage:(e,t)=>{t?O.set(e,t):O.delete(e)},getChatSendMessage:e=>O.get(e),setAddToolOutput:(e,t)=>{t?te.set(e,t):te.delete(e)},getAddToolOutput:e=>te.get(e),setAddToolApprovalResponse:(e,t)=>{t?k.set(e,t):k.delete(e)},getAddToolApprovalResponse:e=>k.get(e),setConfig:e=>{let t=CX(BY(e)),n=C(t);_(e=>w(e,e=>{e.ai.config=t,e.ai.toolTimings=n.timings,e.ai.agentProgress=n.progress,e.ai.devtools.agentSnapshots=n.snapshots}))},setPromptSuggestionsVisible:e=>{_(t=>w(t,t=>{t.ai.promptSuggestionsVisible=e}))},setApiKeyError:(e,t)=>{_(n=>w(n,n=>{t?n.ai.apiKeyErrors[e]=!0:delete n.ai.apiKeyErrors[e]}))},hasApiKeyError:()=>{let e=v(),t=e.ai.getCurrentSession()?.modelProvider||s;return!!e.ai.apiKeyErrors[t]},setPrompt:(e,t)=>{_(n=>w(n,n=>{let r=n.ai.config.sessions.find(t=>t.id===e);r&&(r.prompt=t)}))},getPrompt:e=>v().ai.config.sessions.find(t=>t.id===e)?.prompt||``,setIsRunning:(e,t)=>{_(n=>w(n,n=>{let r=n.ai.config.sessions.find(t=>t.id===e);r&&(r.isRunning=t)}))},getIsRunning:e=>v().ai.config.sessions.find(t=>t.id===e)?.isRunning||!1,setAiModel:(e,t)=>{_(n=>w(n,n=>{let r=MX(n);r&&(r.modelProvider=e,r.model=t)}))},getCurrentSession:()=>{let{currentSessionId:e,sessions:t}=v().ai.config;return t.find(t=>t.id===e)},getSessionRunContext:e=>v().ai.config.sessions.find(t=>t.id===e)?.runContext,setSessionRunContext:(e,t)=>{_(n=>w(n,n=>{let r=n.ai.config.sessions.find(t=>t.id===e);r&&(r.runContext=t)}))},getSessionDraftContextItemIds:e=>v().ai.config.sessions.find(t=>t.id===e)?.draftContextItemIds,setSessionDraftContextItemIds:(e,t)=>{_(n=>w(n,n=>{let r=n.ai.config.sessions.find(t=>t.id===e);r&&(r.draftContextItemIds=t?Array.from(new Set(t)):void 0)}))},createSession:(e,t,n)=>{let r=v().ai.getCurrentSession(),i=ie(t||r?.modelProvider,n||r?.model),a=EP(),o=e;o||=`Untitled`,_(e=>w(e,e=>{let t=Date.now();e.ai.config.sessions.unshift({id:a,name:o,modelProvider:i.modelProvider,model:i.model,createdAt:new Date,uiMessages:[],messagesRevision:0,prompt:``,draftContextItemIds:void 0,isRunning:!1,lastOpenedAt:t}),e.ai.config.currentSessionId=a,e.ai.config.openSessionTabs||(e.ai.config.openSessionTabs=[]),e.ai.config.openSessionTabs.push(a)}))},forkSessionFromMessage:e=>{let t=v().ai.config.sessions.find(t=>t.id===e.sourceSessionId);if(!t)return;let n=Date.now(),r=EP(),i=kX({sourceSession:t,args:e,targetSessionId:r,now:n});if(i)return _(e=>w(e,e=>{e.ai.config.sessions.unshift(i.forkedSession),e.ai.config.currentSessionId=r,e.ai.config.openSessionTabs||(e.ai.config.openSessionTabs=[]),e.ai.config.openSessionTabs.push(r),e.ai.config.sessionForks[r]=i.forkOrigin})),r},getSessionForkOrigin:e=>v().ai.config.sessionForks[e],switchSession:e=>{_(t=>w(t,t=>{let n=Date.now();t.ai.config.currentSessionId=e,t.ai.config.openSessionTabs||(t.ai.config.openSessionTabs=[]),t.ai.config.openSessionTabs.includes(e)||t.ai.config.openSessionTabs.push(e);let r=t.ai.config.sessions.find(t=>t.id===e);r&&(r.lastOpenedAt=n)}))},setOpenSessionTabs:e=>{_(t=>w(t,t=>{let n=new Set(t.ai.config.sessions.map(e=>e.id));t.ai.config.openSessionTabs=e.filter(e=>n.has(e))}))},renameSession:(e,t)=>{_(n=>w(n,n=>{let r=n.ai.config.sessions.find(t=>t.id===e);r&&(r.name=t)}))},deleteSession:e=>{let t=E.get(e);t&&t.abort(gY),E.delete(e),D.delete(e),O.delete(e),te.delete(e),k.delete(e);let n=Date.now();_(t=>w(t,t=>{let r=t.ai.config.sessions.findIndex(t=>t.id===e);if(r!==-1&&(t.ai.config.sessions.splice(r,1),delete t.ai.config.sessionForks[e],t.ai.config.openSessionTabs&&(t.ai.config.openSessionTabs=t.ai.config.openSessionTabs.filter(t=>t!==e)),t.ai.config.currentSessionId===e)){let e=t.ai.config.sessions[0];e?(t.ai.config.currentSessionId=e.id,e.lastOpenedAt=n,t.ai.config.openSessionTabs?.includes(e.id)||(t.ai.config.openSessionTabs=[...t.ai.config.openSessionTabs??[],e.id])):(t.ai.config.currentSessionId=void 0,t.ai.config.openSessionTabs=[])}}))},setSessionUiMessages:(e,t)=>{let n=!1;try{return _(r=>w(r,r=>{let i=r.ai.config.sessions.find(t=>t.id===e);if(i){let e=i.uiMessages??[],r=TY(t);if(TY(e)&&!r&&t.length<=e.length)return;i.uiMessages=structuredClone(t),n=!0}})),n}catch(e){return console.error(`Failed to persist UI messages:`,e instanceof Error?e.message:e),!1}},findToolRenderer:e=>v().ai.toolRenderers[e],getBaseUrlFromSettings:()=>{let e=i?.();if(e)return e;let t=v();if(bX(t)){let e=MX(t);if(e)return e.modelProvider===`custom`?t.aiSettings.config.customModels.find(t=>t.modelName===e.model)?.baseUrl:t.aiSettings.config.providers[e.modelProvider]?.baseUrl}},getApiKeyFromSettings:()=>{let e=v(),t=MX(e);if(t){let n=r?.(t.modelProvider||`openai`);if(n)return n;if(bX(e))return t.modelProvider===`custom`?e.aiSettings.config.customModels.find(e=>e.modelName===t.model)?.apiKey||``:e.aiSettings.config.providers?.[t.modelProvider]?.apiKey||``}return``},getMaxStepsFromSettings:()=>{let e=v();if(a&&Number.isFinite(a)&&a>0)return a;if(bX(e)){let t=e.aiSettings.config.modelParameters.maxSteps;if(Number.isFinite(t)&&t>0)return t}return 50},getFullInstructions:e=>{let t=v(),n=e?t.ai.config.sessions.find(t=>t.id===e):MX(t),r=n?.runContext,i=o({session:n,runContext:r});if(r&&h){let e=h({runContext:r,session:n});e.trim().length>0&&(i=`${i}\n\n${e}`)}if(bX(t)){let{additionalInstruction:e}=t.aiSettings.config.modelParameters;e&&(i=`${i}\n\nAdditional Instructions:\n\n${e}`)}return i},sendPrompt:async(e,t={})=>{let n=v(),r=n.ai.getCurrentSession(),{systemInstructions:i,modelProvider:a,modelName:o,baseUrl:l,abortSignal:u,useTools:d=!1}=t;if(u?.aborted)throw new jY(mY);let f=a||r?.modelProvider||s,p=o||r?.model||c,m=l??n.ai.getBaseUrlFromSettings()??``,h=n.ai.tools,g=Object.fromEntries(Object.entries(h).filter(([,e])=>!e.execute)),_=pY({apiKey:n.ai.getApiKeyFromSettings(),name:f,baseURL:m}).chatModel(p);try{return(await QG({model:_,messages:[{role:`user`,content:e}],system:i||n.ai.getFullInstructions(r?.id),abortSignal:u,...d?{tools:g}:{}})).text}catch(e){let t=typeof e==`object`&&e&&`name`in e?String(e.name):``;if(u?.aborted||t===`AbortError`)throw new jY(mY);return console.error(`Error generating text:`,e),`error: can not generate response`}},startAnalysis:async e=>{let t=v(),n=t.ai.config.sessions.find(t=>t.id===e);if(!n){console.error(`Session not found:`,e);return}let r=t.ai.getChatSendMessage(e);if(!r){console.error(`No sendMessage function found for session:`,e);return}let i=new AbortController,a=n.prompt||``;t.ai.setAbortController(e,i),_(t=>w(t,t=>{let n=t.ai.config.sessions.find(t=>t.id===e);n&&(n.isRunning=!0,n.runContext=m?.(e),n.draftContextItemIds=void 0,n.prompt=``,t.ai.promptSuggestionsVisible=!1)})),r({text:a})},startNewSession:async(e,t)=>{v().ai.createSession(e);let n=v().ai.getCurrentSession();if(!n){console.error(`Failed to create session`);return}v().ai.setPrompt(n.id,t),(async()=>{let e=0,t=async()=>{if(v().ai.getChatSendMessage(n.id)){await v().ai.startAnalysis(n.id);return}if(e++,e>=50){console.error(`Timeout waiting for chat provider to register for session:`,n.id);return}setTimeout(t,20)};await t()})()},cancelAnalysis:e=>{let t=v(),n=t.ai.getAbortController(e);t.ai.getChatStop(e)?.(),n?.abort(_Y),_(t=>w(t,t=>{let n=t.ai.config.sessions.find(t=>t.id===e);n&&(n.isRunning=!1)}))},getAssistantMessageParts:e=>{let t=v().ai.getCurrentSession();if(!t)return[];let n=t.uiMessages,r=n.findIndex(t=>t.id===e&&t.role===`user`);if(r===-1)return[];for(let e=r+1;e<n.length;e++){let t=n[e];if(t?.role===`assistant`)return t.parts;if(t?.role===`user`)break}return[]},deleteAnalysisResult:(e,t)=>{_(n=>w(n,n=>{let r=n.ai.config.sessions.find(t=>t.id===e);if(r){let e=r.uiMessages,n=e.findIndex(e=>e.id===t&&e.role===`user`);if(n!==-1){let t=n+1;for(;t<e.length&&e[t]?.role!==`user`;)t++;r.uiMessages.splice(n,t-n),r.messagesRevision=(r.messagesRevision||0)+1}}}))},getAnalysisResults:()=>{let e=v().ai.getCurrentSession();if(!e)return;let t=e.uiMessages,n=b.get(t);if(n&&n.isRunning===e.isRunning)return n.results;let r=kY(t,{isRunning:e.isRunning});return b.set(t,{isRunning:e.isRunning,results:r}),r},addAnalysisResult:e=>{let t=v().ai.getCurrentSession();if(!t){console.error(`No current session found`);return}_(n=>w(n,n=>{let r=n.ai.config.sessions.find(e=>e.id===t.id);r&&r.uiMessages.push(structuredClone(e))}))},chatEndPoint:f,chatHeaders:p,getLocalChatTransport:e=>pX({store:y,defaultProvider:s,defaultModel:c,getInstructions:()=>y.getState().ai.getFullInstructions(e),getCustomModel:u,sessionId:e})(),getRemoteChatTransport:(e,t,n)=>mX({store:y,defaultProvider:s,defaultModel:c,sessionId:e,getInstructions:()=>y.getState().ai.getFullInstructions(e)})(t,n),...vX({store:y,onChatFinish:e.onChatFinish})}}})}function MX(e){let{currentSessionId:t,sessions:n}=e.ai.config;return n.find(e=>e.id===t)}var NX=k({name:y().optional().describe(`Optional session name.`),modelProvider:y().optional().describe(`Optional model provider ID.`),model:y().optional().describe(`Optional model ID.`)}).default({}),PX=k({sessionId:y().describe(`Target AI session ID.`)}),FX=k({sessionId:y().describe(`Target AI session ID.`),name:y().min(1).describe(`New session name.`)});function IX(){let e=(e,t)=>{if(!e.ai.config.sessions.some(e=>e.id===t))throw Error(`Unknown AI session "${t}".`)};return[{id:`ai.create-session`,name:`Create AI session`,description:`Start a new AI chat session`,group:`AI`,keywords:[`ai`,`chat`,`session`,`new`],inputSchema:NX,inputDescription:`Optionally provide name, modelProvider, and model for the new session.`,metadata:{readOnly:!1,idempotent:!1,riskLevel:`low`},execute:({getState:e},t)=>{let{name:n,modelProvider:r,model:i}=t??{};return e().ai.createSession(n,r,i),{success:!0,commandId:`ai.create-session`,message:`Created AI session.`}}},{id:`ai.switch-session`,name:`Switch AI session`,description:`Switch current AI session by ID`,group:`AI`,keywords:[`ai`,`chat`,`session`,`switch`],inputSchema:PX,inputDescription:`Provide sessionId to activate.`,metadata:{readOnly:!1,idempotent:!0,riskLevel:`low`},validateInput:(t,{getState:n})=>{e(n(),t.sessionId)},execute:({getState:e},t)=>{let{sessionId:n}=t;return e().ai.switchSession(n),{success:!0,commandId:`ai.switch-session`,message:`Switched to AI session "${n}".`}}},{id:`ai.rename-session`,name:`Rename AI session`,description:`Rename AI session by ID`,group:`AI`,keywords:[`ai`,`chat`,`session`,`rename`],inputSchema:FX,inputDescription:`Provide sessionId and new name.`,metadata:{readOnly:!1,idempotent:!0,riskLevel:`low`},validateInput:(t,{getState:n})=>{e(n(),t.sessionId)},execute:({getState:e},t)=>{let{sessionId:n,name:r}=t;return e().ai.renameSession(n,r),{success:!0,commandId:`ai.rename-session`,message:`Renamed AI session "${n}".`}}},{id:`ai.delete-session`,name:`Delete AI session`,description:`Delete AI session by ID`,group:`AI`,keywords:[`ai`,`chat`,`session`,`delete`],inputSchema:PX,inputDescription:`Provide sessionId to delete.`,metadata:{readOnly:!1,idempotent:!0,riskLevel:`medium`,requiresConfirmation:!0},validateInput:(t,{getState:n})=>{let r=n(),{sessionId:i}=t;e(r,i)},execute:({getState:e},t)=>{let{sessionId:n}=t;return e().ai.deleteSession(n),{success:!0,commandId:`ai.delete-session`,message:`Deleted AI session "${n}".`}}},{id:`ai.cancel-current-analysis`,name:`Cancel current AI analysis`,description:`Stop the currently running AI response`,group:`AI`,keywords:[`ai`,`chat`,`cancel`,`stop`,`analysis`],metadata:{readOnly:!1,idempotent:!0,riskLevel:`low`},isEnabled:({getState:e})=>!!e().ai.getCurrentSession()?.isRunning,execute:({getState:e})=>{let t=e().ai.getCurrentSession();return t?(e().ai.cancelAnalysis(t.id),{success:!0,commandId:`ai.cancel-current-analysis`,message:`Cancelled analysis for session "${t.id}".`}):{success:!1,commandId:`ai.cancel-current-analysis`,message:`No active session.`,error:`no active session`}}}]}function LX(e){return O(t=>e(t))}export{ub as $,uc as $t,IA as A,Nd as At,JT as B,H as Bt,$z as C,Wu as Ct,aF as D,Ad as Dt,iF as E,Fd as Et,Yk as F,Gu as Ft,sx as G,Zl as Gt,Uw as H,B as Ht,QE as I,cf as It,Xb as J,tu as Jt,Qb as K,$l as Kt,GE as L,Yu as Lt,mA as M,hd as Mt,OA as N,ud as Nt,EP as O,kd as Ot,pA as P,Uu as Pt,lb as Q,Rc as Qt,jE as R,gu as Rt,qG as S,Dd as St,rF as T,Ed as Tt,ix as U,Dl as Ut,NT as V,Al as Vt,ax as W,El as Wt,qb as X,Qc as Xt,Zb as Y,z as Yt,bb as Z,rl as Zt,qK as _,ke as _n,Ku as _t,MY as a,An as an,hv as at,YK as b,ve as bn,ed as bt,PY as c,Un as cn,qh as ct,LY as d,Be as dn,wg as dt,Qn as en,cb as et,wY as f,Ve as fn,ch as ft,JK as g,Te as gn,Ju as gt,pY as h,Ne as hn,rf as ht,QY as i,Wt as in,yv as it,DA as j,Zu as jt,uN as k,Od as kt,NY as l,We as ln,xg as lt,mY as m,Pe as mn,vg as mt,LX as n,P as nn,Cv as nt,WY as o,I as on,ev as ot,OY as p,Ue as pn,ph as pt,$b as q,jl as qt,bX as r,Cn as rn,vv as rt,IY as s,Vt as sn,ih as st,jX as t,ir as tn,Sv as tt,FY as u,He as un,sh as ut,IK as v,De as vn,cd as vt,lF as w,wd as wt,XK as x,xf as xt,UK as y,Me as yn,sd as yt,iE as z,xu as zt};
|